[shill] Profiles need to own their own storage
We're moving to a model where we rely on the StoreInterface
implementation to maintain profile state, instead of managing
a list of Service objects manually. Thus, we need to allow
Profile to own its own StoreInterface.
BUG=chromium-os:17253
TEST=unit
Change-Id: Ie62462686ecf598efeac08a2d3180cd372430bb9
Reviewed-on: http://gerrit.chromium.org/gerrit/9916
Commit-Ready: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
diff --git a/manager.cc b/manager.cc
index 5bffc6c..76a029c 100644
--- a/manager.cc
+++ b/manager.cc
@@ -97,10 +97,6 @@
// TODO(cmasone): Wire these up once we actually put in profile support.
// known_properties_.push_back(flimflam::kProfilesProperty);
- profiles_.push_back(new DefaultProfile(control_interface_,
- this,
- storage_path_,
- props_));
VLOG(2) << "Manager initialized.";
}
@@ -120,6 +116,12 @@
CHECK(file_util::CreateDirectory(storage_path_)) << storage_path_.value();
+ profiles_.push_back(new DefaultProfile(control_interface_,
+ this,
+ storage_path_,
+ props_));
+ CHECK(profiles_[0]->InitStorage(glib_));
+
running_ = true;
adaptor_->UpdateRunning();
device_info_.Start();
@@ -131,25 +133,21 @@
// Persist profile, device, service information to disk.
vector<ProfileRefPtr>::iterator it;
for (it = profiles_.begin(); it != profiles_.end(); ++it) {
- KeyFileStore storage(glib_);
- FilePath profile_path;
- CHECK((*it)->GetStoragePath(&profile_path));
- storage.set_path(profile_path);
- if (storage.Open()) {
- (*it)->Finalize(&storage);
- storage.Close();
- } else {
- LOG(ERROR) << "Could not open storage at " << profile_path.value();
- }
+ (*it)->Finalize();
}
- ephemeral_profile_->Finalize(NULL);
+ ephemeral_profile_->Finalize();
adaptor_->UpdateRunning();
modem_info_.Stop();
device_info_.Stop();
}
+void Manager::AdoptProfile(const ProfileRefPtr &profile) {
+ profiles_.push_back(profile);
+}
+
const ProfileRefPtr &Manager::ActiveProfile() {
+ DCHECK_NE(profiles_.size(), 0);
return profiles_.back();
}