Chromium Code Reviews| 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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 void PassStubServiceProperties( | 35 void PassStubServiceProperties( |
| 36 const ShillServiceClient::DictionaryValueCallback& callback, | 36 const ShillServiceClient::DictionaryValueCallback& callback, |
| 37 DBusMethodCallStatus call_status, | 37 DBusMethodCallStatus call_status, |
| 38 const base::DictionaryValue* properties) { | 38 const base::DictionaryValue* properties) { |
| 39 callback.Run(call_status, *properties); | 39 callback.Run(call_status, *properties); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 const char ShillServiceClientStub::kStubPortalledWifiPath[] = "portalled_wifi"; | |
| 45 const char ShillServiceClientStub::kStubPortalledWifiName[] = "Portalled Wifi"; | |
|
oshima
2013/08/06 21:00:02
If you follow my suggestion, you can put them in a
ygorshenin1
2013/08/07 09:00:30
Done.
| |
| 46 | |
| 44 ShillServiceClientStub::ShillServiceClientStub() : weak_ptr_factory_(this) { | 47 ShillServiceClientStub::ShillServiceClientStub() : weak_ptr_factory_(this) { |
| 45 SetDefaultProperties(); | 48 SetDefaultProperties(); |
| 46 } | 49 } |
| 47 | 50 |
| 48 ShillServiceClientStub::~ShillServiceClientStub() { | 51 ShillServiceClientStub::~ShillServiceClientStub() { |
| 49 STLDeleteContainerPairSecondPointers( | 52 STLDeleteContainerPairSecondPointers( |
| 50 observer_list_.begin(), observer_list_.end()); | 53 observer_list_.begin(), observer_list_.end()); |
| 51 } | 54 } |
| 52 | 55 |
| 53 // ShillServiceClient overrides. | 56 // ShillServiceClient overrides. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 base::StringValue associating_value(flimflam::kStateAssociation); | 178 base::StringValue associating_value(flimflam::kStateAssociation); |
| 176 SetServiceProperty(service_path.value(), | 179 SetServiceProperty(service_path.value(), |
| 177 flimflam::kStateProperty, | 180 flimflam::kStateProperty, |
| 178 associating_value); | 181 associating_value); |
| 179 if (CommandLine::ForCurrentProcess()->HasSwitch( | 182 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 180 chromeos::switches::kEnableStubInteractive)) { | 183 chromeos::switches::kEnableStubInteractive)) { |
| 181 const int kConnectDelaySeconds = 5; | 184 const int kConnectDelaySeconds = 5; |
| 182 delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds); | 185 delay = base::TimeDelta::FromSeconds(kConnectDelaySeconds); |
| 183 } | 186 } |
| 184 // Set Online after a delay | 187 // Set Online after a delay |
| 185 base::StringValue online_value(flimflam::kStateOnline); | 188 std::string state = flimflam::kStateOnline; |
| 189 if (service_path.value() == kStubPortalledWifiPath) | |
| 190 state = flimflam::kStatePortal; | |
|
oshima
2013/08/06 21:00:02
base::StringValue oneline_value(
service_path.v
ygorshenin1
2013/08/07 09:00:30
Done.
| |
| 186 base::MessageLoop::current()->PostDelayedTask( | 191 base::MessageLoop::current()->PostDelayedTask( |
| 187 FROM_HERE, | 192 FROM_HERE, |
| 188 base::Bind(&ShillServiceClientStub::SetProperty, | 193 base::Bind(&ShillServiceClientStub::SetProperty, |
| 189 weak_ptr_factory_.GetWeakPtr(), | 194 weak_ptr_factory_.GetWeakPtr(), |
| 190 service_path, | 195 service_path, |
| 191 flimflam::kStateProperty, | 196 flimflam::kStateProperty, |
| 192 online_value, | 197 base::StringValue(state), |
| 193 base::Bind(&base::DoNothing), | 198 base::Bind(&base::DoNothing), |
| 194 error_callback), | 199 error_callback), |
| 195 delay); | 200 delay); |
| 196 callback.Run(); | 201 callback.Run(); |
| 197 } | 202 } |
| 198 | 203 |
| 199 void ShillServiceClientStub::Disconnect(const dbus::ObjectPath& service_path, | 204 void ShillServiceClientStub::Disconnect(const dbus::ObjectPath& service_path, |
| 200 const base::Closure& callback, | 205 const base::Closure& callback, |
| 201 const ErrorCallback& error_callback) { | 206 const ErrorCallback& error_callback) { |
| 202 base::Value* service; | 207 base::Value* service; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 } | 291 } |
| 287 | 292 |
| 288 // ShillServiceClient::TestInterface overrides. | 293 // ShillServiceClient::TestInterface overrides. |
| 289 | 294 |
| 290 void ShillServiceClientStub::AddService(const std::string& service_path, | 295 void ShillServiceClientStub::AddService(const std::string& service_path, |
| 291 const std::string& name, | 296 const std::string& name, |
| 292 const std::string& type, | 297 const std::string& type, |
| 293 const std::string& state, | 298 const std::string& state, |
| 294 bool add_to_visible_list, | 299 bool add_to_visible_list, |
| 295 bool add_to_watch_list) { | 300 bool add_to_watch_list) { |
| 296 AddServiceWithIPConfig(service_path, name, type, state, "", | 301 std::string nstate = state; |
| 302 if (CommandLine::ForCurrentProcess()-> | |
| 303 HasSwitch(chromeos::switches::kDefaultStubNetworkStateIdle)) { | |
| 304 nstate = flimflam::kStateIdle; | |
| 305 } | |
| 306 AddServiceWithIPConfig(service_path, name, type, nstate, "", | |
| 297 add_to_visible_list, add_to_watch_list); | 307 add_to_visible_list, add_to_watch_list); |
| 298 } | 308 } |
| 299 | 309 |
| 300 void ShillServiceClientStub::AddServiceWithIPConfig( | 310 void ShillServiceClientStub::AddServiceWithIPConfig( |
| 301 const std::string& service_path, | 311 const std::string& service_path, |
| 302 const std::string& name, | 312 const std::string& name, |
| 303 const std::string& type, | 313 const std::string& type, |
| 304 const std::string& state, | 314 const std::string& state, |
| 305 const std::string& ipconfig_path, | 315 const std::string& ipconfig_path, |
| 306 bool add_to_visible_list, | 316 bool add_to_visible_list, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 flimflam::kStateIdle, | 416 flimflam::kStateIdle, |
| 407 add_to_visible, add_to_watchlist); | 417 add_to_visible, add_to_watchlist); |
| 408 SetServiceProperty("wifi2", | 418 SetServiceProperty("wifi2", |
| 409 flimflam::kSecurityProperty, | 419 flimflam::kSecurityProperty, |
| 410 base::StringValue(flimflam::kSecurityPsk)); | 420 base::StringValue(flimflam::kSecurityPsk)); |
| 411 base::FundamentalValue strength_value(80); | 421 base::FundamentalValue strength_value(80); |
| 412 SetServiceProperty("wifi2", | 422 SetServiceProperty("wifi2", |
| 413 flimflam::kSignalStrengthProperty, | 423 flimflam::kSignalStrengthProperty, |
| 414 strength_value); | 424 strength_value); |
| 415 | 425 |
| 426 if (CommandLine::ForCurrentProcess()-> | |
| 427 HasSwitch(chromeos::switches::kEnableStubPortalledWifi)) { | |
| 428 AddService(kStubPortalledWifiPath, kStubPortalledWifiName, | |
| 429 flimflam::kTypeWifi, | |
| 430 flimflam::kStatePortal, | |
| 431 add_to_visible, add_to_watchlist); | |
| 432 SetServiceProperty(kStubPortalledWifiPath, | |
| 433 flimflam::kSecurityProperty, | |
| 434 base::StringValue(flimflam::kSecurityNone)); | |
| 435 } | |
| 436 | |
| 416 // Wimax | 437 // Wimax |
| 417 | 438 |
| 418 AddService("wimax1", "wimax1", | 439 AddService("wimax1", "wimax1", |
| 419 flimflam::kTypeWimax, | 440 flimflam::kTypeWimax, |
| 420 flimflam::kStateIdle, | 441 flimflam::kStateIdle, |
| 421 add_to_visible, add_to_watchlist); | 442 add_to_visible, add_to_watchlist); |
| 422 SetServiceProperty("wimax1", | 443 SetServiceProperty("wimax1", |
| 423 flimflam::kConnectableProperty, | 444 flimflam::kConnectableProperty, |
| 424 base::FundamentalValue(true)); | 445 base::FundamentalValue(true)); |
| 425 | 446 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = | 525 std::map<dbus::ObjectPath, PropertyObserverList*>::iterator iter = |
| 505 observer_list_.find(device_path); | 526 observer_list_.find(device_path); |
| 506 if (iter != observer_list_.end()) | 527 if (iter != observer_list_.end()) |
| 507 return *(iter->second); | 528 return *(iter->second); |
| 508 PropertyObserverList* observer_list = new PropertyObserverList(); | 529 PropertyObserverList* observer_list = new PropertyObserverList(); |
| 509 observer_list_[device_path] = observer_list; | 530 observer_list_[device_path] = observer_list; |
| 510 return *observer_list; | 531 return *observer_list; |
| 511 } | 532 } |
| 512 | 533 |
| 513 } // namespace chromeos | 534 } // namespace chromeos |
| OLD | NEW |