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

Side by Side Diff: chromeos/dbus/shill_service_client_stub.cc

Issue 12634019: NetworkChangeNotifierChromeos: Handle IPConfig property changes on the default network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AddServiceWithIPConfig Created 7 years, 8 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_service_client_stub.h" 5 #include "chromeos/dbus/shill_service_client_stub.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return this; 247 return this;
248 } 248 }
249 249
250 // ShillServiceClient::TestInterface overrides. 250 // ShillServiceClient::TestInterface overrides.
251 251
252 void ShillServiceClientStub::AddService(const std::string& service_path, 252 void ShillServiceClientStub::AddService(const std::string& service_path,
253 const std::string& name, 253 const std::string& name,
254 const std::string& type, 254 const std::string& type,
255 const std::string& state, 255 const std::string& state,
256 bool add_to_watch_list) { 256 bool add_to_watch_list) {
257 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 257 AddServiceInternal(service_path, name, type, state, "", add_to_watch_list);
258 AddService(service_path, add_to_watch_list); 258 }
259 259
260 base::DictionaryValue* properties = 260 void ShillServiceClientStub::AddServiceWithIPConfig(
261 GetModifiableServiceProperties(service_path); 261 const std::string& service_path,
262 properties->SetWithoutPathExpansion( 262 const std::string& name,
263 flimflam::kSSIDProperty, 263 const std::string& type,
264 base::Value::CreateStringValue(service_path)); 264 const std::string& state,
265 properties->SetWithoutPathExpansion( 265 const std::string& ipconfig_path,
266 flimflam::kNameProperty, 266 bool add_to_watch_list) {
267 base::Value::CreateStringValue(name)); 267 AddServiceInternal(service_path, name, type, state, ipconfig_path,
pneubeck (no reviews) 2013/03/28 10:37:54 Why not adding the implementation here?
gauravsh 2013/03/28 18:48:54 No particular reason. Done.
268 properties->SetWithoutPathExpansion( 268 add_to_watch_list);
269 flimflam::kTypeProperty,
270 base::Value::CreateStringValue(type));
271 properties->SetWithoutPathExpansion(
272 flimflam::kStateProperty,
273 base::Value::CreateStringValue(state));
274 } 269 }
275 270
276 void ShillServiceClientStub::RemoveService(const std::string& service_path) { 271 void ShillServiceClientStub::RemoveService(const std::string& service_path) {
277 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 272 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
278 RemoveService(service_path); 273 RemoveService(service_path);
279 274
280 stub_services_.RemoveWithoutPathExpansion(service_path, NULL); 275 stub_services_.RemoveWithoutPathExpansion(service_path, NULL);
281 } 276 }
282 277
283 void ShillServiceClientStub::SetServiceProperty(const std::string& service_path, 278 void ShillServiceClientStub::SetServiceProperty(const std::string& service_path,
(...skipping 11 matching lines...) Expand all
295 return properties; 290 return properties;
296 } 291 }
297 292
298 void ShillServiceClientStub::ClearServices() { 293 void ShillServiceClientStub::ClearServices() {
299 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 294 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
300 ClearServices(); 295 ClearServices();
301 296
302 stub_services_.Clear(); 297 stub_services_.Clear();
303 } 298 }
304 299
300 void ShillServiceClientStub::AddServiceInternal(
301 const std::string& service_path,
302 const std::string& name,
303 const std::string& type,
304 const std::string& state,
305 const std::string& ipconfig_path,
306 bool add_to_watch_list) {
307 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
308 AddService(service_path, add_to_watch_list);
309
310 base::DictionaryValue* properties =
311 GetModifiableServiceProperties(service_path);
312 properties->SetWithoutPathExpansion(
313 flimflam::kSSIDProperty,
314 base::Value::CreateStringValue(service_path));
315 properties->SetWithoutPathExpansion(
316 flimflam::kNameProperty,
317 base::Value::CreateStringValue(name));
318 properties->SetWithoutPathExpansion(
319 flimflam::kTypeProperty,
320 base::Value::CreateStringValue(type));
321 properties->SetWithoutPathExpansion(
322 flimflam::kStateProperty,
323 base::Value::CreateStringValue(state));
324 if (!ipconfig_path.empty())
325 properties->SetWithoutPathExpansion(
326 shill::kIPConfigProperty,
327 base::Value::CreateStringValue(ipconfig_path));
328 }
329
305 void ShillServiceClientStub::SetDefaultProperties() { 330 void ShillServiceClientStub::SetDefaultProperties() {
306 const bool add_to_watchlist = true; 331 const bool add_to_watchlist = true;
307 332
308 if (!CommandLine::ForCurrentProcess()->HasSwitch( 333 if (!CommandLine::ForCurrentProcess()->HasSwitch(
309 chromeos::switches::kDisableStubEthernet)) { 334 chromeos::switches::kDisableStubEthernet)) {
310 AddService("stub_ethernet", "eth0", 335 AddService("stub_ethernet", "eth0",
311 flimflam::kTypeEthernet, 336 flimflam::kTypeEthernet,
312 flimflam::kStateOnline, 337 flimflam::kStateOnline,
313 add_to_watchlist); 338 add_to_watchlist);
314 } 339 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = 433 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter =
409 observer_list_.find(device_path); 434 observer_list_.find(device_path);
410 if (iter != observer_list_.end()) 435 if (iter != observer_list_.end())
411 return *(iter->second); 436 return *(iter->second);
412 PropertyObserverList* observer_list = new PropertyObserverList(); 437 PropertyObserverList* observer_list = new PropertyObserverList();
413 observer_list_[device_path] = observer_list; 438 observer_list_[device_path] = observer_list;
414 return *observer_list; 439 return *observer_list;
415 } 440 }
416 441
417 } // namespace chromeos 442 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698