Skip to content

Commit

Permalink
port TargetIdGenerator to iOS (firebase#709)
Browse files Browse the repository at this point in the history
* port TargetIdGenerator to iOS

* fix style

* move pointer property to instance variable

* TriggerTravis
  • Loading branch information
zxu123 committed Jan 25, 2018
1 parent 5306474 commit 7226b4a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 272 deletions.
4 changes: 0 additions & 4 deletions Firestore/Example/Firestore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
DE51B1CE1F0D48CD0013853F /* FSTEventManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AA1F0D48AC0013853F /* FSTEventManagerTests.m */; };
DE51B1CF1F0D48CD0013853F /* FSTQueryListenerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */; };
DE51B1D01F0D48CD0013853F /* FSTQueryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */; };
DE51B1D11F0D48CD0013853F /* FSTTargetIDGeneratorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */; };
DE51B1D21F0D48CD0013853F /* FSTTimestampTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */; };
DE51B1D31F0D48CD0013853F /* FSTViewSnapshotTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */; };
DE51B1D41F0D48CD0013853F /* FSTViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B11F0D48AC0013853F /* FSTViewTests.m */; };
Expand Down Expand Up @@ -331,7 +330,6 @@
DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTQueryListenerTests.m; sourceTree = "<group>"; };
DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTQueryTests.m; sourceTree = "<group>"; };
DE51B1AD1F0D48AC0013853F /* FSTSyncEngine+Testing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FSTSyncEngine+Testing.h"; sourceTree = "<group>"; };
DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTTargetIDGeneratorTests.m; sourceTree = "<group>"; };
DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTTimestampTests.m; sourceTree = "<group>"; };
DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTViewSnapshotTest.m; sourceTree = "<group>"; };
DE51B1B11F0D48AC0013853F /* FSTViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTViewTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -718,7 +716,6 @@
DE51B1AA1F0D48AC0013853F /* FSTEventManagerTests.m */,
DE51B1AB1F0D48AC0013853F /* FSTQueryListenerTests.m */,
DE51B1AC1F0D48AC0013853F /* FSTQueryTests.m */,
DE51B1AE1F0D48AC0013853F /* FSTTargetIDGeneratorTests.m */,
DE51B1AF1F0D48AC0013853F /* FSTTimestampTests.m */,
DE51B1B01F0D48AC0013853F /* FSTViewSnapshotTest.m */,
DE51B1B11F0D48AC0013853F /* FSTViewTests.m */,
Expand Down Expand Up @@ -1253,7 +1250,6 @@
DE51B1F41F0D491B0013853F /* FSTRemoteEventTests.m in Sources */,
548DB927200D590300E00ABC /* assert_test.cc in Sources */,
54E928241F33953300C1953E /* FSTEventAccumulator.m in Sources */,
DE51B1D11F0D48CD0013853F /* FSTTargetIDGeneratorTests.m in Sources */,
5436F32420008FAD006E51E3 /* string_printf_test.cc in Sources */,
DE51B1EF1F0D49140013853F /* FSTDocumentTests.m in Sources */,
DE51B1DC1F0D490D0013853F /* FSTLocalSerializerTests.m in Sources */,
Expand Down
94 changes: 0 additions & 94 deletions Firestore/Example/Tests/Core/FSTTargetIDGeneratorTests.m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#import "Firestore/Source/Auth/FSTUser.h"
#import "Firestore/Source/Core/FSTQuery.h"
#import "Firestore/Source/Core/FSTSnapshotVersion.h"
#import "Firestore/Source/Core/FSTTargetIDGenerator.h"
#import "Firestore/Source/Core/FSTTransaction.h"
#import "Firestore/Source/Core/FSTView.h"
#import "Firestore/Source/Core/FSTViewSnapshot.h"
Expand All @@ -41,6 +40,8 @@
#import "Firestore/Source/Util/FSTDispatchQueue.h"
#import "Firestore/Source/Util/FSTLogger.h"

#include "Firestore/core/src/firebase/firestore/core/target_id_generator.h"

NS_ASSUME_NONNULL_BEGIN

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

/** Used for creating the FSTTargetIDs for the listens used to resolve limbo documents. */
@property(nonatomic, strong, readonly) FSTTargetIDGenerator *targetIdGenerator;

@property(nonatomic, strong) FSTUser *currentUser;

@end

@implementation FSTSyncEngine
@implementation FSTSyncEngine {
/** Used for creating the FSTTargetIDs for the listens used to resolve limbo documents. */
firebase::firestore::core::TargetIdGenerator _targetIdGenerator;
}

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

_mutationCompletionBlocks = [NSMutableDictionary dictionary];
_targetIdGenerator = [FSTTargetIDGenerator generatorForSyncEngineStartingAfterID:0];
_targetIdGenerator =
firebase::firestore::core::TargetIdGenerator::SyncEngineTargetIdGenerator(0);
_currentUser = initialUser;
}
return self;
Expand Down Expand Up @@ -490,7 +492,7 @@ - (void)trackLimboChange:(FSTLimboDocumentChange *)limboChange {

if (!self.limboTargetsByKey[key]) {
FSTLog(@"New document in limbo: %@", key);
FSTTargetID limboTargetID = [self.targetIdGenerator nextID];
FSTTargetID limboTargetID = _targetIdGenerator.NextId();
FSTQuery *query = [FSTQuery queryWithPath:key.path];
FSTQueryData *queryData = [[FSTQueryData alloc] initWithQuery:query
targetID:limboTargetID
Expand Down
55 changes: 0 additions & 55 deletions Firestore/Source/Core/FSTTargetIDGenerator.h

This file was deleted.

105 changes: 0 additions & 105 deletions Firestore/Source/Core/FSTTargetIDGenerator.m

This file was deleted.

Loading

0 comments on commit 7226b4a

Please sign in to comment.