| OLD | NEW |
| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 const base::DictionaryValue* ShillServiceClientStub::GetServiceProperties( | 286 const base::DictionaryValue* ShillServiceClientStub::GetServiceProperties( |
| 287 const std::string& service_path) const { | 287 const std::string& service_path) const { |
| 288 const base::DictionaryValue* properties = NULL; | 288 const base::DictionaryValue* properties = NULL; |
| 289 stub_services_.GetDictionaryWithoutPathExpansion(service_path, &properties); | 289 stub_services_.GetDictionaryWithoutPathExpansion(service_path, &properties); |
| 290 return properties; | 290 return properties; |
| 291 } | 291 } |
| 292 | 292 |
| 293 void ShillServiceClientStub::ClearServices() { | 293 void ShillServiceClientStub::ClearServices() { |
| 294 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> |
| 295 ClearServices(); |
| 296 |
| 294 stub_services_.Clear(); | 297 stub_services_.Clear(); |
| 295 } | 298 } |
| 296 | 299 |
| 297 void ShillServiceClientStub::SetDefaultProperties() { | 300 void ShillServiceClientStub::SetDefaultProperties() { |
| 298 const bool add_to_watchlist = true; | 301 const bool add_to_watchlist = true; |
| 299 | 302 |
| 300 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 303 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 301 chromeos::switches::kDisableStubEthernet)) { | 304 chromeos::switches::kDisableStubEthernet)) { |
| 302 AddService("stub_ethernet", "eth0", | 305 AddService("stub_ethernet", "eth0", |
| 303 flimflam::kTypeEthernet, | 306 flimflam::kTypeEthernet, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 328 flimflam::kStateIdle, | 331 flimflam::kStateIdle, |
| 329 add_to_watchlist); | 332 add_to_watchlist); |
| 330 base::StringValue technology_value(flimflam::kNetworkTechnologyGsm); | 333 base::StringValue technology_value(flimflam::kNetworkTechnologyGsm); |
| 331 SetServiceProperty("stub_cellular1", | 334 SetServiceProperty("stub_cellular1", |
| 332 flimflam::kNetworkTechnologyProperty, | 335 flimflam::kNetworkTechnologyProperty, |
| 333 technology_value); | 336 technology_value); |
| 334 base::StringValue activation_value(flimflam::kActivationStateActivated); | 337 base::StringValue activation_value(flimflam::kActivationStateActivated); |
| 335 SetServiceProperty("stub_cellular1", | 338 SetServiceProperty("stub_cellular1", |
| 336 flimflam::kActivationStateProperty, | 339 flimflam::kActivationStateProperty, |
| 337 activation_value); | 340 activation_value); |
| 341 |
| 342 AddService("stub_vpn1", "vpn1", |
| 343 flimflam::kTypeVPN, |
| 344 flimflam::kStateOnline, |
| 345 add_to_watchlist); |
| 346 |
| 347 AddService("stub_vpn2", "vpn2", |
| 348 flimflam::kTypeVPN, |
| 349 flimflam::kStateOffline, |
| 350 add_to_watchlist); |
| 338 } | 351 } |
| 339 | 352 |
| 340 void ShillServiceClientStub::PassStubServiceProperties( | 353 void ShillServiceClientStub::PassStubServiceProperties( |
| 341 const dbus::ObjectPath& service_path, | 354 const dbus::ObjectPath& service_path, |
| 342 const DictionaryValueCallback& callback) { | 355 const DictionaryValueCallback& callback) { |
| 343 base::DictionaryValue* dict = NULL; | 356 base::DictionaryValue* dict = NULL; |
| 344 if (!stub_services_.GetDictionaryWithoutPathExpansion( | 357 if (!stub_services_.GetDictionaryWithoutPathExpansion( |
| 345 service_path.value(), &dict)) { | 358 service_path.value(), &dict)) { |
| 346 base::DictionaryValue empty_dictionary; | 359 base::DictionaryValue empty_dictionary; |
| 347 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); | 360 callback.Run(DBUS_METHOD_CALL_FAILURE, empty_dictionary); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = | 399 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = |
| 387 observer_list_.find(device_path); | 400 observer_list_.find(device_path); |
| 388 if (iter != observer_list_.end()) | 401 if (iter != observer_list_.end()) |
| 389 return *(iter->second); | 402 return *(iter->second); |
| 390 PropertyObserverList* observer_list = new PropertyObserverList(); | 403 PropertyObserverList* observer_list = new PropertyObserverList(); |
| 391 observer_list_[device_path] = observer_list; | 404 observer_list_[device_path] = observer_list; |
| 392 return *observer_list; | 405 return *observer_list; |
| 393 } | 406 } |
| 394 | 407 |
| 395 } // namespace chromeos | 408 } // namespace chromeos |
| OLD | NEW |