Move ownership of libweave config to DeviceManager
It was not pretty that global config was owner by class responsible for
cloud communications.
Change-Id: I1476c610662a9773d38eb2fc64e1e2a5c769b63c
Reviewed-on: https://weave-review.googlesource.com/1826
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/src/device_manager.cc b/src/device_manager.cc
index 743f5bb..e99ca4d 100644
--- a/src/device_manager.cc
+++ b/src/device_manager.cc
@@ -27,26 +27,25 @@
provider::DnsServiceDiscovery* dns_sd,
provider::HttpServer* http_server,
provider::Wifi* wifi,
- provider::Bluetooth* bluetooth) {
- component_manager_.reset(new ComponentManagerImpl);
-
- std::unique_ptr<Config> config{new Config{config_store}};
- config->Load();
+ provider::Bluetooth* bluetooth)
+ : config_{new Config{config_store}},
+ component_manager_{new ComponentManagerImpl} {
+ config_->Load();
if (http_server) {
auth_manager_.reset(
- new privet::AuthManager(config->GetSettings().secret,
+ new privet::AuthManager(config_->GetSettings().secret,
http_server->GetHttpsCertificateFingerprint()));
- if (auth_manager_->GetSecret() != config->GetSettings().secret) {
+ if (auth_manager_->GetSecret() != config_->GetSettings().secret) {
// There is no Config::OnChangedCallback registered.
- Config::Transaction transaction(config.get());
+ Config::Transaction transaction(config_.get());
transaction.set_secret(auth_manager_->GetSecret());
}
}
device_info_.reset(new DeviceRegistrationInfo(
- component_manager_.get(), std::move(config), task_runner, http_client,
+ config_.get(), component_manager_.get(), task_runner, http_client,
network, auth_manager_.get()));
base_api_handler_.reset(new BaseApiHandler{device_info_.get(), this});