@@ -104,8 +104,7 @@ std::string RemoteConfigDesktop::VariantToString(const Variant& variant,
104
104
105
105
#ifndef SWIG
106
106
void RemoteConfigDesktop::SetDefaults (const ConfigKeyValueVariant* defaults,
107
- size_t number_of_defaults,
108
- const char * config_namespace) {
107
+ size_t number_of_defaults) {
109
108
if (defaults == nullptr ) {
110
109
return ;
111
110
}
@@ -118,13 +117,12 @@ void RemoteConfigDesktop::SetDefaults(const ConfigKeyValueVariant* defaults,
118
117
defaults_map[key] = value;
119
118
}
120
119
}
121
- SetDefaults (defaults_map, config_namespace );
120
+ SetDefaults (defaults_map);
122
121
}
123
122
#endif // SWIG
124
123
125
124
void RemoteConfigDesktop::SetDefaults (const ConfigKeyValue* defaults,
126
- size_t number_of_defaults,
127
- const char * config_namespace) {
125
+ size_t number_of_defaults) {
128
126
if (defaults == nullptr ) {
129
127
return ;
130
128
}
@@ -136,16 +134,14 @@ void RemoteConfigDesktop::SetDefaults(const ConfigKeyValue* defaults,
136
134
defaults_map[key] = value;
137
135
}
138
136
}
139
- SetDefaults (defaults_map, config_namespace );
137
+ SetDefaults (defaults_map);
140
138
}
141
139
142
140
void RemoteConfigDesktop::SetDefaults (
143
- const std::map<std::string, std::string>& defaults_map,
144
- const char * config_namespace) {
141
+ const std::map<std::string, std::string>& defaults_map) {
145
142
{
146
143
std::unique_lock<std::mutex> lock (mutex_);
147
- configs_.defaults .SetNamespace (
148
- defaults_map, config_namespace ? config_namespace : kDefaultNamespace );
144
+ configs_.defaults .SetNamespace (defaults_map, kDefaultNamespace );
149
145
}
150
146
save_channel_.Put ();
151
147
}
@@ -167,29 +163,28 @@ void RemoteConfigDesktop::SetConfigSetting(ConfigSetting setting,
167
163
save_channel_.Put ();
168
164
}
169
165
170
- bool RemoteConfigDesktop::CheckValueInActiveAndDefault (
171
- const char * key, const char * config_namespace, ValueInfo* info,
172
- std::string* value) {
173
- return CheckValueInConfig (configs_.active , kValueSourceRemoteValue , key,
174
- config_namespace, info, value) ||
166
+ bool RemoteConfigDesktop::CheckValueInActiveAndDefault (const char * key,
167
+ ValueInfo* info,
168
+ std::string* value) {
169
+ return CheckValueInConfig (configs_.active , kValueSourceRemoteValue , key, info,
170
+ value) ||
175
171
CheckValueInConfig (configs_.defaults , kValueSourceDefaultValue , key,
176
- config_namespace, info, value);
172
+ info, value);
177
173
}
178
174
179
- bool RemoteConfigDesktop::CheckValueInConfig (
180
- const NamespacedConfigData& config, ValueSource source, const char * key,
181
- const char * config_namespace, ValueInfo* info, std::string* value) {
175
+ bool RemoteConfigDesktop::CheckValueInConfig (const NamespacedConfigData& config,
176
+ ValueSource source,
177
+ const char * key, ValueInfo* info,
178
+ std::string* value) {
182
179
if (!key) return false ;
183
180
184
181
{
185
182
// TODO(b/74461360): Replace the thread locks with firebase ones.
186
183
std::unique_lock<std::mutex> lock (mutex_);
187
- if (!config.HasValue (
188
- key, config_namespace ? config_namespace : kDefaultNamespace )) {
184
+ if (!config.HasValue (key, kDefaultNamespace )) {
189
185
return false ;
190
186
}
191
- *value = config.GetValue (
192
- key, config_namespace ? config_namespace : kDefaultNamespace );
187
+ *value = config.GetValue (key, kDefaultNamespace );
193
188
}
194
189
195
190
if (info) info->source = source;
@@ -231,10 +226,9 @@ bool RemoteConfigDesktop::IsDouble(const std::string& str) {
231
226
}
232
227
233
228
bool RemoteConfigDesktop::GetBoolean (const char * key,
234
- const char * config_namespace,
235
229
ValueInfo* info) {
236
230
std::string value;
237
- if (!CheckValueInActiveAndDefault (key, config_namespace, info, &value)) {
231
+ if (!CheckValueInActiveAndDefault (key, info, &value)) {
238
232
if (info) {
239
233
info->source = kValueSourceStaticValue ;
240
234
info->conversion_successful = true ;
@@ -255,10 +249,9 @@ bool RemoteConfigDesktop::GetBoolean(const char* key,
255
249
}
256
250
257
251
std::string RemoteConfigDesktop::GetString (const char * key,
258
- const char * config_namespace,
259
252
ValueInfo* info) {
260
253
std::string value;
261
- if (!CheckValueInActiveAndDefault (key, config_namespace, info, &value)) {
254
+ if (!CheckValueInActiveAndDefault (key, info, &value)) {
262
255
if (info) {
263
256
info->source = kValueSourceStaticValue ;
264
257
info->conversion_successful = true ;
@@ -271,10 +264,9 @@ std::string RemoteConfigDesktop::GetString(const char* key,
271
264
}
272
265
273
266
int64_t RemoteConfigDesktop::GetLong (const char * key,
274
- const char * config_namespace,
275
267
ValueInfo* info) {
276
268
std::string value;
277
- if (!CheckValueInActiveAndDefault (key, config_namespace, info, &value)) {
269
+ if (!CheckValueInActiveAndDefault (key, info, &value)) {
278
270
if (info) {
279
271
info->source = kValueSourceStaticValue ;
280
272
info->conversion_successful = true ;
@@ -295,10 +287,9 @@ int64_t RemoteConfigDesktop::GetLong(const char* key,
295
287
}
296
288
297
289
double RemoteConfigDesktop::GetDouble (const char * key,
298
- const char * config_namespace,
299
290
ValueInfo* info) {
300
291
std::string value;
301
- if (!CheckValueInActiveAndDefault (key, config_namespace, info, &value)) {
292
+ if (!CheckValueInActiveAndDefault (key, info, &value)) {
302
293
if (info) {
303
294
info->source = kValueSourceStaticValue ;
304
295
info->conversion_successful = true ;
@@ -318,10 +309,10 @@ double RemoteConfigDesktop::GetDouble(const char* key,
318
309
return convertation_failure ? kDefaultValueForDouble : double_value;
319
310
}
320
311
321
- std::vector<unsigned char > RemoteConfigDesktop::GetData (
322
- const char * key, const char * config_namespace, ValueInfo* info) {
312
+ std::vector<unsigned char > RemoteConfigDesktop::GetData (const char * key,
313
+ ValueInfo* info) {
323
314
std::string value;
324
- if (!CheckValueInActiveAndDefault (key, config_namespace, info, &value)) {
315
+ if (!CheckValueInActiveAndDefault (key, info, &value)) {
325
316
if (info) {
326
317
info->source = kValueSourceStaticValue ;
327
318
info->conversion_successful = true ;
@@ -338,23 +329,18 @@ std::vector<unsigned char> RemoteConfigDesktop::GetData(
338
329
return data_value;
339
330
}
340
331
341
- std::vector<std::string> RemoteConfigDesktop::GetKeys (
342
- const char * config_namespace) {
343
- return GetKeysByPrefix (" " , config_namespace);
332
+ std::vector<std::string> RemoteConfigDesktop::GetKeys () {
333
+ return GetKeysByPrefix (" " );
344
334
}
345
335
346
336
std::vector<std::string> RemoteConfigDesktop::GetKeysByPrefix (
347
- const char * prefix, const char * config_namespace ) {
337
+ const char * prefix) {
348
338
if (prefix == nullptr ) return std::vector<std::string>();
349
339
std::set<std::string> unique_keys;
350
340
{
351
341
std::unique_lock<std::mutex> lock (mutex_);
352
- configs_.active .GetKeysByPrefix (
353
- prefix, config_namespace ? config_namespace : kDefaultNamespace ,
354
- &unique_keys);
355
- configs_.defaults .GetKeysByPrefix (
356
- prefix, config_namespace ? config_namespace : kDefaultNamespace ,
357
- &unique_keys);
342
+ configs_.active .GetKeysByPrefix (prefix, kDefaultNamespace , &unique_keys);
343
+ configs_.defaults .GetKeysByPrefix (prefix, kDefaultNamespace , &unique_keys);
358
344
}
359
345
return std::vector<std::string>(unique_keys.begin (), unique_keys.end ());
360
346
}
0 commit comments