diff options
author | Sebastian Schmidt <mrschmidt@google.com> | 2018-02-12 19:11:45 -0800 |
---|---|---|
committer | Sebastian Schmidt <mrschmidt@google.com> | 2018-02-13 10:27:53 -0800 |
commit | 12faf205f34042aa7fb6ff13c6980556dbb1ba39 (patch) | |
tree | 4f6300167f06b0cb68fb5c5fb3274293df62bb91 | |
parent | adf9fb31eeef639ef23b2ff22a71adaa91a263b7 (diff) |
Cleaning up implicit retain for the RTDB and Storage
-rw-r--r-- | Example/Database/Tests/Integration/FData.m | 6 | ||||
-rw-r--r-- | Example/Database/Tests/Integration/FRealtime.m | 1 | ||||
-rw-r--r-- | Example/Database/Tests/Unit/FSyncPointTests.m | 6 | ||||
-rw-r--r-- | Example/Firebase.xcodeproj/project.pbxproj | 4 | ||||
-rw-r--r-- | Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m | 2 | ||||
-rw-r--r-- | Firebase/Database/third_party/SocketRocket/FSRWebSocket.m | 34 | ||||
-rw-r--r-- | Firebase/Storage/FIRStorageDeleteTask.m | 2 | ||||
-rw-r--r-- | Firebase/Storage/FIRStorageDownloadTask.m | 6 | ||||
-rw-r--r-- | Firebase/Storage/FIRStorageGetMetadataTask.m | 4 | ||||
-rw-r--r-- | Firebase/Storage/FIRStorageMetadata.m | 4 | ||||
-rw-r--r-- | Firebase/Storage/FIRStorageUpdateMetadataTask.m | 4 | ||||
-rw-r--r-- | Firebase/Storage/FIRStorageUploadTask.m | 8 |
12 files changed, 45 insertions, 36 deletions
diff --git a/Example/Database/Tests/Integration/FData.m b/Example/Database/Tests/Integration/FData.m index aef15e1..d036f77 100644 --- a/Example/Database/Tests/Integration/FData.m +++ b/Example/Database/Tests/Integration/FData.m @@ -487,7 +487,7 @@ [[ref child:@"100003354884401"] setValue:@"alpha"]; __block BOOL ready = NO; - [ref observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) { + [ref observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) { id val = [snapshot value]; XCTAssertTrue([val isKindOfClass:[NSDictionary class]], @"Expected a dictionary."); ready = YES; @@ -678,6 +678,8 @@ [self waitUntil:^BOOL{ return setDone && calls == 1; }]; + + [node removeAllObservers]; } - (void) testHasChildrenWorksCorrectly { @@ -878,6 +880,7 @@ [self waitUntil:^BOOL{ return calls == 1; }]; + [reader removeAllObservers]; } - (void) testSetPriorityOnNonexistentNodeFails { @@ -2208,6 +2211,7 @@ }]; WAIT_FOR(done); + [deleter removeAllObservers]; } - (void) testParentDeleteShadowsChildListenersWithNonDefaultQuery { diff --git a/Example/Database/Tests/Integration/FRealtime.m b/Example/Database/Tests/Integration/FRealtime.m index 5c7d186..5acda07 100644 --- a/Example/Database/Tests/Integration/FRealtime.m +++ b/Example/Database/Tests/Integration/FRealtime.m @@ -481,6 +481,7 @@ WAIT_FOR(count == 2); // cleanup + [reader removeAllObservers]; [FRepoManager disposeRepos:writerCfg]; } diff --git a/Example/Database/Tests/Unit/FSyncPointTests.m b/Example/Database/Tests/Unit/FSyncPointTests.m index 797a5aa..de4680f 100644 --- a/Example/Database/Tests/Unit/FSyncPointTests.m +++ b/Example/Database/Tests/Unit/FSyncPointTests.m @@ -86,15 +86,15 @@ typedef NSDictionary* (^fbt_nsdictionary_void)(void); } - (void) fireEvent:(id<FEvent>)event queue:(dispatch_queue_t)queue { - [NSException raise:@"NotImplementedError" format:@"Method not implemneted."]; + [NSException raise:@"NotImplementedError" format:@"Method not implemented."]; } - (FCancelEvent *) createCancelEventFromError:(NSError *)error path:(FPath *)path { - [NSException raise:@"NotImplementedError" format:@"Method not implemneted."]; + [NSException raise:@"NotImplementedError" format:@"Method not implemented."]; return nil; } - (FIRDatabaseHandle) handle { - [NSException raise:@"NotImplementedError" format:@"Method not implemneted."]; + [NSException raise:@"NotImplementedError" format:@"Method not implemented."]; return 0; } @end diff --git a/Example/Firebase.xcodeproj/project.pbxproj b/Example/Firebase.xcodeproj/project.pbxproj index 9431ae0..c8400d6 100644 --- a/Example/Firebase.xcodeproj/project.pbxproj +++ b/Example/Firebase.xcodeproj/project.pbxproj @@ -8111,6 +8111,7 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/Database/App/iOS/Database-Info.plist"; @@ -8129,6 +8130,7 @@ CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; @@ -8650,6 +8652,7 @@ baseConfigurationReference = 06F3D16439F061DE9973902D /* Pods-Storage_Example_iOS.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -8671,6 +8674,7 @@ baseConfigurationReference = D440FB786B320FCF836B508F /* Pods-Storage_Example_iOS.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m index 703c2c6..8e826c9 100644 --- a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m +++ b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m @@ -33,7 +33,7 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30; * A sample configuration may look like: * * service firebase.storage { - * match /b/{YOUR_PROJECT_ID}.appspot.com/o { + * match /b/{bucket}/o { * ... * match /ios { * match /public/{allPaths=**} { diff --git a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m index c80dbb0..9b3dad0 100644 --- a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m +++ b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m @@ -515,10 +515,10 @@ static __strong NSData *CRLFCRLF; } [self _readUntilHeaderCompleteWithCallback:^(FSRWebSocket *self, NSData *data) { - CFHTTPMessageAppendBytes(_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length); + CFHTTPMessageAppendBytes(self->_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length); - if (CFHTTPMessageIsHeaderComplete(_receivedHTTPHeaders)) { - SRFastLog(@"Finished reading headers %@", CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(_receivedHTTPHeaders))); + if (CFHTTPMessageIsHeaderComplete(self->_receivedHTTPHeaders)) { + SRFastLog(@"Finished reading headers %@", CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(self->_receivedHTTPHeaders))); [self _HTTPHeadersDidFinish]; } else { [self _readHTTPHeader]; @@ -696,7 +696,7 @@ static __strong NSData *CRLFCRLF; // Need to shunt this on the _callbackQueue first to see if they received any messages [self _performDelegateBlock:^{ [self closeWithCode:SRStatusCodeProtocolError reason:message]; - dispatch_async(_workQueue, ^{ + dispatch_async(self->_workQueue, ^{ [self _disconnect]; }); }]; @@ -706,7 +706,7 @@ static __strong NSData *CRLFCRLF; { dispatch_async(_workQueue, ^{ if (self.readyState != SR_CLOSED) { - _failed = YES; + self->_failed = YES; [self _performDelegateBlock:^{ if ([self.delegate respondsToSelector:@selector(webSocket:didFailWithError:)]) { [self.delegate webSocket:self didFailWithError:error]; @@ -756,7 +756,7 @@ static __strong NSData *CRLFCRLF; { // Need to pingpong this off _callbackQueue first to make sure messages happen in order [self _performDelegateBlock:^{ - dispatch_async(_workQueue, ^{ + dispatch_async(self->_workQueue, ^{ [self _sendFrameWithOpcode:SROpCodePong data:pingData]; }); }]; @@ -1031,7 +1031,7 @@ static const uint8_t SRPayloadLenMask = 0x7F; [self _closeWithProtocolError:@"Client must receive unmasked data"]; } - size_t extra_bytes_needed = header.masked ? sizeof(_currentReadMaskKey) : 0; + size_t extra_bytes_needed = header.masked ? sizeof(self->_currentReadMaskKey) : 0; if (header.payload_length == 126) { extra_bytes_needed += sizeof(uint16_t); @@ -1062,7 +1062,7 @@ static const uint8_t SRPayloadLenMask = 0x7F; if (header.masked) { - assert(mapped_size >= sizeof(_currentReadMaskOffset) + offset); + assert(mapped_size >= sizeof(self->_currentReadMaskOffset) + offset); memcpy(self->_currentReadMaskKey, ((uint8_t *)mapped_buffer) + offset, sizeof(self->_currentReadMaskKey)); } @@ -1075,12 +1075,12 @@ static const uint8_t SRPayloadLenMask = 0x7F; - (void)_readFrameNew; { dispatch_async(_workQueue, ^{ - [_currentFrameData setLength:0]; + [self->_currentFrameData setLength:0]; - _currentFrameOpcode = 0; - _currentFrameCount = 0; - _readOpCount = 0; - _currentStringScanPosition = 0; + self->_currentFrameOpcode = 0; + self->_currentFrameCount = 0; + self->_readOpCount = 0; + self->_currentStringScanPosition = 0; [self _readFrameContinue]; }); @@ -1123,7 +1123,7 @@ static const uint8_t SRPayloadLenMask = 0x7F; if (!_failed) { [self _performDelegateBlock:^{ if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) { - [self.delegate webSocket:self didCloseWithCode:_closeCode reason:_closeReason wasClean:YES]; + [self.delegate webSocket:self didCloseWithCode:self->_closeCode reason:self->_closeReason wasClean:YES]; } }]; } @@ -1184,7 +1184,7 @@ static const uint8_t SRPayloadLenMask = 0x7F; // Cleanup selfRetain in the same GCD queue as usual dispatch_async(_workQueue, ^{ - _selfRetain = nil; + self->_selfRetain = nil; }); } @@ -1525,8 +1525,8 @@ static const size_t SRFrameHeaderOverhead = 32; [self _scheduleCleanup]; } - if (!_sentClose && !_failed) { - _sentClose = YES; + if (!self->_sentClose && !self->_failed) { + self->_sentClose = YES; // If we get closed in this state it's probably not clean because we should be sending this when we send messages [self _performDelegateBlock:^{ if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) { diff --git a/Firebase/Storage/FIRStorageDeleteTask.m b/Firebase/Storage/FIRStorageDeleteTask.m index 738d8a5..b41f06e 100644 --- a/Firebase/Storage/FIRStorageDeleteTask.m +++ b/Firebase/Storage/FIRStorageDeleteTask.m @@ -60,7 +60,7 @@ if (callback) { callback(self.error); } - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; }; #pragma clang diangostic pop diff --git a/Firebase/Storage/FIRStorageDownloadTask.m b/Firebase/Storage/FIRStorageDownloadTask.m index c410f05..91da4b7 100644 --- a/Firebase/Storage/FIRStorageDownloadTask.m +++ b/Firebase/Storage/FIRStorageDownloadTask.m @@ -116,7 +116,7 @@ self.error = [FIRStorageErrors errorWithServerError:error reference:self.reference]; [self fireHandlersForStatus:FIRStorageTaskStatusFailure snapshot:self.snapshot]; [self removeAllObservers]; - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; return; } @@ -124,12 +124,12 @@ self.state = FIRStorageTaskStateSuccess; if (data) { - _downloadData = data; + self->_downloadData = data; } [self fireHandlersForStatus:FIRStorageTaskStatusSuccess snapshot:self.snapshot]; [self removeAllObservers]; - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; }; #pragma clang diagnostic pop diff --git a/Firebase/Storage/FIRStorageGetMetadataTask.m b/Firebase/Storage/FIRStorageGetMetadataTask.m index 78d8a16..2623652 100644 --- a/Firebase/Storage/FIRStorageGetMetadataTask.m +++ b/Firebase/Storage/FIRStorageGetMetadataTask.m @@ -65,7 +65,7 @@ if (callback) { callback(nil, self.error); } - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; return; } @@ -90,7 +90,7 @@ callback(nil, self.error); } } - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; }; #pragma clang diagnostic pop diff --git a/Firebase/Storage/FIRStorageMetadata.m b/Firebase/Storage/FIRStorageMetadata.m index 34ac86c..5c12595 100644 --- a/Firebase/Storage/FIRStorageMetadata.m +++ b/Firebase/Storage/FIRStorageMetadata.m @@ -60,8 +60,8 @@ NSURLComponents *components = [[NSURLComponents alloc] init]; components.scheme = kFIRStorageScheme; components.host = kFIRStorageHost; - NSString *path = [FIRStorageUtils GCSEscapedString:_path]; - NSString *fullPath = [NSString stringWithFormat:kFIRStorageFullPathFormat, _bucket, path]; + NSString *path = [FIRStorageUtils GCSEscapedString:self->_path]; + NSString *fullPath = [NSString stringWithFormat:kFIRStorageFullPathFormat, self->_bucket, path]; components.percentEncodedPath = fullPath; components.query = [NSString stringWithFormat:@"alt=media&token=%@", token]; diff --git a/Firebase/Storage/FIRStorageUpdateMetadataTask.m b/Firebase/Storage/FIRStorageUpdateMetadataTask.m index cf1bf93..fa5955a 100644 --- a/Firebase/Storage/FIRStorageUpdateMetadataTask.m +++ b/Firebase/Storage/FIRStorageUpdateMetadataTask.m @@ -71,7 +71,7 @@ if (callback) { callback(nil, self.error); } - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; return; } @@ -96,7 +96,7 @@ callback(nil, self.error); } } - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; }; #pragma clang diagnostic pop diff --git a/Firebase/Storage/FIRStorageUploadTask.m b/Firebase/Storage/FIRStorageUploadTask.m index 0df0bf4..f84c2c7 100644 --- a/Firebase/Storage/FIRStorageUploadTask.m +++ b/Firebase/Storage/FIRStorageUploadTask.m @@ -117,7 +117,7 @@ weakSelf.state = FIRStorageTaskStateProgress; weakSelf.progress.completedUnitCount = totalBytesSent; weakSelf.progress.totalUnitCount = totalBytesExpectedToSend; - weakSelf.metadata = _uploadMetadata; + weakSelf.metadata = self->_uploadMetadata; [weakSelf fireHandlersForStatus:FIRStorageTaskStatusProgress snapshot:weakSelf.snapshot]; weakSelf.state = FIRStorageTaskStateRunning; }]; @@ -137,10 +137,10 @@ if (error) { self.state = FIRStorageTaskStateFailed; self.error = [FIRStorageErrors errorWithServerError:error reference:self.reference]; - self.metadata = _uploadMetadata; + self.metadata = self->_uploadMetadata; [self fireHandlersForStatus:FIRStorageTaskStatusFailure snapshot:self.snapshot]; [self removeAllObservers]; - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; return; } @@ -166,7 +166,7 @@ [self fireHandlersForStatus:FIRStorageTaskStatusSuccess snapshot:self.snapshot]; [self removeAllObservers]; - _fetcherCompletion = nil; + self->_fetcherCompletion = nil; }; #pragma clang diagnostic pop |