| Index: chromeos/network/network_state_handler.cc
|
| diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
|
| index d1ca44f89dc48c4244762c17d353910a116d685a..752699d788ee20cf619566fb9e59465d3e63779b 100644
|
| --- a/chromeos/network/network_state_handler.cc
|
| +++ b/chromeos/network/network_state_handler.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chromeos/network/network_state_handler.h"
|
|
|
| +#include "base/bind.h"
|
| #include "base/format_macros.h"
|
| #include "base/stl_util.h"
|
| #include "base/string_util.h"
|
| @@ -297,9 +298,24 @@ void NetworkStateHandler::GetNetworkList(NetworkStateList* list) const {
|
| }
|
|
|
| void NetworkStateHandler::RequestScan() const {
|
| + network_event_log::AddEntry(kLogModule, "RequestScan", "");
|
| shill_property_handler_->RequestScan();
|
| }
|
|
|
| +void NetworkStateHandler::WaitForScan(const std::string& type,
|
| + const base::Closure& callback) {
|
| + scan_complete_callbacks_[type].push_back(callback);
|
| + if (!GetScanningByType(type))
|
| + RequestScan();
|
| +}
|
| +
|
| +void NetworkStateHandler::ConnectToBestWifiNetwork() {
|
| + network_event_log::AddEntry(kLogModule, "ConnectToBestWifiNetwork", "");
|
| + WaitForScan(flimflam::kTypeWifi,
|
| + base::Bind(&internal::ShillPropertyHandler::ConnectToBestServices,
|
| + shill_property_handler_->AsWeakPtr()));
|
| +}
|
| +
|
| //------------------------------------------------------------------------------
|
| // ShillPropertyHandler::Delegate overrides
|
|
|
| @@ -429,6 +445,9 @@ void NetworkStateHandler::UpdateDeviceProperty(const std::string& device_path,
|
| FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
|
| DeviceListChanged());
|
|
|
| + if (key == flimflam::kScanningProperty && device->scanning() == false)
|
| + ScanCompleted(device->type());
|
| +
|
| std::string detail = device->name() + "." + key;
|
| std::string vstr = ValueAsString(value);
|
| if (!vstr.empty())
|
| @@ -549,4 +568,19 @@ void NetworkStateHandler::NetworkPropertiesUpdated(
|
| NetworkPropertiesUpdated(network));
|
| }
|
|
|
| +void NetworkStateHandler::ScanCompleted(const std::string& type) {
|
| + size_t num_callbacks = scan_complete_callbacks_.count(type);
|
| + network_event_log::AddEntry(
|
| + kLogModule, "ScanCompleted",
|
| + base::StringPrintf("%s: %"PRIuS, type.c_str(), num_callbacks));
|
| + if (num_callbacks == 0)
|
| + return;
|
| + ScanCallbackList& callback_list = scan_complete_callbacks_[type];
|
| + for (ScanCallbackList::iterator iter = callback_list.begin();
|
| + iter != callback_list.end(); ++iter) {
|
| + (*iter).Run();
|
| + }
|
| + scan_complete_callbacks_.erase(type);
|
| +}
|
| +
|
| } // namespace chromeos
|
|
|