Skip to content

Commit 7226b4a

Browse files
authored
port TargetIdGenerator to iOS (firebase#709)
* port TargetIdGenerator to iOS * fix style * move pointer property to instance variable * TriggerTravis
1 parent 5306474 commit 7226b4a

File tree

7 files changed

+24
-272
lines changed

7 files changed

+24
-272
lines changed

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
DE51B1CE1F0D48CD0013853F /* FSTEventManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AA1F0D48AC0013853F /* FSTEventManagerTests.m */; };
112112
DE51B1CF1F0D48CD0013853F /* FSTQueryListenerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */; };
113113
DE51B1D01F0D48CD0013853F /* FSTQueryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */; };
114-
DE51B1D11F0D48CD0013853F /* FSTTargetIDGeneratorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */; };
115114
DE51B1D21F0D48CD0013853F /* FSTTimestampTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */; };
116115
DE51B1D31F0D48CD0013853F /* FSTViewSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */; };
117116
DE51B1D41F0D48CD0013853F /* FSTViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B11F0D48AC0013853F /* FSTViewTests.m */; };
@@ -331,7 +330,6 @@
331330
DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTQueryListenerTests.m; sourceTree = "<group>"; };
332331
DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTQueryTests.m; sourceTree = "<group>"; };
333332
DE51B1AD1F0D48AC0013853F /* FSTSyncEngine+Testing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FSTSyncEngine+Testing.h"; sourceTree = "<group>"; };
334-
DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTTargetIDGeneratorTests.m; sourceTree = "<group>"; };
335333
DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTTimestampTests.m; sourceTree = "<group>"; };
336334
DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTViewSnapshotTest.m; sourceTree = "<group>"; };
337335
DE51B1B11F0D48AC0013853F /* FSTViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTViewTests.m; sourceTree = "<group>"; };
@@ -718,7 +716,6 @@
718716
DE51B1AA1F0D48AC0013853F /* FSTEventManagerTests.m */,
719717
DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */,
720718
DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */,
721-
DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */,
722719
DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */,
723720
DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */,
724721
DE51B1B11F0D48AC0013853F /* FSTViewTests.m */,
@@ -1253,7 +1250,6 @@
12531250
DE51B1F41F0D491B0013853F /* FSTRemoteEventTests.m in Sources */,
12541251
548DB927200D590300E00ABC /* assert_test.cc in Sources */,
12551252
54E928241F33953300C1953E /* FSTEventAccumulator.m in Sources */,
1256-
DE51B1D11F0D48CD0013853F /* FSTTargetIDGeneratorTests.m in Sources */,
12571253
5436F32420008FAD006E51E3 /* string_printf_test.cc in Sources */,
12581254
DE51B1EF1F0D49140013853F /* FSTDocumentTests.m in Sources */,
12591255
DE51B1DC1F0D490D0013853F /* FSTLocalSerializerTests.m in Sources */,

Firestore/Example/Tests/Core/FSTTargetIDGeneratorTests.m

Lines changed: 0 additions & 94 deletions
This file was deleted.

Firestore/Source/Core/FSTSyncEngine.m renamed to Firestore/Source/Core/FSTSyncEngine.mm

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#import "Firestore/Source/Auth/FSTUser.h"
2323
#import "Firestore/Source/Core/FSTQuery.h"
2424
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
25-
#import "Firestore/Source/Core/FSTTargetIDGenerator.h"
2625
#import "Firestore/Source/Core/FSTTransaction.h"
2726
#import "Firestore/Source/Core/FSTView.h"
2827
#import "Firestore/Source/Core/FSTViewSnapshot.h"
@@ -41,6 +40,8 @@
4140
#import "Firestore/Source/Util/FSTDispatchQueue.h"
4241
#import "Firestore/Source/Util/FSTLogger.h"
4342

43+
#include "Firestore/core/src/firebase/firestore/core/target_id_generator.h"
44+
4445
NS_ASSUME_NONNULL_BEGIN
4546

4647
// Limbo documents don't use persistence, and are eagerly GC'd. So, listens for them don't need
@@ -141,14 +142,14 @@ @interface FSTSyncEngine ()
141142
NSMutableDictionary<FSTUser *, NSMutableDictionary<NSNumber *, FSTVoidErrorBlock> *>
142143
*mutationCompletionBlocks;
143144

144-
/** Used for creating the FSTTargetIDs for the listens used to resolve limbo documents. */
145-
@property(nonatomic, strong, readonly) FSTTargetIDGenerator *targetIdGenerator;
146-
147145
@property(nonatomic, strong) FSTUser *currentUser;
148146

149147
@end
150148

151-
@implementation FSTSyncEngine
149+
@implementation FSTSyncEngine {
150+
/** Used for creating the FSTTargetIDs for the listens used to resolve limbo documents. */
151+
firebase::firestore::core::TargetIdGenerator _targetIdGenerator;
152+
}
152153

153154
- (instancetype)initWithLocalStore:(FSTLocalStore *)localStore
154155
remoteStore:(FSTRemoteStore *)remoteStore
@@ -167,7 +168,8 @@ - (instancetype)initWithLocalStore:(FSTLocalStore *)localStore
167168
[_limboCollector addGarbageSource:_limboDocumentRefs];
168169

169170
_mutationCompletionBlocks = [NSMutableDictionary dictionary];
170-
_targetIdGenerator = [FSTTargetIDGenerator generatorForSyncEngineStartingAfterID:0];
171+
_targetIdGenerator =
172+
firebase::firestore::core::TargetIdGenerator::SyncEngineTargetIdGenerator(0);
171173
_currentUser = initialUser;
172174
}
173175
return self;
@@ -490,7 +492,7 @@ - (void)trackLimboChange:(FSTLimboDocumentChange *)limboChange {
490492

491493
if (!self.limboTargetsByKey[key]) {
492494
FSTLog(@"New document in limbo: %@", key);
493-
FSTTargetID limboTargetID = [self.targetIdGenerator nextID];
495+
FSTTargetID limboTargetID = _targetIdGenerator.NextId();
494496
FSTQuery *query = [FSTQuery queryWithPath:key.path];
495497
FSTQueryData *queryData = [[FSTQueryData alloc] initWithQuery:query
496498
targetID:limboTargetID

Firestore/Source/Core/FSTTargetIDGenerator.h

Lines changed: 0 additions & 55 deletions
This file was deleted.

Firestore/Source/Core/FSTTargetIDGenerator.m

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)