Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,40 @@ + (instancetype)controllerWithDataSource:(id<PFCurrentUserControllerProvider>)da

- (BFTask<PFACL *> *)getDefaultACLAsync {
return [_taskQueue enqueue:^id(BFTask *task) {
if (!_defaultACL || !_useCurrentUser) {
return _defaultACL;
if (!self->_defaultACL || !self->_useCurrentUser) {
return self->_defaultACL;
}

PFCurrentUserController *currentUserController = self.dataSource.currentUserController;
return [[currentUserController getCurrentObjectAsync] continueWithBlock:^id(BFTask *task) {
PFUser *currentUser = task.result;
if (!currentUser) {
return _defaultACL;
return self->_defaultACL;
}

if (currentUser != _lastCurrentUser) {
_defaultACLWithCurrentUser = [_defaultACL createUnsharedCopy];
[_defaultACLWithCurrentUser setShared:YES];
[_defaultACLWithCurrentUser setReadAccess:YES forUser:currentUser];
[_defaultACLWithCurrentUser setWriteAccess:YES forUser:currentUser];
_lastCurrentUser = currentUser;
if (currentUser != self->_lastCurrentUser) {
self->_defaultACLWithCurrentUser = [self->_defaultACL createUnsharedCopy];
[self->_defaultACLWithCurrentUser setShared:YES];
[self->_defaultACLWithCurrentUser setReadAccess:YES forUser:currentUser];
[self->_defaultACLWithCurrentUser setWriteAccess:YES forUser:currentUser];
self->_lastCurrentUser = currentUser;
}
return _defaultACLWithCurrentUser;
return self->_defaultACLWithCurrentUser;
}];
}];
}

- (BFTask<PFACL *> *)setDefaultACLAsync:(PFACL *)acl withCurrentUserAccess:(BOOL)accessForCurrentUser {
return [_taskQueue enqueue:^id(BFTask *task) {
_defaultACLWithCurrentUser = nil;
_lastCurrentUser = nil;
self->_defaultACLWithCurrentUser = nil;
self->_lastCurrentUser = nil;

_defaultACL = [acl createUnsharedCopy];
[_defaultACL setShared:YES];
self->_defaultACL = [acl createUnsharedCopy];
[self->_defaultACL setShared:YES];

_useCurrentUser = accessForCurrentUser;
self->_useCurrentUser = accessForCurrentUser;

return _defaultACL;
return self->_defaultACL;
}];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ - (void)dealloc {
BOOL success = [command resolveLocalIds:&error];
PFPreconditionReturnFailedTask(success, error);
return [[self.requestConstructor getDataURLRequestAsyncForCommand:command] continueWithSuccessBlock:^id(BFTask <NSURLRequest *>*task) {
return [_session performDataURLRequestAsync:task.result forCommand:command cancellationToken:cancellationToken];
return [self->_session performDataURLRequestAsync:task.result forCommand:command cancellationToken:cancellationToken];
}];
} withOptions:options cancellationToken:cancellationToken];
}
Expand All @@ -177,7 +177,7 @@ - (void)dealloc {
return [[self.requestConstructor getFileUploadURLRequestAsyncForCommand:command
withContentType:contentType
contentSourceFilePath:sourceFilePath] continueWithSuccessBlock:^id(BFTask<NSURLRequest *> *task) {
return [_session performFileUploadURLRequestAsync:task.result
return [self->_session performFileUploadURLRequestAsync:task.result
forCommand:command
withContentSourceFilePath:sourceFilePath
cancellationToken:cancellationToken
Expand All @@ -192,7 +192,7 @@ - (void)dealloc {
progressBlock:(nullable PFProgressBlock)progressBlock {
return [self _performCommandRunningBlock:^id {
NSURLRequest *request = [NSURLRequest requestWithURL:url];
return [_session performFileDownloadURLRequestAsync:request
return [self->_session performFileDownloadURLRequestAsync:request
toFileAtPath:filePath
withCancellationToken:cancellationToken
progressBlock:progressBlock];
Expand Down Expand Up @@ -241,7 +241,7 @@ - (BFTask *)_performCommandRunningBlock:(nonnull id (^)(void))block
if ([task.error.userInfo[@"temporary"] boolValue] && attempts > 1) {
PFLogError(PFLoggingTagCommon,
@"Network connection failed. Making attempt %lu after sleeping for %f seconds.",
(unsigned long)(_retryAttempts - attempts + 1), (double)delay);
(unsigned long)(self->_retryAttempts - attempts + 1), (double)delay);

return [[BFTask taskWithDelay:(int)(delay * 1000)] continueWithBlock:^id(BFTask *task) {
return [self _performCommandRunningBlock:block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ - (BFTask *)performDataURLRequestAsync:(NSURLRequest *)request
}

__block NSURLSessionDataTask *task = nil;
dispatch_sync(_sessionTaskQueue, ^{
task = [_urlSession dataTaskWithRequest:request];
dispatch_sync(self->_sessionTaskQueue, ^{
task = [self->_urlSession dataTaskWithRequest:request];
});
PFURLSessionDataTaskDelegate *delegate = [PFURLSessionJSONDataTaskDelegate taskDelegateForDataTask:task
withCancellationToken:cancellationToken];
Expand All @@ -125,8 +125,8 @@ - (BFTask *)performFileUploadURLRequestAsync:(NSURLRequest *)request
}

__block NSURLSessionDataTask *task = nil;
dispatch_sync(_sessionTaskQueue, ^{
task = [_urlSession uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:sourceFilePath]];
dispatch_sync(self->_sessionTaskQueue, ^{
task = [self->_urlSession uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:sourceFilePath]];
});
PFURLSessionUploadTaskDelegate *delegate = [PFURLSessionUploadTaskDelegate taskDelegateForDataTask:task
withCancellationToken:cancellationToken
Expand All @@ -151,8 +151,8 @@ - (BFTask *)performFileDownloadURLRequestAsync:(NSURLRequest *)request
}

__block NSURLSessionDataTask *task = nil;
dispatch_sync(_sessionTaskQueue, ^{
task = [_urlSession dataTaskWithRequest:request];
dispatch_sync(self->_sessionTaskQueue, ^{
task = [self->_urlSession dataTaskWithRequest:request];
});
PFURLSessionFileDownloadTaskDelegate *delegate = [PFURLSessionFileDownloadTaskDelegate taskDelegateForDataTask:task
withCancellationToken:cancellationToken
Expand Down Expand Up @@ -194,20 +194,20 @@ - (BFTask *)_performDataTask:(NSURLSessionDataTask *)dataTask withDelegate:(PFUR
- (PFURLSessionDataTaskDelegate *)_taskDelegateForTask:(NSURLSessionTask *)task {
__block PFURLSessionDataTaskDelegate *delegate = nil;
dispatch_sync(_delegatesAccessQueue, ^{
delegate = _delegatesDictionary[@(task.taskIdentifier)];
delegate = self->_delegatesDictionary[@(task.taskIdentifier)];
});
return delegate;
}

- (void)setDelegate:(PFURLSessionDataTaskDelegate *)delegate forDataTask:(NSURLSessionDataTask *)task {
dispatch_barrier_async(_delegatesAccessQueue, ^{
_delegatesDictionary[@(task.taskIdentifier)] = delegate;
self->_delegatesDictionary[@(task.taskIdentifier)] = delegate;
});
}

- (void)_removeDelegateForTaskWithIdentifier:(NSNumber *)identifier {
dispatch_barrier_async(_delegatesAccessQueue, ^{
[_delegatesDictionary removeObjectForKey:identifier];
[self->_delegatesDictionary removeObjectForKey:identifier];
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ - (void)URLSession:(NSURLSession *)session
totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
int progress = (int)round(totalBytesSent / (double)totalBytesExpectedToSend * 100);
dispatch_async(dispatch_get_main_queue(), ^{
if (_progressBlock) {
_progressBlock(progress);
if (self->_progressBlock) {
self->_progressBlock(progress);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions Parse/Parse/Internal/Commands/PFRESTPushCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ NS_ASSUME_NONNULL_BEGIN

PF_TV_UNAVAILABLE PF_WATCH_UNAVAILABLE @interface PFRESTPushCommand : PFRESTCommand

+ (instancetype)sendPushCommandWithPushState:(PFPushState *)state
sessionToken:(nullable NSString *)sessionToken
error:(NSError **)error;
+ (nullable instancetype)sendPushCommandWithPushState:(PFPushState *)state
sessionToken:(nullable NSString *)sessionToken
error:(NSError **)error;

@end

Expand Down
6 changes: 3 additions & 3 deletions Parse/Parse/Internal/Config/Controller/PFConfigController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ - (BFTask *)fetchConfigAsyncWithSessionToken:(NSString *)sessionToken {
- (PFCurrentConfigController *)currentConfigController {
__block PFCurrentConfigController *controller = nil;
dispatch_sync(_dataAccessQueue, ^{
if (!_currentConfigController) {
_currentConfigController = [[PFCurrentConfigController alloc] initWithDataSource:self.dataSource];
if (!self->_currentConfigController) {
self->_currentConfigController = [[PFCurrentConfigController alloc] initWithDataSource:self.dataSource];
}
controller = _currentConfigController;
controller = self->_currentConfigController;
});
return controller;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ + (instancetype)controllerWithDataSource:(id<PFPersistenceControllerProvider>)da

- (BFTask *)getCurrentConfigAsync {
return [_dataTaskQueue enqueue:^id(BFTask *_) {
if (!_currentConfig) {
if (!self->_currentConfig) {
return [[self _loadConfigAsync] continueWithSuccessBlock:^id(BFTask<PFConfig *> *task) {
_currentConfig = task.result;
return _currentConfig;
self->_currentConfig = task.result;
return self->_currentConfig;
}];
}
return _currentConfig;
return self->_currentConfig;
}];
}

- (BFTask *)setCurrentConfigAsync:(PFConfig *)config {
@weakify(self);
return [_dataTaskQueue enqueue:^id(BFTask *_) {
@strongify(self);
_currentConfig = config;
self->_currentConfig = config;

NSDictionary *configParameters = @{ PFConfigParametersRESTKey : (config.parametersDictionary ?: @{}) };
NSError *error;
Expand All @@ -88,7 +88,7 @@ - (BFTask *)clearCurrentConfigAsync {
@weakify(self);
return [_dataTaskQueue enqueue:^id(BFTask *_) {
@strongify(self);
_currentConfig = nil;
self->_currentConfig = nil;
return [[self.dataSource.persistenceController getPersistenceGroupAsync] continueWithSuccessBlock:^id(BFTask<id<PFPersistenceGroup>> *task) {
return [task.result removeDataAsyncForKey:PFConfigCurrentConfigFileName_];
}];
Expand All @@ -97,7 +97,7 @@ - (BFTask *)clearCurrentConfigAsync {

- (BFTask *)clearMemoryCachedCurrentConfigAsync {
return [_dataTaskQueue enqueue:^id(BFTask *_) {
_currentConfig = nil;
self->_currentConfig = nil;
return nil;
}];
}
Expand Down
30 changes: 15 additions & 15 deletions Parse/Parse/Internal/File/Controller/PFFileController.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ + (instancetype)controllerWithDataSource:(id<PFCommandRunnerProvider, PFFileMana
- (PFFileStagingController *)fileStagingController {
__block PFFileStagingController *result = nil;
dispatch_sync(_fileStagingControllerAccessQueue, ^{
if (!_fileStagingController) {
_fileStagingController = [PFFileStagingController controllerWithDataSource:self.dataSource];
if (!self->_fileStagingController) {
self->_fileStagingController = [PFFileStagingController controllerWithDataSource:self.dataSource];
}
result = _fileStagingController;
result = self->_fileStagingController;
});
return result;
}
Expand Down Expand Up @@ -119,14 +119,14 @@ - (PFFileStagingController *)fileStagingController {
return task;
}];
}] continueWithBlock:^id(BFTask *task) {
dispatch_barrier_async(_downloadDataAccessQueue, ^{
[_downloadTasks removeObjectForKey:fileState.secureURLString];
[_downloadProgressBlocks removeObjectForKey:fileState.secureURLString];
dispatch_barrier_async(self->_downloadDataAccessQueue, ^{
[self->_downloadTasks removeObjectForKey:fileState.secureURLString];
[self->_downloadProgressBlocks removeObjectForKey:fileState.secureURLString];
});
return task;
}];
dispatch_barrier_async(_downloadDataAccessQueue, ^{
_downloadTasks[fileState.secureURLString] = resultTask;
dispatch_barrier_async(self->_downloadDataAccessQueue, ^{
self->_downloadTasks[fileState.secureURLString] = resultTask;
});
}
return resultTask;
Expand Down Expand Up @@ -158,8 +158,8 @@ - (PFFileStagingController *)fileStagingController {

- (BFTask *)_fileDownloadResultTaskForFileWithState:(PFFileState *)state {
__block BFTask *resultTask = nil;
dispatch_sync(_downloadDataAccessQueue, ^{
resultTask = _downloadTasks[state.secureURLString];
dispatch_sync(self->_downloadDataAccessQueue, ^{
resultTask = self->_downloadTasks[state.secureURLString];
});
return resultTask;
}
Expand All @@ -168,8 +168,8 @@ - (PFProgressBlock)_fileDownloadUnifyingProgressBlockForFileState:(PFFileState *
return ^(int progress) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
__block NSArray *blocks = nil;
dispatch_sync(_downloadDataAccessQueue, ^{
blocks = [_downloadProgressBlocks[fileState.secureURLString] copy];
dispatch_sync(self->_downloadDataAccessQueue, ^{
blocks = [self->_downloadProgressBlocks[fileState.secureURLString] copy];
});
if (blocks.count != 0) {
dispatch_async(dispatch_get_main_queue(), ^{
Expand All @@ -187,11 +187,11 @@ - (void)_addFileDownloadProgressBlock:(PFProgressBlock)block forFileWithState:(P
return;
}

dispatch_barrier_async(_downloadDataAccessQueue, ^{
NSMutableArray *progressBlocks = _downloadProgressBlocks[state.secureURLString];
dispatch_barrier_async(self->_downloadDataAccessQueue, ^{
NSMutableArray *progressBlocks = self->_downloadProgressBlocks[state.secureURLString];
if (!progressBlocks) {
progressBlocks = [NSMutableArray arrayWithObject:block];
_downloadProgressBlocks[state.secureURLString] = progressBlocks;
self->_downloadProgressBlocks[state.secureURLString] = progressBlocks;
} else {
[progressBlocks addObject:block];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ - (BFTask *)getCurrentObjectAsync {
return installation;
}];
}] continueWithBlock:^id(BFTask *task) {
dispatch_barrier_sync(_dataQueue, ^{
_currentInstallation = task.result;
_currentInstallationMatchesDisk = !task.faulted;
dispatch_barrier_sync(self->_dataQueue, ^{
self->_currentInstallation = task.result;
self->_currentInstallationMatchesDisk = !task.faulted;
});
return task;
}];
Expand Down Expand Up @@ -167,9 +167,9 @@ - (BFTask *)clearCurrentInstallationAsync {
return [_dataTaskQueue enqueue:^BFTask *(BFTask *unused) {
@strongify(self);

dispatch_barrier_sync(_dataQueue, ^{
_currentInstallation = nil;
_currentInstallationMatchesDisk = NO;
dispatch_barrier_sync(self->_dataQueue, ^{
self->_currentInstallation = nil;
self->_currentInstallationMatchesDisk = NO;
});

NSMutableArray *tasks = [NSMutableArray arrayWithCapacity:2];
Expand Down Expand Up @@ -252,30 +252,30 @@ - (PFInstallationIdentifierStore *)installationIdentifierStore {
- (PFInstallation *)currentInstallation {
__block PFInstallation *installation = nil;
dispatch_sync(_dataQueue, ^{
installation = _currentInstallation;
installation = self->_currentInstallation;
});
return installation;
}

- (void)setCurrentInstallation:(PFInstallation *)currentInstallation {
dispatch_barrier_sync(_dataQueue, ^{
if (_currentInstallation != currentInstallation) {
_currentInstallation = currentInstallation;
if (self->_currentInstallation != currentInstallation) {
self->_currentInstallation = currentInstallation;
}
});
}

- (BOOL)currentInstallationMatchesDisk {
__block BOOL matches = NO;
dispatch_sync(_dataQueue, ^{
matches = _currentInstallationMatchesDisk;
matches = self->_currentInstallationMatchesDisk;
});
return matches;
}

- (void)setCurrentInstallationMatchesDisk:(BOOL)currentInstallationMatchesDisk {
dispatch_barrier_sync(_dataQueue, ^{
_currentInstallationMatchesDisk = currentInstallationMatchesDisk;
self->_currentInstallationMatchesDisk = currentInstallationMatchesDisk;
});
}

Expand Down
2 changes: 1 addition & 1 deletion Parse/Parse/Internal/KeyValueCache/PFKeyValueCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ - (void)removeAllObjects {

dispatch_sync(_diskCacheQueue, ^{
// Directory will be automatically recreated the next time 'cacheDir' is accessed.
[self.fileManager removeItemAtURL:_cacheDirectoryURL error:NULL];
[self.fileManager removeItemAtURL:self->_cacheDirectoryURL error:NULL];
});
}

Expand Down
8 changes: 4 additions & 4 deletions Parse/Parse/Internal/LocalDataStore/SQLite/PFSQLiteDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ - (BFTask *)openAsync {
}

// Check if this database have already been opened before.
if (_databaseClosedTaskCompletionSource.task.completed) {
if (self->_databaseClosedTaskCompletionSource.task.completed) {
NSError *error = [self _errorWithErrorCode:PFSQLiteDatabaseDatabaseAlreadyClosed
errorMessage:@"Closed database cannot be reopen."
domain:PFSQLiteDatabaseErrorPFSQLiteDatabaseDomain];
Expand Down Expand Up @@ -146,12 +146,12 @@ - (BFTask *)closeAsync {
if (resultCode == SQLITE_OK) {

self.database = nil;
[_databaseClosedTaskCompletionSource setResult:nil];
[self->_databaseClosedTaskCompletionSource setResult:nil];
} else {
// Returns error
[_databaseClosedTaskCompletionSource setError:[self _errorWithErrorCode:resultCode]];
[self->_databaseClosedTaskCompletionSource setError:[self _errorWithErrorCode:resultCode]];
}
return _databaseClosedTaskCompletionSource.task;
return self->_databaseClosedTaskCompletionSource.task;
}];
}

Expand Down
Loading