diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-10 22:36:42 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-10 22:36:42 +0000 |
commit | cc74be8f7f40d70b6bcfadae581d15227e141aee (patch) | |
tree | 842bef978443f25e54028bc89e4c8337a6e19e9a /chromeos | |
parent | 4bf43b9fa720a4325069955649cdcb028e9cf56a (diff) | |
download | chromium_src-cc74be8f7f40d70b6bcfadae581d15227e141aee.zip chromium_src-cc74be8f7f40d70b6bcfadae581d15227e141aee.tar.gz chromium_src-cc74be8f7f40d70b6bcfadae581d15227e141aee.tar.bz2 |
Call RequestScan periodically while the network list is open
Having issues with git cl. This is the same as https://codereview.chromium.org/13978002/
BUG=227096
TBR=gspencer@chromium.org
Review URL: https://chromiumcodereview.appspot.com/14069010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193478 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/dbus/shill_device_client.h | 1 | ||||
-rw-r--r-- | chromeos/dbus/shill_device_client_stub.cc | 19 | ||||
-rw-r--r-- | chromeos/dbus/shill_device_client_stub.h | 1 | ||||
-rw-r--r-- | chromeos/dbus/shill_manager_client_stub.cc | 38 | ||||
-rw-r--r-- | chromeos/dbus/shill_manager_client_stub.h | 2 |
5 files changed, 54 insertions, 7 deletions
diff --git a/chromeos/dbus/shill_device_client.h b/chromeos/dbus/shill_device_client.h index e7490f5..e865753 100644 --- a/chromeos/dbus/shill_device_client.h +++ b/chromeos/dbus/shill_device_client.h @@ -52,6 +52,7 @@ class CHROMEOS_EXPORT ShillDeviceClient { virtual void SetDeviceProperty(const std::string& device_path, const std::string& name, const base::Value& value) = 0; + virtual std::string GetDevicePathForType(const std::string& type) = 0; protected: ~TestInterface() {} diff --git a/chromeos/dbus/shill_device_client_stub.cc b/chromeos/dbus/shill_device_client_stub.cc index 7ede6dc..b82f0d0 100644 --- a/chromeos/dbus/shill_device_client_stub.cc +++ b/chromeos/dbus/shill_device_client_stub.cc @@ -235,11 +235,30 @@ void ShillDeviceClientStub::ClearDevices(){ void ShillDeviceClientStub::SetDeviceProperty(const std::string& device_path, const std::string& name, const base::Value& value){ + VLOG(1) << "SetDeviceProperty: " << device_path + << ": " << name << " = " << value; SetProperty(dbus::ObjectPath(device_path), name, value, base::Bind(&base::DoNothing), base::Bind(&ErrorFunction)); } +std::string ShillDeviceClientStub::GetDevicePathForType( + const std::string& type) { + for (base::DictionaryValue::Iterator iter(stub_devices_); + !iter.IsAtEnd(); iter.Advance()) { + const base::DictionaryValue* properties = NULL; + if (!iter.value().GetAsDictionary(&properties)) + continue; + std::string prop_type; + if (!properties->GetStringWithoutPathExpansion( + flimflam::kTypeProperty, &prop_type) || + prop_type != type) + continue; + return iter.key(); + } + return std::string(); +} + void ShillDeviceClientStub::SetDefaultProperties() { // Add a wifi device. Note: path matches Manager entry. AddDevice("stub_wifi_device1", flimflam::kTypeWifi, "/device/wifi1"); diff --git a/chromeos/dbus/shill_device_client_stub.h b/chromeos/dbus/shill_device_client_stub.h index a2e1eb8..cc7edf2 100644 --- a/chromeos/dbus/shill_device_client_stub.h +++ b/chromeos/dbus/shill_device_client_stub.h @@ -87,6 +87,7 @@ class ShillDeviceClientStub : public ShillDeviceClient, virtual void SetDeviceProperty(const std::string& device_path, const std::string& name, const base::Value& value) OVERRIDE; + virtual std::string GetDevicePathForType(const std::string& type) OVERRIDE; private: typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList; diff --git a/chromeos/dbus/shill_manager_client_stub.cc b/chromeos/dbus/shill_manager_client_stub.cc index f19c5a5..aa58ddf 100644 --- a/chromeos/dbus/shill_manager_client_stub.cc +++ b/chromeos/dbus/shill_manager_client_stub.cc @@ -11,6 +11,7 @@ #include "base/values.h" #include "chromeos/chromeos_switches.h" #include "chromeos/dbus/dbus_thread_manager.h" +#include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_property_changed_observer.h" #include "chromeos/dbus/shill_service_client.h" #include "dbus/bus.h" @@ -94,12 +95,24 @@ void ShillManagerClientStub::SetProperty(const std::string& name, void ShillManagerClientStub::RequestScan(const std::string& type, const base::Closure& callback, const ErrorCallback& error_callback) { - const int kScanDelayMilliseconds = 3000; - CallNotifyObserversPropertyChanged( - flimflam::kServicesProperty, kScanDelayMilliseconds); - if (callback.is_null()) - return; - MessageLoop::current()->PostTask(FROM_HERE, callback); + // For Stub purposes, default to a Wifi scan. + std::string device_type = flimflam::kTypeWifi; + if (!type.empty()) + device_type = type; + ShillDeviceClient::TestInterface* device_client = + DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); + std::string device_path = device_client->GetDevicePathForType(device_type); + if (!device_path.empty()) { + device_client->SetDeviceProperty(device_path, + flimflam::kScanningProperty, + base::FundamentalValue(true)); + } + const int kScanDurationSeconds = 3; + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&ShillManagerClientStub::ScanCompleted, + weak_ptr_factory_.GetWeakPtr(), device_path, callback), + base::TimeDelta::FromSeconds(kScanDurationSeconds)); } void ShillManagerClientStub::EnableTechnology( @@ -312,7 +325,6 @@ void ShillManagerClientStub::AddServiceAtIndex(const std::string& service_path, base::ListValue::iterator iter = std::find_if(service_list->begin(), service_list->end(), ValueEquals(&path_value)); - service_list->Find(path_value); if (iter != service_list->end()) service_list->Erase(iter, NULL); service_list->Insert(index, path_value.DeepCopy()); @@ -507,4 +519,16 @@ base::ListValue* ShillManagerClientStub::GetEnabledServiceList( return new_service_list; } +void ShillManagerClientStub::ScanCompleted(const std::string& device_path, + const base::Closure& callback) { + if (!device_path.empty()) { + DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> + SetDeviceProperty(device_path, + flimflam::kScanningProperty, + base::FundamentalValue(false)); + } + if (!callback.is_null()) + MessageLoop::current()->PostTask(FROM_HERE, callback); +} + } // namespace chromeos diff --git a/chromeos/dbus/shill_manager_client_stub.h b/chromeos/dbus/shill_manager_client_stub.h index eebea36..162d33ab 100644 --- a/chromeos/dbus/shill_manager_client_stub.h +++ b/chromeos/dbus/shill_manager_client_stub.h @@ -113,6 +113,8 @@ class ShillManagerClientStub : public ShillManagerClient, base::ListValue* GetListProperty(const std::string& property); bool TechnologyEnabled(const std::string& type) const; base::ListValue* GetEnabledServiceList(const std::string& property) const; + void ScanCompleted(const std::string& device_path, + const base::Closure& callback); // Dictionary of property name -> property value base::DictionaryValue stub_properties_; |