FIRFirestore+Internal.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FIRFirestore.h"
  17. #include <memory>
  18. #include <string>
  19. #include "Firestore/core/src/api/firestore.h"
  20. #include "Firestore/core/src/credentials/credentials_provider.h"
  21. #include "Firestore/core/src/util/async_queue.h"
  22. @class FIRApp;
  23. @class FSTUserDataReader;
  24. namespace firebase {
  25. namespace firestore {
  26. namespace remote {
  27. class FirebaseMetadataProvider;
  28. } // namespace remote
  29. } // namespace firestore
  30. } // namespace firebase
  31. namespace api = firebase::firestore::api;
  32. namespace credentials = firebase::firestore::credentials;
  33. namespace model = firebase::firestore::model;
  34. namespace remote = firebase::firestore::remote;
  35. NS_ASSUME_NONNULL_BEGIN
  36. /** Provides a registry management interface for FIRFirestore instances. */
  37. @protocol FSTFirestoreInstanceRegistry
  38. /** Removes the FIRFirestore instance with given database name from registry. */
  39. - (void)removeInstanceWithDatabase:(NSString *)database;
  40. @end
  41. @interface FIRFirestore (/* Init */)
  42. /**
  43. * Initializes a Firestore object with all the required parameters directly. This exists so that
  44. * tests can create FIRFirestore objects without needing FIRApp.
  45. */
  46. - (instancetype)initWithDatabaseID:(model::DatabaseId)databaseID
  47. persistenceKey:(std::string)persistenceKey
  48. authCredentialsProvider:
  49. (std::shared_ptr<credentials::AuthCredentialsProvider>)authCredentialsProvider
  50. appCheckCredentialsProvider:
  51. (std::shared_ptr<credentials::AppCheckCredentialsProvider>)appCheckCredentialsProvider
  52. workerQueue:
  53. (std::shared_ptr<firebase::firestore::util::AsyncQueue>)workerQueue
  54. firebaseMetadataProvider:
  55. (std::unique_ptr<remote::FirebaseMetadataProvider>)firebaseMetadataProvider
  56. firebaseApp:(FIRApp *)app
  57. instanceRegistry:(nullable id<FSTFirestoreInstanceRegistry>)registry;
  58. @end
  59. /** Internal FIRFirestore API we don't want exposed in our public header files. */
  60. @interface FIRFirestore (Internal)
  61. + (FIRFirestore *)recoverFromFirestore:(std::shared_ptr<api::Firestore>)firestore;
  62. - (void)terminateInternalWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
  63. - (const std::shared_ptr<firebase::firestore::util::AsyncQueue> &)workerQueue;
  64. @property(nonatomic, assign, readonly) std::shared_ptr<api::Firestore> wrapped;
  65. @property(nonatomic, assign, readonly) const model::DatabaseId &databaseID;
  66. @property(nonatomic, strong, readonly) FSTUserDataReader *dataReader;
  67. /**
  68. * Creates, caches, and returns named `Firestore` object for the specified `FirebaseApp`. Each
  69. * subsequent invocation returns the same `Firestore` object.
  70. *
  71. * @param app The `FirebaseApp` instance to use for authentication and as a source of the Google
  72. * Cloud Project ID for your Firestore Database. If you want the default instance, you should
  73. * explicitly set it to `FirebaseApp.app()`.
  74. * @param database The database name.
  75. *
  76. * @return The named `Firestore` instance.
  77. */
  78. + (instancetype)firestoreForApp:(FIRApp *)app
  79. database:(NSString *)database NS_SWIFT_NAME(firestore(app:database:));
  80. /**
  81. * Creates, caches, and returns named `Firestore` object for the default _app_. Each subsequent
  82. * invocation returns the same `Firestore` object.
  83. *
  84. * @param database The database name.
  85. *
  86. * @return The named `Firestore` instance.
  87. */
  88. + (instancetype)firestoreForDatabase:(NSString *)database NS_SWIFT_NAME(firestore(database:));
  89. @end
  90. NS_ASSUME_NONNULL_END