Chromium Code Reviews| 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. |
|
stevenjb
2013/03/07 00:43:22
nit: move this commend below the next line (closer
pneubeck (no reviews)
2013/03/07 13:06:18
we can do that for now, but it might be necessary
Greg Spencer (Chromium)
2013/03/07 22:01:23
Yeah, I know. I hope we don't have to.
|
| + 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. |
|
stevenjb
2013/03/07 00:43:22
Shouldn't we just set all of the new properties in
pneubeck (no reviews)
2013/03/07 13:06:18
+1
Greg Spencer (Chromium)
2013/03/07 22:01:23
Well, but (as I understand it) merging is recursiv
pneubeck (no reviews)
2013/03/08 08:30:35
Makes sense. Your solution is better for Dictionar
|
| + 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( |