@@ -40,13 +40,13 @@ namespace firebase {
40
40
namespace remote_config {
41
41
namespace internal {
42
42
43
- const char * const RemoteConfigDesktop ::kDefaultNamespace = " configns:firebase" ;
44
- const char * const RemoteConfigDesktop ::kDefaultValueForString = " " ;
45
- const int64_t RemoteConfigDesktop ::kDefaultValueForLong = 0L ;
46
- const double RemoteConfigDesktop ::kDefaultValueForDouble = 0.0 ;
47
- const bool RemoteConfigDesktop ::kDefaultValueForBool = false ;
43
+ const char * const RemoteConfigInternal ::kDefaultNamespace = " configns:firebase" ;
44
+ const char * const RemoteConfigInternal ::kDefaultValueForString = " " ;
45
+ const int64_t RemoteConfigInternal ::kDefaultValueForLong = 0L ;
46
+ const double RemoteConfigInternal ::kDefaultValueForDouble = 0.0 ;
47
+ const bool RemoteConfigInternal ::kDefaultValueForBool = false ;
48
48
49
- RemoteConfigDesktop::RemoteConfigDesktop (
49
+ RemoteConfigInternal::RemoteConfigInternal (
50
50
const firebase::App& app, const RemoteConfigFileManager& file_manager)
51
51
: app_(app),
52
52
file_manager_ (file_manager),
@@ -56,7 +56,7 @@ RemoteConfigDesktop::RemoteConfigDesktop(
56
56
AsyncFetch ();
57
57
}
58
58
59
- RemoteConfigDesktop ::~RemoteConfigDesktop () {
59
+ RemoteConfigInternal ::~RemoteConfigInternal () {
60
60
fetch_channel_.Close ();
61
61
if (fetch_thread_.joinable ()) {
62
62
fetch_thread_.join ();
@@ -68,7 +68,7 @@ RemoteConfigDesktop::~RemoteConfigDesktop() {
68
68
}
69
69
}
70
70
71
- void RemoteConfigDesktop ::AsyncSaveToFile () {
71
+ void RemoteConfigInternal ::AsyncSaveToFile () {
72
72
save_thread_ = std::thread ([this ]() {
73
73
while (save_channel_.Get ()) {
74
74
LayeredConfigs copy;
@@ -81,8 +81,8 @@ void RemoteConfigDesktop::AsyncSaveToFile() {
81
81
});
82
82
}
83
83
84
- std::string RemoteConfigDesktop ::VariantToString (const Variant& variant,
85
- bool * failure) {
84
+ std::string RemoteConfigInternal ::VariantToString (const Variant& variant,
85
+ bool * failure) {
86
86
if (variant.is_blob ()) {
87
87
const uint8_t * blob_data = variant.blob_data ();
88
88
size_t blob_size = variant.blob_size ();
@@ -103,8 +103,8 @@ std::string RemoteConfigDesktop::VariantToString(const Variant& variant,
103
103
}
104
104
105
105
#ifndef SWIG
106
- void RemoteConfigDesktop ::SetDefaults (const ConfigKeyValueVariant* defaults,
107
- size_t number_of_defaults) {
106
+ void RemoteConfigInternal ::SetDefaults (const ConfigKeyValueVariant* defaults,
107
+ size_t number_of_defaults) {
108
108
if (defaults == nullptr ) {
109
109
return ;
110
110
}
@@ -121,8 +121,8 @@ void RemoteConfigDesktop::SetDefaults(const ConfigKeyValueVariant* defaults,
121
121
}
122
122
#endif // SWIG
123
123
124
- void RemoteConfigDesktop ::SetDefaults (const ConfigKeyValue* defaults,
125
- size_t number_of_defaults) {
124
+ void RemoteConfigInternal ::SetDefaults (const ConfigKeyValue* defaults,
125
+ size_t number_of_defaults) {
126
126
if (defaults == nullptr ) {
127
127
return ;
128
128
}
@@ -137,7 +137,7 @@ void RemoteConfigDesktop::SetDefaults(const ConfigKeyValue* defaults,
137
137
SetDefaults (defaults_map);
138
138
}
139
139
140
- void RemoteConfigDesktop ::SetDefaults (
140
+ void RemoteConfigInternal ::SetDefaults (
141
141
const std::map<std::string, std::string>& defaults_map) {
142
142
{
143
143
std::unique_lock<std::mutex> lock (mutex_);
@@ -146,13 +146,13 @@ void RemoteConfigDesktop::SetDefaults(
146
146
save_channel_.Put ();
147
147
}
148
148
149
- std::string RemoteConfigDesktop ::GetConfigSetting (ConfigSetting setting) {
149
+ std::string RemoteConfigInternal ::GetConfigSetting (ConfigSetting setting) {
150
150
std::unique_lock<std::mutex> lock (mutex_);
151
151
return configs_.metadata .GetSetting (setting);
152
152
}
153
153
154
- void RemoteConfigDesktop ::SetConfigSetting (ConfigSetting setting,
155
- const char * value) {
154
+ void RemoteConfigInternal ::SetConfigSetting (ConfigSetting setting,
155
+ const char * value) {
156
156
if (value == nullptr ) {
157
157
return ;
158
158
}
@@ -163,19 +163,18 @@ void RemoteConfigDesktop::SetConfigSetting(ConfigSetting setting,
163
163
save_channel_.Put ();
164
164
}
165
165
166
- bool RemoteConfigDesktop ::CheckValueInActiveAndDefault (const char * key,
167
- ValueInfo* info,
168
- std::string* value) {
166
+ bool RemoteConfigInternal ::CheckValueInActiveAndDefault (const char * key,
167
+ ValueInfo* info,
168
+ std::string* value) {
169
169
return CheckValueInConfig (configs_.active , kValueSourceRemoteValue , key, info,
170
170
value) ||
171
171
CheckValueInConfig (configs_.defaults , kValueSourceDefaultValue , key,
172
172
info, value);
173
173
}
174
174
175
- bool RemoteConfigDesktop::CheckValueInConfig (const NamespacedConfigData& config,
176
- ValueSource source,
177
- const char * key, ValueInfo* info,
178
- std::string* value) {
175
+ bool RemoteConfigInternal::CheckValueInConfig (
176
+ const NamespacedConfigData& config, ValueSource source, const char * key,
177
+ ValueInfo* info, std::string* value) {
179
178
if (!key) return false ;
180
179
181
180
{
@@ -191,19 +190,19 @@ bool RemoteConfigDesktop::CheckValueInConfig(const NamespacedConfigData& config,
191
190
return true ;
192
191
}
193
192
194
- bool RemoteConfigDesktop ::IsBoolTrue (const std::string& str) {
193
+ bool RemoteConfigInternal ::IsBoolTrue (const std::string& str) {
195
194
// regex: ^(1|true|t|yes|y|on)$
196
195
return str == " 1" || str == " true" || str == " t" || str == " yes" ||
197
196
str == " y" || str == " on" ;
198
197
}
199
198
200
- bool RemoteConfigDesktop ::IsBoolFalse (const std::string& str) {
199
+ bool RemoteConfigInternal ::IsBoolFalse (const std::string& str) {
201
200
// regex: ^(0|false|f|no|n|off)$
202
201
return str == " 0" || str == " false" || str == " f" || str == " no" ||
203
202
str == " n" || str == " off" ;
204
203
}
205
204
206
- bool RemoteConfigDesktop ::IsLong (const std::string& str) {
205
+ bool RemoteConfigInternal ::IsLong (const std::string& str) {
207
206
// regex: ^[-+]?[0-9]+$
208
207
// Don't allow empty string.
209
208
if (str.length () == 0 ) return false ;
@@ -214,7 +213,7 @@ bool RemoteConfigDesktop::IsLong(const std::string& str) {
214
213
return (*endptr == ' \0 ' ); // Ensure we consumed the whole string.
215
214
}
216
215
217
- bool RemoteConfigDesktop ::IsDouble (const std::string& str) {
216
+ bool RemoteConfigInternal ::IsDouble (const std::string& str) {
218
217
// regex: ^[-+]?[0-9]*.?[0-9]+([eE][-+]?[0-9]+)?
219
218
// Don't allow empty string.
220
219
if (str.length () == 0 ) return false ;
@@ -225,8 +224,7 @@ bool RemoteConfigDesktop::IsDouble(const std::string& str) {
225
224
return (*endptr == ' \0 ' ); // Ensure we consumed the whole string.
226
225
}
227
226
228
- bool RemoteConfigDesktop::GetBoolean (const char * key,
229
- ValueInfo* info) {
227
+ bool RemoteConfigInternal::GetBoolean (const char * key, ValueInfo* info) {
230
228
std::string value;
231
229
if (!CheckValueInActiveAndDefault (key, info, &value)) {
232
230
if (info) {
@@ -248,8 +246,7 @@ bool RemoteConfigDesktop::GetBoolean(const char* key,
248
246
return kDefaultValueForBool ;
249
247
}
250
248
251
- std::string RemoteConfigDesktop::GetString (const char * key,
252
- ValueInfo* info) {
249
+ std::string RemoteConfigInternal::GetString (const char * key, ValueInfo* info) {
253
250
std::string value;
254
251
if (!CheckValueInActiveAndDefault (key, info, &value)) {
255
252
if (info) {
@@ -263,8 +260,7 @@ std::string RemoteConfigDesktop::GetString(const char* key,
263
260
return value;
264
261
}
265
262
266
- int64_t RemoteConfigDesktop::GetLong (const char * key,
267
- ValueInfo* info) {
263
+ int64_t RemoteConfigInternal::GetLong (const char * key, ValueInfo* info) {
268
264
std::string value;
269
265
if (!CheckValueInActiveAndDefault (key, info, &value)) {
270
266
if (info) {
@@ -286,8 +282,7 @@ int64_t RemoteConfigDesktop::GetLong(const char* key,
286
282
return convertation_failure ? kDefaultValueForLong : long_value;
287
283
}
288
284
289
- double RemoteConfigDesktop::GetDouble (const char * key,
290
- ValueInfo* info) {
285
+ double RemoteConfigInternal::GetDouble (const char * key, ValueInfo* info) {
291
286
std::string value;
292
287
if (!CheckValueInActiveAndDefault (key, info, &value)) {
293
288
if (info) {
@@ -309,8 +304,8 @@ double RemoteConfigDesktop::GetDouble(const char* key,
309
304
return convertation_failure ? kDefaultValueForDouble : double_value;
310
305
}
311
306
312
- std::vector<unsigned char > RemoteConfigDesktop ::GetData (const char * key,
313
- ValueInfo* info) {
307
+ std::vector<unsigned char > RemoteConfigInternal ::GetData (const char * key,
308
+ ValueInfo* info) {
314
309
std::string value;
315
310
if (!CheckValueInActiveAndDefault (key, info, &value)) {
316
311
if (info) {
@@ -329,11 +324,11 @@ std::vector<unsigned char> RemoteConfigDesktop::GetData(const char* key,
329
324
return data_value;
330
325
}
331
326
332
- std::vector<std::string> RemoteConfigDesktop ::GetKeys () {
327
+ std::vector<std::string> RemoteConfigInternal ::GetKeys () {
333
328
return GetKeysByPrefix (" " );
334
329
}
335
330
336
- std::vector<std::string> RemoteConfigDesktop ::GetKeysByPrefix (
331
+ std::vector<std::string> RemoteConfigInternal ::GetKeysByPrefix (
337
332
const char * prefix) {
338
333
if (prefix == nullptr ) return std::vector<std::string>();
339
334
std::set<std::string> unique_keys;
@@ -345,7 +340,7 @@ std::vector<std::string> RemoteConfigDesktop::GetKeysByPrefix(
345
340
return std::vector<std::string>(unique_keys.begin (), unique_keys.end ());
346
341
}
347
342
348
- bool RemoteConfigDesktop ::ActivateFetched () {
343
+ bool RemoteConfigInternal ::ActivateFetched () {
349
344
{
350
345
std::unique_lock<std::mutex> lock (mutex_);
351
346
// Fetched config not found or already activated.
@@ -357,12 +352,12 @@ bool RemoteConfigDesktop::ActivateFetched() {
357
352
return true ;
358
353
}
359
354
360
- const ConfigInfo& RemoteConfigDesktop ::GetInfo () const {
355
+ const ConfigInfo& RemoteConfigInternal ::GetInfo () const {
361
356
std::unique_lock<std::mutex> lock (mutex_);
362
357
return configs_.metadata .info ();
363
358
}
364
359
365
- void RemoteConfigDesktop ::AsyncFetch () {
360
+ void RemoteConfigInternal ::AsyncFetch () {
366
361
fetch_thread_ = std::thread ([this ]() {
367
362
SafeFutureHandle<void > handle;
368
363
while (fetch_channel_.Get ()) {
@@ -404,7 +399,7 @@ void RemoteConfigDesktop::AsyncFetch() {
404
399
});
405
400
}
406
401
407
- Future<void > RemoteConfigDesktop ::Fetch (uint64_t cache_expiration_in_seconds) {
402
+ Future<void > RemoteConfigInternal ::Fetch (uint64_t cache_expiration_in_seconds) {
408
403
std::unique_lock<std::mutex> lock (mutex_);
409
404
410
405
uint64_t milliseconds_since_epoch =
@@ -433,7 +428,7 @@ Future<void> RemoteConfigDesktop::Fetch(uint64_t cache_expiration_in_seconds) {
433
428
return FetchLastResult ();
434
429
}
435
430
436
- Future<void > RemoteConfigDesktop ::FetchLastResult () {
431
+ Future<void > RemoteConfigInternal ::FetchLastResult () {
437
432
ReferenceCountedFutureImpl* api = FutureData::Get ()->api ();
438
433
return static_cast <const Future<void >&>(
439
434
api->LastResult (kRemoteConfigFnFetch ));
0 commit comments