@@ -58,14 +58,16 @@ RemoteConfig* RemoteConfig::GetInstance(App* app) {
5858 " it depends upon." ,
5959 static_cast <int >(reinterpret_cast <intptr_t >(rc)),
6060 static_cast <int >(reinterpret_cast <intptr_t >(rc->app ())));
61- DeleteInternal (rc );
61+ rc-> DeleteInternal ();
6262 });
63+
64+ // Stick it in the global map so we remember it, and can delete it on
65+ // shutdown.
66+ g_rcs[app] = rc;
67+ return rc;
6368 }
6469
65- // Stick it in the global map so we remember it, and can delete it on
66- // shutdown.
67- g_rcs[app] = rc;
68- return rc;
70+ return nullptr ;
6971}
7072
7173RemoteConfig* RemoteConfig::FindRemoteConfig (App* app) {
@@ -78,18 +80,20 @@ RemoteConfig* RemoteConfig::FindRemoteConfig(App* app) {
7880 return nullptr ;
7981}
8082
81- void RemoteConfig::DeleteInternal (RemoteConfig* rc ) {
83+ void RemoteConfig::DeleteInternal () {
8284 MutexLock lock (g_rc_mutex);
85+ if (!internal_) return ;
8386
84- CleanupNotifier* notifier = CleanupNotifier::FindByOwner (rc-> app ());
87+ CleanupNotifier* notifier = CleanupNotifier::FindByOwner (app ());
8588 assert (notifier);
86- notifier->UnregisterObject (rc );
89+ notifier->UnregisterObject (this );
8790
88- // Remove rc from the g_rcs map.
89- g_rcs.erase (rc->app ());
91+ internal_->Cleanup ();
92+ delete internal_;
93+ internal_ = nullptr ;
9094
91- delete rc;
92- rc = nullptr ;
95+ // Remove rc from the g_rcs map.
96+ g_rcs. erase ( app ()) ;
9397}
9498
9599RemoteConfig::RemoteConfig (App* app) {
@@ -98,11 +102,7 @@ RemoteConfig::RemoteConfig(App* app) {
98102 internal_ = new internal::RemoteConfigInternal (*app);
99103}
100104
101- RemoteConfig::~RemoteConfig () {
102- internal_->Cleanup ();
103- delete internal_;
104- internal_ = nullptr ;
105- }
105+ RemoteConfig::~RemoteConfig () { DeleteInternal (); }
106106
107107bool RemoteConfig::InitInternal () { return internal_->Initialized (); }
108108
@@ -199,9 +199,7 @@ std::string RemoteConfig::GetString(const char* key, ValueInfo* info) {
199199}
200200
201201std::vector<unsigned char > RemoteConfig::GetData (const char * key) {
202- std::vector<unsigned char > value;
203- // TODO(cynthiajiang) implement
204- return value;
202+ return GetData (key, static_cast <ValueInfo*>(nullptr ));
205203}
206204
207205std::vector<unsigned char > RemoteConfig::GetData (const char * key,
@@ -222,9 +220,7 @@ std::map<std::string, Variant> RemoteConfig::GetAll() {
222220}
223221
224222// TODO(b/147143718): Change to a more descriptive name.
225- const ConfigInfo& RemoteConfig::GetInfo () {
226- return internal_->GetInfo ();
227- }
223+ const ConfigInfo RemoteConfig::GetInfo () { return internal_->GetInfo (); }
228224#endif // FIREBASE_EARLY_ACCESS_PREVIEW
229225
230226} // namespace remote_config
0 commit comments