Skip to content

Commit 158986f

Browse files
committed
try using this->databaseId() in android
1 parent b65cffd commit 158986f

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

firestore/src/android/firestore_android.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ FirestoreInternal::FirestoreInternal(App* app, const char* database_id) {
264264
FIREBASE_ASSERT(app != nullptr);
265265
if (!Initialize(app)) return;
266266
app_ = app;
267-
database_name_ = database_id;
268267

269268
Env env = GetEnv();
270269
Local<Object> platform_app(env.get(), app_->GetPlatformApp());

firestore/src/android/firestore_android.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <string>
2626
#include <unordered_set>
2727

28+
#include "Firestore/core/src/model/database_id.h"
2829
#include "app/src/cleanup_notifier.h"
2930
#include "app/src/future_manager.h"
3031
#include "app/src/include/firebase/app.h"
@@ -136,8 +137,6 @@ class FirestoreInternal {
136137
ListenerRegistrationInternal* registration);
137138
void ClearListeners();
138139

139-
const std::string& database_name() const { return database_name_; }
140-
141140
// Bundles
142141
Future<LoadBundleTaskProgress> LoadBundle(const std::string& bundle);
143142
Future<LoadBundleTaskProgress> LoadBundle(
@@ -167,6 +166,10 @@ class FirestoreInternal {
167166
firestore_public_ = firestore_public;
168167
}
169168

169+
const model::DatabaseId& database_id() const {
170+
return this->database_id();
171+
}
172+
170173
Firestore* firestore_public() { return firestore_public_; }
171174
const Firestore* firestore_public() const { return firestore_public_; }
172175

@@ -214,8 +217,6 @@ class FirestoreInternal {
214217
std::unique_ptr<PromiseFactory<AsyncFn>> promises_;
215218

216219
CleanupNotifier cleanup_;
217-
218-
std::string database_name_;
219220
};
220221

221222
// Holds a "weak reference" to a `FirestoreInternal` object.

firestore/src/common/firestore.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Firestore* Firestore::CreateFirestore(App* app,
179179

180180
MutexLock lock(*g_firestores_lock);
181181

182-
const char* database_id = internal->database_name().c_str();
182+
const char* database_id = internal->database_id().database_id().c_str();
183183
Firestore* from_cache =
184184
FindFirestoreInCache(app, database_id, init_result_out);
185185
SIMPLE_HARD_ASSERT(from_cache == nullptr,
@@ -200,7 +200,7 @@ Firestore* Firestore::AddFirestoreToCache(Firestore* firestore,
200200
}
201201

202202
FirestoreMap::key_type key =
203-
MakeKey(firestore->app(), firestore->internal_->database_name());
203+
MakeKey(firestore->app(), firestore->internal_->database_id().database_id());
204204
FirestoreCache()->emplace(key, firestore);
205205
return firestore;
206206
}
@@ -263,7 +263,7 @@ void Firestore::DeleteInternal() {
263263
// Force cleanup to happen first.
264264
internal_->cleanup().CleanupAll();
265265
// Store the database id before deleting the firestore instance.
266-
const std::string database_id = internal_->database_name();
266+
const std::string database_id = internal_->database_id().database_id();
267267
delete internal_;
268268
internal_ = nullptr;
269269
// If a Firestore is explicitly deleted, remove it from our cache.
@@ -381,7 +381,7 @@ Future<void> Firestore::EnableNetwork() {
381381

382382
Future<void> Firestore::Terminate() {
383383
if (!internal_) return FailedFuture<void>();
384-
FirestoreMap::key_type key = MakeKey(app(), internal_->database_name());
384+
FirestoreMap::key_type key = MakeKey(app(), internal_->database_id().database_id());
385385

386386
FirestoreCache()->erase(key);
387387
return internal_->Terminate();

firestore/src/main/firestore_main.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ FirestoreInternal::FirestoreInternal(
117117
std::move(auth_credentials),
118118
std::move(app_check_credentials))),
119119
transaction_executor_(absl::ShareUniquePtr(Executor::CreateConcurrent(
120-
"com.google.firebase.firestore.transaction", /*threads=*/5))),
121-
database_name_(database_id) {
120+
"com.google.firebase.firestore.transaction", /*threads=*/5))) {
122121
ApplyDefaultSettings();
123122

124123
#if FIREBASE_PLATFORM_ANDROID

firestore/src/main/firestore_main.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ class FirestoreInternal {
108108
return firestore_core_->database_id();
109109
}
110110

111-
const std::string& database_name() const { return database_name_; }
112-
113111
// Bundles
114112
Future<LoadBundleTaskProgress> LoadBundle(const std::string& bundle);
115113
Future<LoadBundleTaskProgress> LoadBundle(
@@ -187,7 +185,6 @@ class FirestoreInternal {
187185
std::unordered_set<ListenerRegistrationInternal*> listeners_;
188186

189187
std::shared_ptr<util::Executor> transaction_executor_;
190-
std::string database_name_;
191188
};
192189

193190
} // namespace firestore

0 commit comments

Comments
 (0)