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

Side by Side 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: Fixed flag usage 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/shill_manager_client_stub.h" 5 #include "chromeos/dbus/shill_manager_client_stub.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/chromeos/chromeos_version.h" 8 #include "base/chromeos/chromeos_version.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); 151 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
152 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0); 152 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0);
153 } 153 }
154 154
155 void ShillManagerClientStub::ConfigureService( 155 void ShillManagerClientStub::ConfigureService(
156 const base::DictionaryValue& properties, 156 const base::DictionaryValue& properties,
157 const ObjectPathCallback& callback, 157 const ObjectPathCallback& callback,
158 const ErrorCallback& error_callback) { 158 const ErrorCallback& error_callback) {
159 if (callback.is_null()) 159 if (callback.is_null())
160 return; 160 return;
161
162 // For the purposes of this stub, we're going to assume that the GUID property
163 // is set to the service path because we don't want to re-implement Shill's
164 // 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.
165 ShillServiceClient::TestInterface* service_client =
166 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
167
168 std::string guid;
169 std::string type;
170 if (!properties.GetString(flimflam::kGuidProperty, &guid) ||
171 !properties.GetString(flimflam::kTypeProperty, &type)) {
172 // If the properties aren't filled out completely, then just return an empty
173 // object path.
174 MessageLoop::current()->PostTask(
175 FROM_HERE, base::Bind(callback, dbus::ObjectPath()));
176 return;
177 }
178
179 // Add the service to the service client stub if not already there.
180 service_client->AddService(guid, guid, type, flimflam::kStateIdle, true);
181
182 // Merge the new properties with existing properties, if any.
183 scoped_ptr<base::DictionaryValue> merged_properties;
184 const base::DictionaryValue* existing_properties =
185 service_client->GetServiceProperties(guid);
186 if (existing_properties) {
187 merged_properties.reset(existing_properties->DeepCopy());
188 } else {
189 merged_properties.reset(new base::DictionaryValue);
190 }
191 merged_properties->MergeDictionary(&properties);
192
193 // 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
194 for (base::DictionaryValue::Iterator iter(*merged_properties);
195 !iter.IsAtEnd(); iter.Advance()) {
196 service_client->SetServiceProperty(guid, iter.key(), iter.value());
197 }
198
161 MessageLoop::current()->PostTask( 199 MessageLoop::current()->PostTask(
162 FROM_HERE, base::Bind(callback, dbus::ObjectPath())); 200 FROM_HERE, base::Bind(callback, dbus::ObjectPath(guid)));
163 } 201 }
164 202
165 void ShillManagerClientStub::GetService( 203 void ShillManagerClientStub::GetService(
166 const base::DictionaryValue& properties, 204 const base::DictionaryValue& properties,
167 const ObjectPathCallback& callback, 205 const ObjectPathCallback& callback,
168 const ErrorCallback& error_callback) { 206 const ErrorCallback& error_callback) {
169 if (callback.is_null()) 207 if (callback.is_null())
170 return; 208 return;
171 MessageLoop::current()->PostTask( 209 MessageLoop::current()->PostTask(
172 FROM_HERE, base::Bind(callback, dbus::ObjectPath())); 210 FROM_HERE, base::Bind(callback, dbus::ObjectPath()));
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 std::string type; 493 std::string type;
456 properties->GetString(flimflam::kTypeProperty, &type); 494 properties->GetString(flimflam::kTypeProperty, &type);
457 if (TechnologyEnabled(type)) 495 if (TechnologyEnabled(type))
458 new_service_list->Append((*iter)->DeepCopy()); 496 new_service_list->Append((*iter)->DeepCopy());
459 } 497 }
460 } 498 }
461 return new_service_list; 499 return new_service_list;
462 } 500 }
463 501
464 } // namespace chromeos 502 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698