| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 error_callback.Run("Error.InvalidService", "Invalid Service"); | 105 error_callback.Run("Error.InvalidService", "Invalid Service"); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 if (name == flimflam::kStateProperty) { | 108 if (name == flimflam::kStateProperty) { |
| 109 // If we connect to a service, then we move it to the top of the list in | 109 // If we connect to a service, then we move it to the top of the list in |
| 110 // the manager client. | 110 // the manager client. |
| 111 std::string state; | 111 std::string state; |
| 112 if (value.GetAsString(&state) && state == flimflam::kStateOnline) { | 112 if (value.GetAsString(&state) && state == flimflam::kStateOnline) { |
| 113 ShillManagerClient* manager_client = | 113 ShillManagerClient* manager_client = |
| 114 DBusThreadManager::Get()->GetShillManagerClient(); | 114 DBusThreadManager::Get()->GetShillManagerClient(); |
| 115 manager_client->GetTestInterface()->RemoveService(service_path.value()); | 115 manager_client->GetTestInterface()->MoveServiceToIndex( |
| 116 manager_client->GetTestInterface()->AddServiceAtIndex( | |
| 117 service_path.value(), 0, true); | 116 service_path.value(), 0, true); |
| 118 } | 117 } |
| 119 } | 118 } |
| 120 dict->SetWithoutPathExpansion(name, value.DeepCopy()); | 119 dict->SetWithoutPathExpansion(name, value.DeepCopy()); |
| 121 MessageLoop::current()->PostTask( | 120 MessageLoop::current()->PostTask( |
| 122 FROM_HERE, | 121 FROM_HERE, |
| 123 base::Bind(&ShillServiceClientStub::NotifyObserversPropertyChanged, | 122 base::Bind(&ShillServiceClientStub::NotifyObserversPropertyChanged, |
| 124 weak_ptr_factory_.GetWeakPtr(), service_path, name)); | 123 weak_ptr_factory_.GetWeakPtr(), service_path, name)); |
| 125 if (callback.is_null()) | 124 if (callback.is_null()) |
| 126 return; | 125 return; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 282 } |
| 284 | 283 |
| 285 void ShillServiceClientStub::AddServiceWithIPConfig( | 284 void ShillServiceClientStub::AddServiceWithIPConfig( |
| 286 const std::string& service_path, | 285 const std::string& service_path, |
| 287 const std::string& name, | 286 const std::string& name, |
| 288 const std::string& type, | 287 const std::string& type, |
| 289 const std::string& state, | 288 const std::string& state, |
| 290 const std::string& ipconfig_path, | 289 const std::string& ipconfig_path, |
| 291 bool add_to_watch_list) { | 290 bool add_to_watch_list) { |
| 292 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> | 291 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> |
| 293 AddService(service_path, add_to_watch_list); | 292 AddManagerService(service_path, add_to_watch_list); |
| 294 | 293 |
| 295 base::DictionaryValue* properties = | 294 base::DictionaryValue* properties = |
| 296 GetModifiableServiceProperties(service_path); | 295 GetModifiableServiceProperties(service_path); |
| 297 properties->SetWithoutPathExpansion( | 296 properties->SetWithoutPathExpansion( |
| 298 flimflam::kSSIDProperty, | 297 flimflam::kSSIDProperty, |
| 299 base::Value::CreateStringValue(service_path)); | 298 base::Value::CreateStringValue(service_path)); |
| 300 properties->SetWithoutPathExpansion( | 299 properties->SetWithoutPathExpansion( |
| 301 flimflam::kNameProperty, | 300 flimflam::kNameProperty, |
| 302 base::Value::CreateStringValue(name)); | 301 base::Value::CreateStringValue(name)); |
| 303 properties->SetWithoutPathExpansion( | 302 properties->SetWithoutPathExpansion( |
| 304 flimflam::kTypeProperty, | 303 flimflam::kTypeProperty, |
| 305 base::Value::CreateStringValue(type)); | 304 base::Value::CreateStringValue(type)); |
| 306 properties->SetWithoutPathExpansion( | 305 properties->SetWithoutPathExpansion( |
| 307 flimflam::kStateProperty, | 306 flimflam::kStateProperty, |
| 308 base::Value::CreateStringValue(state)); | 307 base::Value::CreateStringValue(state)); |
| 309 if (!ipconfig_path.empty()) | 308 if (!ipconfig_path.empty()) |
| 310 properties->SetWithoutPathExpansion( | 309 properties->SetWithoutPathExpansion( |
| 311 shill::kIPConfigProperty, | 310 shill::kIPConfigProperty, |
| 312 base::Value::CreateStringValue(ipconfig_path)); | 311 base::Value::CreateStringValue(ipconfig_path)); |
| 313 } | 312 } |
| 314 | 313 |
| 315 void ShillServiceClientStub::RemoveService(const std::string& service_path) { | 314 void ShillServiceClientStub::RemoveService(const std::string& service_path) { |
| 316 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> | 315 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> |
| 317 RemoveService(service_path); | 316 RemoveManagerService(service_path); |
| 318 | 317 |
| 319 stub_services_.RemoveWithoutPathExpansion(service_path, NULL); | 318 stub_services_.RemoveWithoutPathExpansion(service_path, NULL); |
| 320 } | 319 } |
| 321 | 320 |
| 322 void ShillServiceClientStub::SetServiceProperty(const std::string& service_path, | 321 void ShillServiceClientStub::SetServiceProperty(const std::string& service_path, |
| 323 const std::string& property, | 322 const std::string& property, |
| 324 const base::Value& value) { | 323 const base::Value& value) { |
| 325 SetProperty(dbus::ObjectPath(service_path), property, value, | 324 SetProperty(dbus::ObjectPath(service_path), property, value, |
| 326 base::Bind(&base::DoNothing), | 325 base::Bind(&base::DoNothing), |
| 327 base::Bind(&ErrorFunction)); | 326 base::Bind(&ErrorFunction)); |
| 328 } | 327 } |
| 329 | 328 |
| 330 const base::DictionaryValue* ShillServiceClientStub::GetServiceProperties( | 329 const base::DictionaryValue* ShillServiceClientStub::GetServiceProperties( |
| 331 const std::string& service_path) const { | 330 const std::string& service_path) const { |
| 332 const base::DictionaryValue* properties = NULL; | 331 const base::DictionaryValue* properties = NULL; |
| 333 stub_services_.GetDictionaryWithoutPathExpansion(service_path, &properties); | 332 stub_services_.GetDictionaryWithoutPathExpansion(service_path, &properties); |
| 334 return properties; | 333 return properties; |
| 335 } | 334 } |
| 336 | 335 |
| 337 void ShillServiceClientStub::ClearServices() { | 336 void ShillServiceClientStub::ClearServices() { |
| 338 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> | 337 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> |
| 339 ClearServices(); | 338 ClearManagerServices(); |
| 340 | 339 |
| 341 stub_services_.Clear(); | 340 stub_services_.Clear(); |
| 342 } | 341 } |
| 343 | 342 |
| 344 void ShillServiceClientStub::SetDefaultProperties() { | 343 void ShillServiceClientStub::SetDefaultProperties() { |
| 345 const bool add_to_watchlist = true; | 344 const bool add_to_watchlist = true; |
| 346 | 345 |
| 347 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 346 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 348 chromeos::switches::kDisableStubEthernet)) { | 347 chromeos::switches::kDisableStubEthernet)) { |
| 349 AddService("stub_ethernet", "eth0", | 348 AddService("stub_ethernet", "eth0", |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = | 433 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = |
| 435 observer_list_.find(device_path); | 434 observer_list_.find(device_path); |
| 436 if (iter != observer_list_.end()) | 435 if (iter != observer_list_.end()) |
| 437 return *(iter->second); | 436 return *(iter->second); |
| 438 PropertyObserverList* observer_list = new PropertyObserverList(); | 437 PropertyObserverList* observer_list = new PropertyObserverList(); |
| 439 observer_list_[device_path] = observer_list; | 438 observer_list_[device_path] = observer_list; |
| 440 return *observer_list; | 439 return *observer_list; |
| 441 } | 440 } |
| 442 | 441 |
| 443 } // namespace chromeos | 442 } // namespace chromeos |
| OLD | NEW |