Merge: Add |name| into LoadSettings/SaveSettings
Libweave needs to store more than one config file.
BUG:25776798
Reviewed-on: https://weave-review.googlesource.com/2198
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
(cherry picked from commit 7ecdf959f10b62f192be867c280a7885626d6b85)
Change-Id: I00ce2ef4e7d272d1a7cfaf73d1802429d4f73831
Reviewed-on: https://weave-review.googlesource.com/2420
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/src/config.cc b/src/config.cc
index 76be205..cf564c8 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -21,6 +21,8 @@
namespace weave {
+const char kConfigName[] = "config";
+
namespace config_keys {
const char kVersion[] = "version";
@@ -139,9 +141,12 @@
void Config::Transaction::LoadState() {
if (!config_->config_store_)
return;
- std::string json_string = config_->config_store_->LoadSettings();
- if (json_string.empty())
- return;
+ std::string json_string = config_->config_store_->LoadSettings(kConfigName);
+ if (json_string.empty()) {
+ json_string = config_->config_store_->LoadSettings();
+ if (json_string.empty())
+ return;
+ }
auto value = base::JSONReader::Read(json_string);
base::DictionaryValue* dict = nullptr;
@@ -266,7 +271,7 @@
base::JSONWriter::WriteWithOptions(
dict, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_string);
- config_store_->SaveSettings(json_string);
+ config_store_->SaveSettings(kConfigName, json_string);
}
Config::Transaction::~Transaction() {