Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: chromeos/dbus/shill_manager_client_stub.cc

Issue 12541007: This adds the setProperties and getState functions to the networking API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload after merge Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/shill_manager_client_stub.cc
diff --git a/chromeos/dbus/shill_manager_client_stub.cc b/chromeos/dbus/shill_manager_client_stub.cc
index 2a74567ad4e96a68c44247de6902aac9c0853a6d..8681baf0c80ecd28ea80a67414585c605e2af15e 100644
--- a/chromeos/dbus/shill_manager_client_stub.cc
+++ b/chromeos/dbus/shill_manager_client_stub.cc
@@ -158,8 +158,46 @@ void ShillManagerClientStub::ConfigureService(
const ErrorCallback& error_callback) {
if (callback.is_null())
return;
+
+ // For the purposes of this stub, we're going to assume that the GUID property
+ // is set to the service path because we don't want to re-implement Shill's
+ // property matching magic here.
+ ShillServiceClient::TestInterface* service_client =
+ DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
+
+ std::string guid;
+ std::string type;
+ if (!properties.GetString(flimflam::kGuidProperty, &guid) ||
+ !properties.GetString(flimflam::kTypeProperty, &type)) {
+ // If the properties aren't filled out completely, then just return an empty
+ // object path.
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(callback, dbus::ObjectPath()));
+ return;
+ }
+
+ // Add the service to the service client stub if not already there.
+ service_client->AddService(guid, guid, type, flimflam::kStateIdle, true);
+
+ // Merge the new properties with existing properties, if any.
+ scoped_ptr<base::DictionaryValue> merged_properties;
+ const base::DictionaryValue* existing_properties =
+ service_client->GetServiceProperties(guid);
+ if (existing_properties) {
+ merged_properties.reset(existing_properties->DeepCopy());
+ } else {
+ merged_properties.reset(new base::DictionaryValue);
+ }
+ merged_properties->MergeDictionary(&properties);
+
+ // Now set all the properties.
+ for (base::DictionaryValue::Iterator iter(*merged_properties);
+ !iter.IsAtEnd(); iter.Advance()) {
+ service_client->SetServiceProperty(guid, iter.key(), iter.value());
+ }
+
MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(callback, dbus::ObjectPath()));
+ FROM_HERE, base::Bind(callback, dbus::ObjectPath(guid)));
}
void ShillManagerClientStub::GetService(
« no previous file with comments | « chrome/test/data/extensions/api_test/networking/test.js ('k') | chromeos/network/onc/onc_translator_onc_to_shill.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698