Skip to content

Commit b6613bd

Browse files
Cleaning up implicit retain for the RTDB and Storage
Cleaning up implicit retain for the RTDB and Storage
2 parents 5f5f808 + 6496eca commit b6613bd

File tree

12 files changed

+46
-36
lines changed

12 files changed

+46
-36
lines changed

Example/Database/Tests/Integration/FData.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ - (void) testLargeNumericKeysDontGetTurnedIntoArrays {
487487
[[ref child:@"100003354884401"] setValue:@"alpha"];
488488

489489
__block BOOL ready = NO;
490-
[ref observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
490+
[ref observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
491491
id val = [snapshot value];
492492
XCTAssertTrue([val isKindOfClass:[NSDictionary class]], @"Expected a dictionary.");
493493
ready = YES;
@@ -678,6 +678,8 @@ - (void) testSetAndThenListenForValueEventsAreCorrect {
678678
[self waitUntil:^BOOL{
679679
return setDone && calls == 1;
680680
}];
681+
682+
[node removeAllObservers];
681683
}
682684

683685
- (void) testHasChildrenWorksCorrectly {
@@ -878,6 +880,7 @@ - (void) testListenForValueAndThenWriteOnANodeWithExistingData {
878880
[self waitUntil:^BOOL{
879881
return calls == 1;
880882
}];
883+
[reader removeAllObservers];
881884
}
882885

883886
- (void) testSetPriorityOnNonexistentNodeFails {
@@ -2208,6 +2211,7 @@ - (void) testParentDeleteShadowsChildListeners {
22082211
}];
22092212

22102213
WAIT_FOR(done);
2214+
[deleter removeAllObservers];
22112215
}
22122216

22132217
- (void) testParentDeleteShadowsChildListenersWithNonDefaultQuery {

Example/Database/Tests/Integration/FRealtime.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ - (void) testOnDisconnectDeepMergeTriggersOnlyOneValueEventForReaderWithQuery {
481481
WAIT_FOR(count == 2);
482482

483483
// cleanup
484+
[reader removeAllObservers];
484485
[FRepoManager disposeRepos:writerCfg];
485486
}
486487

Example/Database/Tests/Unit/FSyncPointTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ - (BOOL) matches:(id<FEventRegistration>)other {
8686
}
8787

8888
- (void) fireEvent:(id<FEvent>)event queue:(dispatch_queue_t)queue {
89-
[NSException raise:@"NotImplementedError" format:@"Method not implemneted."];
89+
[NSException raise:@"NotImplementedError" format:@"Method not implemented."];
9090
}
9191
- (FCancelEvent *) createCancelEventFromError:(NSError *)error path:(FPath *)path {
92-
[NSException raise:@"NotImplementedError" format:@"Method not implemneted."];
92+
[NSException raise:@"NotImplementedError" format:@"Method not implemented."];
9393
return nil;
9494
}
9595

9696
- (FIRDatabaseHandle) handle {
97-
[NSException raise:@"NotImplementedError" format:@"Method not implemneted."];
97+
[NSException raise:@"NotImplementedError" format:@"Method not implemented."];
9898
return 0;
9999
}
100100
@end

Example/Firebase.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8111,6 +8111,7 @@
81118111
CLANG_ANALYZER_NONNULL = YES;
81128112
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
81138113
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
8114+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
81148115
DEBUG_INFORMATION_FORMAT = dwarf;
81158116
DEVELOPMENT_TEAM = "";
81168117
INFOPLIST_FILE = "$(SRCROOT)/Database/App/iOS/Database-Info.plist";
@@ -8129,6 +8130,7 @@
81298130
CLANG_ANALYZER_NONNULL = YES;
81308131
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
81318132
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
8133+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
81328134
COPY_PHASE_STRIP = NO;
81338135
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
81348136
DEVELOPMENT_TEAM = "";
@@ -8650,6 +8652,7 @@
86508652
baseConfigurationReference = 06F3D16439F061DE9973902D /* Pods-Storage_Example_iOS.debug.xcconfig */;
86518653
buildSettings = {
86528654
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
8655+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
86538656
DEVELOPMENT_TEAM = "";
86548657
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
86558658
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -8671,6 +8674,7 @@
86718674
baseConfigurationReference = D440FB786B320FCF836B508F /* Pods-Storage_Example_iOS.release.xcconfig */;
86728675
buildSettings = {
86738676
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
8677+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
86748678
DEVELOPMENT_TEAM = "";
86758679
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
86768680
GCC_PRECOMPILE_PREFIX_HEADER = YES;

Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* A sample configuration may look like:
3434
*
3535
* service firebase.storage {
36-
* match /b/{YOUR_PROJECT_ID}.appspot.com/o {
36+
* match /b/{bucket}/o {
3737
* ...
3838
* match /ios {
3939
* match /public/{allPaths=**} {

Firebase/Database/third_party/SocketRocket/FSRWebSocket.m

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,10 @@ - (void)_readHTTPHeader;
515515
}
516516

517517
[self _readUntilHeaderCompleteWithCallback:^(FSRWebSocket *self, NSData *data) {
518-
CFHTTPMessageAppendBytes(_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length);
518+
CFHTTPMessageAppendBytes(self->_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length);
519519

520-
if (CFHTTPMessageIsHeaderComplete(_receivedHTTPHeaders)) {
521-
SRFastLog(@"Finished reading headers %@", CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(_receivedHTTPHeaders)));
520+
if (CFHTTPMessageIsHeaderComplete(self->_receivedHTTPHeaders)) {
521+
SRFastLog(@"Finished reading headers %@", CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(self->_receivedHTTPHeaders)));
522522
[self _HTTPHeadersDidFinish];
523523
} else {
524524
[self _readHTTPHeader];
@@ -696,7 +696,7 @@ - (void)_closeWithProtocolError:(NSString *)message;
696696
// Need to shunt this on the _callbackQueue first to see if they received any messages
697697
[self _performDelegateBlock:^{
698698
[self closeWithCode:SRStatusCodeProtocolError reason:message];
699-
dispatch_async(_workQueue, ^{
699+
dispatch_async(self->_workQueue, ^{
700700
[self _disconnect];
701701
});
702702
}];
@@ -706,7 +706,7 @@ - (void)_failWithError:(NSError *)error;
706706
{
707707
dispatch_async(_workQueue, ^{
708708
if (self.readyState != SR_CLOSED) {
709-
_failed = YES;
709+
self->_failed = YES;
710710
[self _performDelegateBlock:^{
711711
if ([self.delegate respondsToSelector:@selector(webSocket:didFailWithError:)]) {
712712
[self.delegate webSocket:self didFailWithError:error];
@@ -756,7 +756,7 @@ - (void)handlePing:(NSData *)pingData;
756756
{
757757
// Need to pingpong this off _callbackQueue first to make sure messages happen in order
758758
[self _performDelegateBlock:^{
759-
dispatch_async(_workQueue, ^{
759+
dispatch_async(self->_workQueue, ^{
760760
[self _sendFrameWithOpcode:SROpCodePong data:pingData];
761761
});
762762
}];
@@ -1031,7 +1031,7 @@ - (void)_readFrameContinue;
10311031
[self _closeWithProtocolError:@"Client must receive unmasked data"];
10321032
}
10331033

1034-
size_t extra_bytes_needed = header.masked ? sizeof(_currentReadMaskKey) : 0;
1034+
size_t extra_bytes_needed = header.masked ? sizeof(self->_currentReadMaskKey) : 0;
10351035

10361036
if (header.payload_length == 126) {
10371037
extra_bytes_needed += sizeof(uint16_t);
@@ -1062,7 +1062,7 @@ - (void)_readFrameContinue;
10621062

10631063

10641064
if (header.masked) {
1065-
assert(mapped_size >= sizeof(_currentReadMaskOffset) + offset);
1065+
assert(mapped_size >= sizeof(self->_currentReadMaskOffset) + offset);
10661066
memcpy(self->_currentReadMaskKey, ((uint8_t *)mapped_buffer) + offset, sizeof(self->_currentReadMaskKey));
10671067
}
10681068

@@ -1075,12 +1075,12 @@ - (void)_readFrameContinue;
10751075
- (void)_readFrameNew;
10761076
{
10771077
dispatch_async(_workQueue, ^{
1078-
[_currentFrameData setLength:0];
1078+
[self->_currentFrameData setLength:0];
10791079

1080-
_currentFrameOpcode = 0;
1081-
_currentFrameCount = 0;
1082-
_readOpCount = 0;
1083-
_currentStringScanPosition = 0;
1080+
self->_currentFrameOpcode = 0;
1081+
self->_currentFrameCount = 0;
1082+
self->_readOpCount = 0;
1083+
self->_currentStringScanPosition = 0;
10841084

10851085
[self _readFrameContinue];
10861086
});
@@ -1123,7 +1123,7 @@ - (void)_pumpWriting;
11231123
if (!_failed) {
11241124
[self _performDelegateBlock:^{
11251125
if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) {
1126-
[self.delegate webSocket:self didCloseWithCode:_closeCode reason:_closeReason wasClean:YES];
1126+
[self.delegate webSocket:self didCloseWithCode:self->_closeCode reason:self->_closeReason wasClean:YES];
11271127
}
11281128
}];
11291129
}
@@ -1184,7 +1184,7 @@ - (void)_cleanupSelfReference:(NSTimer *)timer
11841184

11851185
// Cleanup selfRetain in the same GCD queue as usual
11861186
dispatch_async(_workQueue, ^{
1187-
_selfRetain = nil;
1187+
self->_selfRetain = nil;
11881188
});
11891189
}
11901190

@@ -1525,8 +1525,8 @@ - (void)safeHandleEvent:(NSStreamEvent)eventCode stream:(NSStream *)aStream
15251525
[self _scheduleCleanup];
15261526
}
15271527

1528-
if (!_sentClose && !_failed) {
1529-
_sentClose = YES;
1528+
if (!self->_sentClose && !self->_failed) {
1529+
self->_sentClose = YES;
15301530
// If we get closed in this state it's probably not clean because we should be sending this when we send messages
15311531
[self _performDelegateBlock:^{
15321532
if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) {

Firebase/Storage/FIRStorageDeleteTask.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ - (void)enqueue {
6060
if (callback) {
6161
callback(self.error);
6262
}
63-
_fetcherCompletion = nil;
63+
self->_fetcherCompletion = nil;
6464
};
6565
#pragma clang diangostic pop
6666

Firebase/Storage/FIRStorageDownloadTask.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,20 @@ - (void)enqueueWithData:(nullable NSData *)resumeData {
116116
self.error = [FIRStorageErrors errorWithServerError:error reference:self.reference];
117117
[self fireHandlersForStatus:FIRStorageTaskStatusFailure snapshot:self.snapshot];
118118
[self removeAllObservers];
119-
_fetcherCompletion = nil;
119+
self->_fetcherCompletion = nil;
120120
return;
121121
}
122122

123123
// Download completed successfully, fire completion callbacks
124124
self.state = FIRStorageTaskStateSuccess;
125125

126126
if (data) {
127-
_downloadData = data;
127+
self->_downloadData = data;
128128
}
129129

130130
[self fireHandlersForStatus:FIRStorageTaskStatusSuccess snapshot:self.snapshot];
131131
[self removeAllObservers];
132-
_fetcherCompletion = nil;
132+
self->_fetcherCompletion = nil;
133133
};
134134
#pragma clang diagnostic pop
135135

Firebase/Storage/FIRStorageGetMetadataTask.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ - (void)enqueue {
6565
if (callback) {
6666
callback(nil, self.error);
6767
}
68-
_fetcherCompletion = nil;
68+
self->_fetcherCompletion = nil;
6969
return;
7070
}
7171

@@ -90,7 +90,7 @@ - (void)enqueue {
9090
callback(nil, self.error);
9191
}
9292
}
93-
_fetcherCompletion = nil;
93+
self->_fetcherCompletion = nil;
9494
};
9595
#pragma clang diagnostic pop
9696

Firebase/Storage/FIRStorageMetadata.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary {
6060
NSURLComponents *components = [[NSURLComponents alloc] init];
6161
components.scheme = kFIRStorageScheme;
6262
components.host = kFIRStorageHost;
63-
NSString *path = [FIRStorageUtils GCSEscapedString:_path];
64-
NSString *fullPath = [NSString stringWithFormat:kFIRStorageFullPathFormat, _bucket, path];
63+
NSString *path = [FIRStorageUtils GCSEscapedString:self->_path];
64+
NSString *fullPath =
65+
[NSString stringWithFormat:kFIRStorageFullPathFormat, self->_bucket, path];
6566
components.percentEncodedPath = fullPath;
6667
components.query = [NSString stringWithFormat:@"alt=media&token=%@", token];
6768

0 commit comments

Comments
 (0)