Skip to content

Commit cae247c

Browse files
chkuang-ga-maurice
authored andcommitted
Remove Remote Config C++ & Unity APIs which take namespace parameter.
This is to align with the breaking changes in iOS/Android API before I/O. go/frc-io2019-breaking-android For desktop implementation, this only remove user facing API. The underlying local persistent storage and REST API are not changed. Disable typo check due to Doxygen syntax "@returns" in remote_config.h PiperOrigin-RevId: 245150591
1 parent 8fffaa4 commit cae247c

File tree

6 files changed

+157
-798
lines changed

6 files changed

+157
-798
lines changed

remote_config/src/desktop/remote_config.cc

Lines changed: 15 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,15 @@ void Terminate() {
6565
#ifndef SWIG
6666
void SetDefaults(const ConfigKeyValueVariant* defaults,
6767
size_t number_of_defaults) {
68-
SetDefaults(defaults, number_of_defaults, nullptr);
69-
}
70-
71-
void SetDefaults(const ConfigKeyValueVariant* defaults,
72-
size_t number_of_defaults, const char* config_namespace) {
7368
FIREBASE_ASSERT_RETURN_VOID(internal::IsInitialized());
74-
g_remote_config_desktop_instance->SetDefaults(defaults, number_of_defaults,
75-
config_namespace);
69+
g_remote_config_desktop_instance->SetDefaults(defaults, number_of_defaults);
7670
}
71+
7772
#endif // SWIG
7873

7974
void SetDefaults(const ConfigKeyValue* defaults, size_t number_of_defaults) {
8075
FIREBASE_ASSERT_RETURN_VOID(internal::IsInitialized());
81-
SetDefaults(defaults, number_of_defaults, nullptr);
82-
}
83-
84-
void SetDefaults(const ConfigKeyValue* defaults, size_t number_of_defaults,
85-
const char* config_namespace) {
86-
FIREBASE_ASSERT_RETURN_VOID(internal::IsInitialized());
87-
g_remote_config_desktop_instance->SetDefaults(defaults, number_of_defaults,
88-
config_namespace);
76+
g_remote_config_desktop_instance->SetDefaults(defaults, number_of_defaults);
8977
}
9078

9179
std::string GetConfigSetting(ConfigSetting setting) {
@@ -99,124 +87,59 @@ void SetConfigSetting(ConfigSetting setting, const char* value) {
9987
}
10088

10189
bool GetBoolean(const char* key) {
102-
return GetBoolean(key, static_cast<char*>(nullptr),
103-
static_cast<ValueInfo*>(nullptr));
104-
}
105-
106-
bool GetBoolean(const char* key, const char* config_namespace) {
107-
return GetBoolean(key, config_namespace, static_cast<ValueInfo*>(nullptr));
90+
return GetBoolean(key, static_cast<ValueInfo*>(nullptr));
10891
}
10992

11093
bool GetBoolean(const char* key, ValueInfo* info) {
111-
return GetBoolean(key, static_cast<char*>(nullptr), info);
112-
}
113-
114-
bool GetBoolean(const char* key, const char* config_namespace,
115-
ValueInfo* info) {
11694
FIREBASE_ASSERT_RETURN(false, internal::IsInitialized());
117-
return g_remote_config_desktop_instance->GetBoolean(key, config_namespace,
118-
info);
95+
return g_remote_config_desktop_instance->GetBoolean(key, info);
11996
}
12097

12198
int64_t GetLong(const char* key) {
122-
return GetLong(key, static_cast<char*>(nullptr),
123-
static_cast<ValueInfo*>(nullptr));
124-
}
125-
126-
int64_t GetLong(const char* key, const char* config_namespace) {
127-
return GetLong(key, config_namespace, static_cast<ValueInfo*>(nullptr));
99+
return GetLong(key, static_cast<ValueInfo*>(nullptr));
128100
}
129101

130102
int64_t GetLong(const char* key, ValueInfo* info) {
131-
return GetLong(key, static_cast<char*>(nullptr), info);
132-
}
133-
134-
int64_t GetLong(const char* key, const char* config_namespace,
135-
ValueInfo* info) {
136103
FIREBASE_ASSERT_RETURN(0, internal::IsInitialized());
137-
return g_remote_config_desktop_instance->GetLong(key, config_namespace, info);
104+
return g_remote_config_desktop_instance->GetLong(key, info);
138105
}
139106

140107
double GetDouble(const char* key) {
141-
return GetDouble(key, static_cast<char*>(nullptr),
142-
static_cast<ValueInfo*>(nullptr));
143-
}
144-
145-
double GetDouble(const char* key, const char* config_namespace) {
146-
return GetDouble(key, config_namespace, static_cast<ValueInfo*>(nullptr));
108+
return GetDouble(key, static_cast<ValueInfo*>(nullptr));
147109
}
148110

149111
double GetDouble(const char* key, ValueInfo* info) {
150-
return GetDouble(key, static_cast<char*>(nullptr), info);
151-
}
152-
153-
double GetDouble(const char* key, const char* config_namespace,
154-
ValueInfo* info) {
155112
FIREBASE_ASSERT_RETURN(0.0, internal::IsInitialized());
156-
return g_remote_config_desktop_instance->GetDouble(key, config_namespace,
157-
info);
113+
return g_remote_config_desktop_instance->GetDouble(key, info);
158114
}
159115

160116
std::string GetString(const char* key) {
161-
return GetString(key, static_cast<char*>(nullptr),
162-
static_cast<ValueInfo*>(nullptr));
163-
}
164-
165-
std::string GetString(const char* key, const char* config_namespace) {
166-
return GetString(key, config_namespace, static_cast<ValueInfo*>(nullptr));
117+
return GetString(key, static_cast<ValueInfo*>(nullptr));
167118
}
168119

169120
std::string GetString(const char* key, ValueInfo* info) {
170-
return GetString(key, static_cast<char*>(nullptr), info);
171-
}
172-
173-
std::string GetString(const char* key, const char* config_namespace,
174-
ValueInfo* info) {
175121
FIREBASE_ASSERT_RETURN(std::string(), internal::IsInitialized());
176-
return g_remote_config_desktop_instance->GetString(key, config_namespace,
177-
info);
122+
return g_remote_config_desktop_instance->GetString(key, info);
178123
}
179124

180125
std::vector<unsigned char> GetData(const char* key) {
181-
return GetData(key, static_cast<char*>(nullptr),
182-
static_cast<ValueInfo*>(nullptr));
183-
}
184-
185-
std::vector<unsigned char> GetData(const char* key,
186-
const char* config_namespace) {
187-
return GetData(key, config_namespace, static_cast<ValueInfo*>(nullptr));
126+
return GetData(key, static_cast<ValueInfo*>(nullptr));
188127
}
189128

190129
std::vector<unsigned char> GetData(const char* key, ValueInfo* info) {
191-
return GetData(key, static_cast<char*>(nullptr), info);
192-
}
193-
194-
std::vector<unsigned char> GetData(const char* key,
195-
const char* config_namespace,
196-
ValueInfo* info) {
197130
FIREBASE_ASSERT_RETURN(std::vector<unsigned char>(),
198131
internal::IsInitialized());
199-
return g_remote_config_desktop_instance->GetData(key, config_namespace, info);
132+
return g_remote_config_desktop_instance->GetData(key, info);
200133
}
201134

202135
std::vector<std::string> GetKeysByPrefix(const char* prefix) {
203-
return GetKeysByPrefix(prefix, static_cast<char*>(nullptr));
204-
}
205-
206-
std::vector<std::string> GetKeysByPrefix(const char* prefix,
207-
const char* config_namespace) {
208136
FIREBASE_ASSERT_RETURN(std::vector<std::string>(), internal::IsInitialized());
209-
return g_remote_config_desktop_instance->GetKeysByPrefix(prefix,
210-
config_namespace);
137+
return g_remote_config_desktop_instance->GetKeysByPrefix(prefix);
211138
}
212139

213140
std::vector<std::string> GetKeys() {
214-
return GetKeys(static_cast<char*>(nullptr));
215-
}
216-
217-
std::vector<std::string> GetKeys(const char* config_namespace) {
218141
FIREBASE_ASSERT_RETURN(std::vector<std::string>(), internal::IsInitialized());
219-
return g_remote_config_desktop_instance->GetKeys(config_namespace);
142+
return g_remote_config_desktop_instance->GetKeys();
220143
}
221144

222145
bool ActivateFetched() {

remote_config/src/desktop/remote_config_desktop.cc

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ std::string RemoteConfigDesktop::VariantToString(const Variant& variant,
104104

105105
#ifndef SWIG
106106
void RemoteConfigDesktop::SetDefaults(const ConfigKeyValueVariant* defaults,
107-
size_t number_of_defaults,
108-
const char* config_namespace) {
107+
size_t number_of_defaults) {
109108
if (defaults == nullptr) {
110109
return;
111110
}
@@ -118,13 +117,12 @@ void RemoteConfigDesktop::SetDefaults(const ConfigKeyValueVariant* defaults,
118117
defaults_map[key] = value;
119118
}
120119
}
121-
SetDefaults(defaults_map, config_namespace);
120+
SetDefaults(defaults_map);
122121
}
123122
#endif // SWIG
124123

125124
void RemoteConfigDesktop::SetDefaults(const ConfigKeyValue* defaults,
126-
size_t number_of_defaults,
127-
const char* config_namespace) {
125+
size_t number_of_defaults) {
128126
if (defaults == nullptr) {
129127
return;
130128
}
@@ -136,16 +134,14 @@ void RemoteConfigDesktop::SetDefaults(const ConfigKeyValue* defaults,
136134
defaults_map[key] = value;
137135
}
138136
}
139-
SetDefaults(defaults_map, config_namespace);
137+
SetDefaults(defaults_map);
140138
}
141139

142140
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) {
145142
{
146143
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);
149145
}
150146
save_channel_.Put();
151147
}
@@ -167,29 +163,28 @@ void RemoteConfigDesktop::SetConfigSetting(ConfigSetting setting,
167163
save_channel_.Put();
168164
}
169165

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) ||
175171
CheckValueInConfig(configs_.defaults, kValueSourceDefaultValue, key,
176-
config_namespace, info, value);
172+
info, value);
177173
}
178174

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) {
182179
if (!key) return false;
183180

184181
{
185182
// TODO(b/74461360): Replace the thread locks with firebase ones.
186183
std::unique_lock<std::mutex> lock(mutex_);
187-
if (!config.HasValue(
188-
key, config_namespace ? config_namespace : kDefaultNamespace)) {
184+
if (!config.HasValue(key, kDefaultNamespace)) {
189185
return false;
190186
}
191-
*value = config.GetValue(
192-
key, config_namespace ? config_namespace : kDefaultNamespace);
187+
*value = config.GetValue(key, kDefaultNamespace);
193188
}
194189

195190
if (info) info->source = source;
@@ -231,10 +226,9 @@ bool RemoteConfigDesktop::IsDouble(const std::string& str) {
231226
}
232227

233228
bool RemoteConfigDesktop::GetBoolean(const char* key,
234-
const char* config_namespace,
235229
ValueInfo* info) {
236230
std::string value;
237-
if (!CheckValueInActiveAndDefault(key, config_namespace, info, &value)) {
231+
if (!CheckValueInActiveAndDefault(key, info, &value)) {
238232
if (info) {
239233
info->source = kValueSourceStaticValue;
240234
info->conversion_successful = true;
@@ -255,10 +249,9 @@ bool RemoteConfigDesktop::GetBoolean(const char* key,
255249
}
256250

257251
std::string RemoteConfigDesktop::GetString(const char* key,
258-
const char* config_namespace,
259252
ValueInfo* info) {
260253
std::string value;
261-
if (!CheckValueInActiveAndDefault(key, config_namespace, info, &value)) {
254+
if (!CheckValueInActiveAndDefault(key, info, &value)) {
262255
if (info) {
263256
info->source = kValueSourceStaticValue;
264257
info->conversion_successful = true;
@@ -271,10 +264,9 @@ std::string RemoteConfigDesktop::GetString(const char* key,
271264
}
272265

273266
int64_t RemoteConfigDesktop::GetLong(const char* key,
274-
const char* config_namespace,
275267
ValueInfo* info) {
276268
std::string value;
277-
if (!CheckValueInActiveAndDefault(key, config_namespace, info, &value)) {
269+
if (!CheckValueInActiveAndDefault(key, info, &value)) {
278270
if (info) {
279271
info->source = kValueSourceStaticValue;
280272
info->conversion_successful = true;
@@ -295,10 +287,9 @@ int64_t RemoteConfigDesktop::GetLong(const char* key,
295287
}
296288

297289
double RemoteConfigDesktop::GetDouble(const char* key,
298-
const char* config_namespace,
299290
ValueInfo* info) {
300291
std::string value;
301-
if (!CheckValueInActiveAndDefault(key, config_namespace, info, &value)) {
292+
if (!CheckValueInActiveAndDefault(key, info, &value)) {
302293
if (info) {
303294
info->source = kValueSourceStaticValue;
304295
info->conversion_successful = true;
@@ -318,10 +309,10 @@ double RemoteConfigDesktop::GetDouble(const char* key,
318309
return convertation_failure ? kDefaultValueForDouble : double_value;
319310
}
320311

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) {
323314
std::string value;
324-
if (!CheckValueInActiveAndDefault(key, config_namespace, info, &value)) {
315+
if (!CheckValueInActiveAndDefault(key, info, &value)) {
325316
if (info) {
326317
info->source = kValueSourceStaticValue;
327318
info->conversion_successful = true;
@@ -338,23 +329,18 @@ std::vector<unsigned char> RemoteConfigDesktop::GetData(
338329
return data_value;
339330
}
340331

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("");
344334
}
345335

346336
std::vector<std::string> RemoteConfigDesktop::GetKeysByPrefix(
347-
const char* prefix, const char* config_namespace) {
337+
const char* prefix) {
348338
if (prefix == nullptr) return std::vector<std::string>();
349339
std::set<std::string> unique_keys;
350340
{
351341
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);
358344
}
359345
return std::vector<std::string>(unique_keys.begin(), unique_keys.end());
360346
}

0 commit comments

Comments
 (0)