@@ -58,14 +58,16 @@ RemoteConfig* RemoteConfig::GetInstance(App* app) {
58
58
" it depends upon." ,
59
59
static_cast <int >(reinterpret_cast <intptr_t >(rc)),
60
60
static_cast <int >(reinterpret_cast <intptr_t >(rc->app ())));
61
- DeleteInternal (rc );
61
+ rc-> DeleteInternal ();
62
62
});
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;
63
68
}
64
69
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 ;
69
71
}
70
72
71
73
RemoteConfig* RemoteConfig::FindRemoteConfig (App* app) {
@@ -78,18 +80,20 @@ RemoteConfig* RemoteConfig::FindRemoteConfig(App* app) {
78
80
return nullptr ;
79
81
}
80
82
81
- void RemoteConfig::DeleteInternal (RemoteConfig* rc ) {
83
+ void RemoteConfig::DeleteInternal () {
82
84
MutexLock lock (g_rc_mutex);
85
+ if (!internal_) return ;
83
86
84
- CleanupNotifier* notifier = CleanupNotifier::FindByOwner (rc-> app ());
87
+ CleanupNotifier* notifier = CleanupNotifier::FindByOwner (app ());
85
88
assert (notifier);
86
- notifier->UnregisterObject (rc );
89
+ notifier->UnregisterObject (this );
87
90
88
- // Remove rc from the g_rcs map.
89
- g_rcs.erase (rc->app ());
91
+ internal_->Cleanup ();
92
+ delete internal_;
93
+ internal_ = nullptr ;
90
94
91
- delete rc;
92
- rc = nullptr ;
95
+ // Remove rc from the g_rcs map.
96
+ g_rcs. erase ( app ()) ;
93
97
}
94
98
95
99
RemoteConfig::RemoteConfig (App* app) {
@@ -98,11 +102,7 @@ RemoteConfig::RemoteConfig(App* app) {
98
102
internal_ = new internal::RemoteConfigInternal (*app);
99
103
}
100
104
101
- RemoteConfig::~RemoteConfig () {
102
- internal_->Cleanup ();
103
- delete internal_;
104
- internal_ = nullptr ;
105
- }
105
+ RemoteConfig::~RemoteConfig () { DeleteInternal (); }
106
106
107
107
bool RemoteConfig::InitInternal () { return internal_->Initialized (); }
108
108
@@ -199,9 +199,7 @@ std::string RemoteConfig::GetString(const char* key, ValueInfo* info) {
199
199
}
200
200
201
201
std::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 ));
205
203
}
206
204
207
205
std::vector<unsigned char > RemoteConfig::GetData (const char * key,
@@ -222,9 +220,7 @@ std::map<std::string, Variant> RemoteConfig::GetAll() {
222
220
}
223
221
224
222
// 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 (); }
228
224
#endif // FIREBASE_EARLY_ACCESS_PREVIEW
229
225
230
226
} // namespace remote_config
0 commit comments