Skip to content

port TargetIdGenerator to iOS #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 25, 2018
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
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