mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-11 22:55:59 +05:45
* lazy replacing FST(Firebase)CredentialsProvider by (Firebase)CredentialsProvider * lazy replacing FSTUser by User * adding error-code parameter to TokenListener * actually use const user& instead of pointer; also add an error util * add HashUser and pass into the unordered_map * use User in test * use c++ CredentialsProvider and subclass in test * fix unit test * use explicit capture in lambda instead of capture all by reference * cache currentUser explicitly when reset sync engineer test driver * objc object should be captured by value in lambda * replacing Auth/FSTUser by C++ auth implementation * address changes * replacing FSTGetTokenResult by C++ Token implementation * address changes * fix unintentional change in merging * patch the change in objc Auth up-stream * somehow, the lambda-version of set-user-change-listener does not work... fallback to block * address changes * fix another const& v.s. dispatch bug * fix more const& v.s. dispatch bug zxu123 committed * fix a bad sync line * address changes * address change * address change * fix upstream change from merge * fix upstream changes * Suggested fixes for cpp/port_auth (#846) * Get rid of MockDatastore factory This avoids the need to statically allocate (and leak) a credentials provider * Use absl::make_unique std::make_unique technically does not exist until C++14. * #include <utility> for std::move * Use std::future for the initial user * fix style
97 lines
3.9 KiB
Objective-C
97 lines
3.9 KiB
Objective-C
/*
|
|
* Copyright 2017 Google
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#import "Firestore/Source/Core/FSTTypes.h"
|
|
#import "Firestore/Source/Core/FSTViewSnapshot.h"
|
|
#import "Firestore/Source/Remote/FSTRemoteStore.h"
|
|
|
|
#include "Firestore/core/src/firebase/firestore/auth/credentials_provider.h"
|
|
#include "Firestore/core/src/firebase/firestore/core/database_info.h"
|
|
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
|
|
|
|
@class FSTDispatchQueue;
|
|
@class FSTDocument;
|
|
@class FSTListenOptions;
|
|
@class FSTMutation;
|
|
@class FSTQuery;
|
|
@class FSTQueryListener;
|
|
@class FSTTransaction;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/**
|
|
* FirestoreClient is a top-level class that constructs and owns all of the pieces of the client
|
|
* SDK architecture. It is responsible for creating the worker queue that is shared by all of the
|
|
* other components in the system.
|
|
*/
|
|
@interface FSTFirestoreClient : NSObject <FSTOnlineStateDelegate>
|
|
|
|
/**
|
|
* Creates and returns a FSTFirestoreClient with the given parameters.
|
|
*
|
|
* All callbacks and events will be triggered on the provided userDispatchQueue.
|
|
*/
|
|
+ (instancetype)clientWithDatabaseInfo:(const firebase::firestore::core::DatabaseInfo &)databaseInfo
|
|
usePersistence:(BOOL)usePersistence
|
|
credentialsProvider:(firebase::firestore::auth::CredentialsProvider *)
|
|
credentialsProvider // no passing ownership
|
|
userDispatchQueue:(FSTDispatchQueue *)userDispatchQueue
|
|
workerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue;
|
|
|
|
- (instancetype)init __attribute__((unavailable("Use static constructor method.")));
|
|
|
|
/** Shuts down this client, cancels all writes / listeners, and releases all resources. */
|
|
- (void)shutdownWithCompletion:(nullable FSTVoidErrorBlock)completion;
|
|
|
|
/** Disables the network connection. Pending operations will not complete. */
|
|
- (void)disableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion;
|
|
|
|
/** Enables the network connection and requeues all pending operations. */
|
|
- (void)enableNetworkWithCompletion:(nullable FSTVoidErrorBlock)completion;
|
|
|
|
/** Starts listening to a query. */
|
|
- (FSTQueryListener *)listenToQuery:(FSTQuery *)query
|
|
options:(FSTListenOptions *)options
|
|
viewSnapshotHandler:(FSTViewSnapshotHandler)viewSnapshotHandler;
|
|
|
|
/** Stops listening to a query previously listened to. */
|
|
- (void)removeListener:(FSTQueryListener *)listener;
|
|
|
|
/** Write mutations. completion will be notified when it's written to the backend. */
|
|
- (void)writeMutations:(NSArray<FSTMutation *> *)mutations
|
|
completion:(nullable FSTVoidErrorBlock)completion;
|
|
|
|
/** Tries to execute the transaction in updateBlock up to retries times. */
|
|
- (void)transactionWithRetries:(int)retries
|
|
updateBlock:(FSTTransactionBlock)updateBlock
|
|
completion:(FSTVoidIDErrorBlock)completion;
|
|
|
|
/** The database ID of the databaseInfo this client was initialized with. */
|
|
// Ownes a DatabaseInfo instance, which contains the id here.
|
|
@property(nonatomic, assign, readonly) const firebase::firestore::model::DatabaseId *databaseID;
|
|
|
|
/**
|
|
* Dispatch queue for user callbacks / events. This will often be the "Main Dispatch Queue" of the
|
|
* app but the developer can configure it to a different queue if they so choose.
|
|
*/
|
|
@property(nonatomic, strong, readonly) FSTDispatchQueue *userDispatchQueue;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|