summaryrefslogtreecommitdiff
path: root/ephemeral_profile.cc
diff options
context:
space:
mode:
authorChris Masone <cmasone@chromium.org>2011-07-11 11:13:35 -0700
committerChris Masone <cmasone@chromium.org>2011-07-11 17:41:30 -0700
commit7aa5f90848b530999d8b6788ecb40aa30871c7ae (patch)
tree5c7abd3cf4e450d9269c2f0b4c1a98408ca42b74 /ephemeral_profile.cc
parenta4766822880815bafdc69778ccaccaf661536181 (diff)
downloadshill-7aa5f90848b530999d8b6788ecb40aa30871c7ae.tar.gz
[shill] Back property storage in Service objects with Entry objects
Much of Shill Service state is persisted to disk, by creating an Entry in a Profile. We should store this info just once, so that we don't have to worry about keeping multiple data stores in sync. This is a first step in that direction. BUG=chromium-os:17436 TEST=unit tests Change-Id: If94db2a38a7d79c56e2c746b2f069cfd7ab4bf65 Reviewed-on: http://gerrit.chromium.org/gerrit/3876 Tested-by: Chris Masone <cmasone@chromium.org> Reviewed-by: Darin Petkov <petkov@chromium.org>
Diffstat (limited to 'ephemeral_profile.cc')
-rw-r--r--ephemeral_profile.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/ephemeral_profile.cc b/ephemeral_profile.cc
new file mode 100644
index 00000000..364274fe
--- /dev/null
+++ b/ephemeral_profile.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "shill/ephemeral_profile.h"
+
+#include <string>
+#include <map>
+
+#include <chromeos/dbus/service_constants.h>
+
+#include "shill/adaptor_interfaces.h"
+#include "shill/control_interface.h"
+#include "shill/entry.h"
+#include "shill/manager.h"
+
+using std::map;
+using std::string;
+
+namespace shill {
+
+EphemeralProfile::EphemeralProfile(ControlInterface *control_interface,
+ GLib *glib,
+ Manager *manager)
+ : Profile(control_interface, glib),
+ manager_(manager) {
+}
+
+EphemeralProfile::~EphemeralProfile() {}
+
+bool EphemeralProfile::MoveToActiveProfile(const std::string &entry_name) {
+ map<string, EntryRefPtr>::iterator it = entries_.find(entry_name);
+ if (it == entries_.end())
+ return false;
+ manager_->ActiveProfile()->AdoptEntry(entry_name, it->second);
+ entries_.erase(it);
+ return true;
+}
+
+} // namespace shill