| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/network/network_state_handler.h" | 5 #include "chromeos/network/network_state_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chromeos/network/device_state.h" | 15 #include "chromeos/network/device_state.h" |
| 16 #include "chromeos/network/favorite_state.h" | 16 #include "chromeos/network/favorite_state.h" |
| 17 #include "chromeos/network/managed_state.h" | 17 #include "chromeos/network/managed_state.h" |
| 18 #include "chromeos/network/network_event_log.h" | 18 #include "chromeos/network/network_event_log.h" |
| 19 #include "chromeos/network/network_state.h" | 19 #include "chromeos/network/network_state.h" |
| 20 #include "chromeos/network/network_state_handler_observer.h" | 20 #include "chromeos/network/network_state_handler_observer.h" |
| 21 #include "chromeos/network/shill_property_handler.h" | 21 #include "chromeos/network/shill_property_handler.h" |
| 22 #include "chromeos/network/shill_property_util.h" |
| 22 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 23 | 24 |
| 24 namespace chromeos { | 25 namespace chromeos { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // Returns true if |network->type()| == |match_type|, or it matches one of the | |
| 29 // following special match types: | |
| 30 // * kMatchTypeDefault matches any network (i.e. the first instance) | |
| 31 // * kMatchTypeNonVirtual matches non virtual networks | |
| 32 // * kMatchTypeWireless matches wireless networks | |
| 33 // * kMatchTypeMobile matches cellular or wimax networks | |
| 34 bool ManagedStateMatchesType(const ManagedState* managed, | |
| 35 const std::string& match_type) { | |
| 36 const std::string& type = managed->type(); | |
| 37 if (match_type == NetworkStateHandler::kMatchTypeDefault) | |
| 38 return true; | |
| 39 if (match_type == type) | |
| 40 return true; | |
| 41 if (match_type == NetworkStateHandler::kMatchTypeNonVirtual && | |
| 42 type != flimflam::kTypeVPN) { | |
| 43 return true; | |
| 44 } | |
| 45 if (match_type == NetworkStateHandler::kMatchTypeWireless && | |
| 46 type != flimflam::kTypeEthernet && type != flimflam::kTypeVPN) { | |
| 47 return true; | |
| 48 } | |
| 49 if (match_type == NetworkStateHandler::kMatchTypeMobile && | |
| 50 (type == flimflam::kTypeCellular || type == flimflam::kTypeWimax)) { | |
| 51 return true; | |
| 52 } | |
| 53 return false; | |
| 54 } | |
| 55 | |
| 56 bool ConnectionStateChanged(NetworkState* network, | 29 bool ConnectionStateChanged(NetworkState* network, |
| 57 const std::string& prev_connection_state) { | 30 const std::string& prev_connection_state) { |
| 58 return (network->connection_state() != prev_connection_state) && | 31 return (network->connection_state() != prev_connection_state) && |
| 59 (network->connection_state() != flimflam::kStateIdle || | 32 (network->connection_state() != flimflam::kStateIdle || |
| 60 !prev_connection_state.empty()); | 33 !prev_connection_state.empty()); |
| 61 } | 34 } |
| 62 | 35 |
| 63 std::string GetManagedStateLogType(const ManagedState* state) { | 36 std::string GetManagedStateLogType(const ManagedState* state) { |
| 64 switch (state->managed_type()) { | 37 switch (state->managed_type()) { |
| 65 case ManagedState::MANAGED_TYPE_NETWORK: | 38 case ManagedState::MANAGED_TYPE_NETWORK: |
| 66 return "Network"; | 39 return "Network"; |
| 67 case ManagedState::MANAGED_TYPE_FAVORITE: | 40 case ManagedState::MANAGED_TYPE_FAVORITE: |
| 68 return "Favorite"; | 41 return "Favorite"; |
| 69 case ManagedState::MANAGED_TYPE_DEVICE: | 42 case ManagedState::MANAGED_TYPE_DEVICE: |
| 70 return "Device"; | 43 return "Device"; |
| 71 } | 44 } |
| 72 NOTREACHED(); | 45 NOTREACHED(); |
| 73 return ""; | 46 return ""; |
| 74 } | 47 } |
| 75 | 48 |
| 76 std::string GetManagedStateLogName(const ManagedState* state) { | 49 std::string GetManagedStateLogName(const ManagedState* state) { |
| 77 if (!state) | 50 if (!state) |
| 78 return "None"; | 51 return "None"; |
| 79 return base::StringPrintf("%s (%s)", state->name().c_str(), | 52 return base::StringPrintf("%s (%s)", state->name().c_str(), |
| 80 state->path().c_str()); | 53 state->path().c_str()); |
| 81 } | 54 } |
| 82 | 55 |
| 83 } // namespace | 56 } // namespace |
| 84 | 57 |
| 85 const char NetworkStateHandler::kMatchTypeDefault[] = "default"; | |
| 86 const char NetworkStateHandler::kMatchTypeWireless[] = "wireless"; | |
| 87 const char NetworkStateHandler::kMatchTypeMobile[] = "mobile"; | |
| 88 const char NetworkStateHandler::kMatchTypeNonVirtual[] = "non-virtual"; | |
| 89 const char NetworkStateHandler::kDefaultCheckPortalList[] = | 58 const char NetworkStateHandler::kDefaultCheckPortalList[] = |
| 90 "ethernet,wifi,cellular"; | 59 "ethernet,wifi,cellular"; |
| 91 | 60 |
| 92 NetworkStateHandler::NetworkStateHandler() { | 61 NetworkStateHandler::NetworkStateHandler() { |
| 93 } | 62 } |
| 94 | 63 |
| 95 NetworkStateHandler::~NetworkStateHandler() { | 64 NetworkStateHandler::~NetworkStateHandler() { |
| 96 STLDeleteContainerPointers(network_list_.begin(), network_list_.end()); | 65 STLDeleteContainerPointers(network_list_.begin(), network_list_.end()); |
| 97 STLDeleteContainerPointers(favorite_list_.begin(), favorite_list_.end()); | 66 STLDeleteContainerPointers(favorite_list_.begin(), favorite_list_.end()); |
| 98 STLDeleteContainerPointers(device_list_.begin(), device_list_.end()); | 67 STLDeleteContainerPointers(device_list_.begin(), device_list_.end()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 129 network_event_log::LOG_LEVEL_DEBUG, | 98 network_event_log::LOG_LEVEL_DEBUG, |
| 130 "NetworkStateHandler::RemoveObserver", ""); | 99 "NetworkStateHandler::RemoveObserver", ""); |
| 131 } | 100 } |
| 132 | 101 |
| 133 void NetworkStateHandler::UpdateManagerProperties() { | 102 void NetworkStateHandler::UpdateManagerProperties() { |
| 134 NET_LOG_USER("UpdateManagerProperties", ""); | 103 NET_LOG_USER("UpdateManagerProperties", ""); |
| 135 shill_property_handler_->UpdateManagerProperties(); | 104 shill_property_handler_->UpdateManagerProperties(); |
| 136 } | 105 } |
| 137 | 106 |
| 138 NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState( | 107 NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState( |
| 139 const std::string& type) const { | 108 const NetworkTypePattern& type) const { |
| 140 std::string technology = GetTechnologyForType(type); | 109 std::string technology = GetTechnologyForType(type); |
| 141 TechnologyState state; | 110 TechnologyState state; |
| 142 if (shill_property_handler_->IsTechnologyEnabled(technology)) | 111 if (shill_property_handler_->IsTechnologyEnabled(technology)) |
| 143 state = TECHNOLOGY_ENABLED; | 112 state = TECHNOLOGY_ENABLED; |
| 144 else if (shill_property_handler_->IsTechnologyEnabling(technology)) | 113 else if (shill_property_handler_->IsTechnologyEnabling(technology)) |
| 145 state = TECHNOLOGY_ENABLING; | 114 state = TECHNOLOGY_ENABLING; |
| 146 else if (shill_property_handler_->IsTechnologyUninitialized(technology)) | 115 else if (shill_property_handler_->IsTechnologyUninitialized(technology)) |
| 147 state = TECHNOLOGY_UNINITIALIZED; | 116 state = TECHNOLOGY_UNINITIALIZED; |
| 148 else if (shill_property_handler_->IsTechnologyAvailable(technology)) | 117 else if (shill_property_handler_->IsTechnologyAvailable(technology)) |
| 149 state = TECHNOLOGY_AVAILABLE; | 118 state = TECHNOLOGY_AVAILABLE; |
| 150 else | 119 else |
| 151 state = TECHNOLOGY_UNAVAILABLE; | 120 state = TECHNOLOGY_UNAVAILABLE; |
| 152 VLOG(2) << "GetTechnologyState: " << type << " = " << state; | 121 VLOG(2) << "GetTechnologyState: " << type.ToDebugString() << " = " << state; |
| 153 return state; | 122 return state; |
| 154 } | 123 } |
| 155 | 124 |
| 156 void NetworkStateHandler::SetTechnologyEnabled( | 125 void NetworkStateHandler::SetTechnologyEnabled( |
| 157 const std::string& type, | 126 const NetworkTypePattern& type, |
| 158 bool enabled, | 127 bool enabled, |
| 159 const network_handler::ErrorCallback& error_callback) { | 128 const network_handler::ErrorCallback& error_callback) { |
| 160 std::string technology = GetTechnologyForType(type); | 129 std::string technology = GetTechnologyForType(type); |
| 161 NET_LOG_USER("SetTechnologyEnabled", | 130 NET_LOG_USER("SetTechnologyEnabled", |
| 162 base::StringPrintf("%s:%d", technology.c_str(), enabled)); | 131 base::StringPrintf("%s:%d", technology.c_str(), enabled)); |
| 163 shill_property_handler_->SetTechnologyEnabled( | 132 shill_property_handler_->SetTechnologyEnabled( |
| 164 technology, enabled, error_callback); | 133 technology, enabled, error_callback); |
| 165 // Signal Technology state changed -> ENABLING | 134 // Signal Technology state changed -> ENABLING |
| 166 NotifyManagerPropertyChanged(); | 135 NotifyManagerPropertyChanged(); |
| 167 } | 136 } |
| 168 | 137 |
| 169 const DeviceState* NetworkStateHandler::GetDeviceState( | 138 const DeviceState* NetworkStateHandler::GetDeviceState( |
| 170 const std::string& device_path) const { | 139 const std::string& device_path) const { |
| 171 const DeviceState* device = GetModifiableDeviceState(device_path); | 140 const DeviceState* device = GetModifiableDeviceState(device_path); |
| 172 DCHECK(!device || device->update_received()); | 141 DCHECK(!device || device->update_received()); |
| 173 return device; | 142 return device; |
| 174 } | 143 } |
| 175 | 144 |
| 176 const DeviceState* NetworkStateHandler::GetDeviceStateByType( | 145 const DeviceState* NetworkStateHandler::GetDeviceStateByType( |
| 177 const std::string& type) const { | 146 const NetworkTypePattern& type) const { |
| 178 for (ManagedStateList::const_iterator iter = device_list_.begin(); | 147 for (ManagedStateList::const_iterator iter = device_list_.begin(); |
| 179 iter != device_list_.end(); ++iter) { | 148 iter != device_list_.end(); ++iter) { |
| 180 ManagedState* device = *iter; | 149 ManagedState* device = *iter; |
| 181 if (!device->update_received()) | 150 if (!device->update_received()) |
| 182 continue; | 151 continue; |
| 183 if (ManagedStateMatchesType(device, type)) | 152 if (device->Matches(type)) |
| 184 return device->AsDeviceState(); | 153 return device->AsDeviceState(); |
| 185 } | 154 } |
| 186 return NULL; | 155 return NULL; |
| 187 } | 156 } |
| 188 | 157 |
| 189 bool NetworkStateHandler::GetScanningByType(const std::string& type) const { | 158 bool NetworkStateHandler::GetScanningByType( |
| 159 const NetworkTypePattern& type) const { |
| 190 for (ManagedStateList::const_iterator iter = device_list_.begin(); | 160 for (ManagedStateList::const_iterator iter = device_list_.begin(); |
| 191 iter != device_list_.end(); ++iter) { | 161 iter != device_list_.end(); ++iter) { |
| 192 const DeviceState* device = (*iter)->AsDeviceState(); | 162 const DeviceState* device = (*iter)->AsDeviceState(); |
| 193 DCHECK(device); | 163 DCHECK(device); |
| 194 if (!device->update_received()) | 164 if (!device->update_received()) |
| 195 continue; | 165 continue; |
| 196 if (ManagedStateMatchesType(device, type) && device->scanning()) | 166 if (device->Matches(type) && device->scanning()) |
| 197 return true; | 167 return true; |
| 198 } | 168 } |
| 199 return false; | 169 return false; |
| 200 } | 170 } |
| 201 | 171 |
| 202 const NetworkState* NetworkStateHandler::GetNetworkState( | 172 const NetworkState* NetworkStateHandler::GetNetworkState( |
| 203 const std::string& service_path) const { | 173 const std::string& service_path) const { |
| 204 const NetworkState* network = GetModifiableNetworkState(service_path); | 174 const NetworkState* network = GetModifiableNetworkState(service_path); |
| 205 DCHECK(!network || network->update_received()); | 175 DCHECK(!network || network->update_received()); |
| 206 return network; | 176 return network; |
| 207 } | 177 } |
| 208 | 178 |
| 209 const NetworkState* NetworkStateHandler::DefaultNetwork() const { | 179 const NetworkState* NetworkStateHandler::DefaultNetwork() const { |
| 210 if (network_list_.empty()) | 180 if (network_list_.empty()) |
| 211 return NULL; | 181 return NULL; |
| 212 const NetworkState* network = network_list_.front()->AsNetworkState(); | 182 const NetworkState* network = network_list_.front()->AsNetworkState(); |
| 213 DCHECK(network); | 183 DCHECK(network); |
| 214 if (!network->update_received() || !network->IsConnectedState()) | 184 if (!network->update_received() || !network->IsConnectedState()) |
| 215 return NULL; | 185 return NULL; |
| 216 return network; | 186 return network; |
| 217 } | 187 } |
| 218 | 188 |
| 219 const NetworkState* NetworkStateHandler::ConnectedNetworkByType( | 189 const NetworkState* NetworkStateHandler::ConnectedNetworkByType( |
| 220 const std::string& type) const { | 190 const NetworkTypePattern& type) const { |
| 221 for (ManagedStateList::const_iterator iter = network_list_.begin(); | 191 for (ManagedStateList::const_iterator iter = network_list_.begin(); |
| 222 iter != network_list_.end(); ++iter) { | 192 iter != network_list_.end(); ++iter) { |
| 223 const NetworkState* network = (*iter)->AsNetworkState(); | 193 const NetworkState* network = (*iter)->AsNetworkState(); |
| 224 DCHECK(network); | 194 DCHECK(network); |
| 225 if (!network->update_received()) | 195 if (!network->update_received()) |
| 226 continue; | 196 continue; |
| 227 if (!network->IsConnectedState()) | 197 if (!network->IsConnectedState()) |
| 228 break; // Connected networks are listed first. | 198 break; // Connected networks are listed first. |
| 229 if (ManagedStateMatchesType(network, type)) | 199 if (network->Matches(type)) |
| 230 return network; | 200 return network; |
| 231 } | 201 } |
| 232 return NULL; | 202 return NULL; |
| 233 } | 203 } |
| 234 | 204 |
| 235 const NetworkState* NetworkStateHandler::ConnectingNetworkByType( | 205 const NetworkState* NetworkStateHandler::ConnectingNetworkByType( |
| 236 const std::string& type) const { | 206 const NetworkTypePattern& type) const { |
| 237 for (ManagedStateList::const_iterator iter = network_list_.begin(); | 207 for (ManagedStateList::const_iterator iter = network_list_.begin(); |
| 238 iter != network_list_.end(); ++iter) { | 208 iter != network_list_.end(); ++iter) { |
| 239 const NetworkState* network = (*iter)->AsNetworkState(); | 209 const NetworkState* network = (*iter)->AsNetworkState(); |
| 240 DCHECK(network); | 210 DCHECK(network); |
| 241 if (!network->update_received() || network->IsConnectedState()) | 211 if (!network->update_received() || network->IsConnectedState()) |
| 242 continue; | 212 continue; |
| 243 if (!network->IsConnectingState()) | 213 if (!network->IsConnectingState()) |
| 244 break; // Connected and connecting networks are listed first. | 214 break; // Connected and connecting networks are listed first. |
| 245 if (ManagedStateMatchesType(network, type)) | 215 if (network->Matches(type)) |
| 246 return network; | 216 return network; |
| 247 } | 217 } |
| 248 return NULL; | 218 return NULL; |
| 249 } | 219 } |
| 250 | 220 |
| 251 const NetworkState* NetworkStateHandler::FirstNetworkByType( | 221 const NetworkState* NetworkStateHandler::FirstNetworkByType( |
| 252 const std::string& type) const { | 222 const NetworkTypePattern& type) const { |
| 253 for (ManagedStateList::const_iterator iter = network_list_.begin(); | 223 for (ManagedStateList::const_iterator iter = network_list_.begin(); |
| 254 iter != network_list_.end(); ++iter) { | 224 iter != network_list_.end(); ++iter) { |
| 255 const NetworkState* network = (*iter)->AsNetworkState(); | 225 const NetworkState* network = (*iter)->AsNetworkState(); |
| 256 DCHECK(network); | 226 DCHECK(network); |
| 257 if (!network->update_received()) | 227 if (!network->update_received()) |
| 258 continue; | 228 continue; |
| 259 if (ManagedStateMatchesType(network, type)) | 229 if (network->Matches(type)) |
| 260 return network; | 230 return network; |
| 261 } | 231 } |
| 262 return NULL; | 232 return NULL; |
| 263 } | 233 } |
| 264 | 234 |
| 265 std::string NetworkStateHandler::HardwareAddressForType( | 235 std::string NetworkStateHandler::HardwareAddressForType( |
| 266 const std::string& type) const { | 236 const NetworkTypePattern& type) const { |
| 267 const NetworkState* network = ConnectedNetworkByType(type); | 237 const NetworkState* network = ConnectedNetworkByType(type); |
| 268 if (!network) | 238 if (!network) |
| 269 return std::string(); | 239 return std::string(); |
| 270 const DeviceState* device = GetDeviceState(network->device_path()); | 240 const DeviceState* device = GetDeviceState(network->device_path()); |
| 271 if (!device) | 241 if (!device) |
| 272 return std::string(); | 242 return std::string(); |
| 273 std::string result = device->mac_address(); | 243 std::string result = device->mac_address(); |
| 274 StringToUpperASCII(&result); | 244 StringToUpperASCII(&result); |
| 275 return result; | 245 return result; |
| 276 } | 246 } |
| 277 | 247 |
| 278 std::string NetworkStateHandler::FormattedHardwareAddressForType( | 248 std::string NetworkStateHandler::FormattedHardwareAddressForType( |
| 279 const std::string& type) const { | 249 const NetworkTypePattern& type) const { |
| 280 std::string address = HardwareAddressForType(type); | 250 std::string address = HardwareAddressForType(type); |
| 281 if (address.size() % 2 != 0) | 251 if (address.size() % 2 != 0) |
| 282 return address; | 252 return address; |
| 283 std::string result; | 253 std::string result; |
| 284 for (size_t i = 0; i < address.size(); ++i) { | 254 for (size_t i = 0; i < address.size(); ++i) { |
| 285 if ((i != 0) && (i % 2 == 0)) | 255 if ((i != 0) && (i % 2 == 0)) |
| 286 result.push_back(':'); | 256 result.push_back(':'); |
| 287 result.push_back(address[i]); | 257 result.push_back(address[i]); |
| 288 } | 258 } |
| 289 return result; | 259 return result; |
| 290 } | 260 } |
| 291 | 261 |
| 292 void NetworkStateHandler::GetNetworkList(NetworkStateList* list) const { | 262 void NetworkStateHandler::GetNetworkList(NetworkStateList* list) const { |
| 293 GetNetworkListByType(kMatchTypeDefault, list); | 263 GetNetworkListByType(NetworkTypePattern::Default(), list); |
| 294 } | 264 } |
| 295 | 265 |
| 296 void NetworkStateHandler::GetNetworkListByType(const std::string& type, | 266 void NetworkStateHandler::GetNetworkListByType(const NetworkTypePattern& type, |
| 297 NetworkStateList* list) const { | 267 NetworkStateList* list) const { |
| 298 DCHECK(list); | 268 DCHECK(list); |
| 299 list->clear(); | 269 list->clear(); |
| 300 for (ManagedStateList::const_iterator iter = network_list_.begin(); | 270 for (ManagedStateList::const_iterator iter = network_list_.begin(); |
| 301 iter != network_list_.end(); ++iter) { | 271 iter != network_list_.end(); ++iter) { |
| 302 const NetworkState* network = (*iter)->AsNetworkState(); | 272 const NetworkState* network = (*iter)->AsNetworkState(); |
| 303 DCHECK(network); | 273 DCHECK(network); |
| 304 if (!network->update_received()) | 274 if (!network->update_received()) |
| 305 continue; | 275 continue; |
| 306 if (ManagedStateMatchesType(network, type)) | 276 if (network->Matches(type)) |
| 307 list->push_back(network); | 277 list->push_back(network); |
| 308 } | 278 } |
| 309 } | 279 } |
| 310 | 280 |
| 311 void NetworkStateHandler::GetDeviceList(DeviceStateList* list) const { | 281 void NetworkStateHandler::GetDeviceList(DeviceStateList* list) const { |
| 312 DCHECK(list); | 282 DCHECK(list); |
| 313 list->clear(); | 283 list->clear(); |
| 314 for (ManagedStateList::const_iterator iter = device_list_.begin(); | 284 for (ManagedStateList::const_iterator iter = device_list_.begin(); |
| 315 iter != device_list_.end(); ++iter) { | 285 iter != device_list_.end(); ++iter) { |
| 316 const DeviceState* device = (*iter)->AsDeviceState(); | 286 const DeviceState* device = (*iter)->AsDeviceState(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 347 } | 317 } |
| 348 | 318 |
| 349 void NetworkStateHandler::RequestScan() const { | 319 void NetworkStateHandler::RequestScan() const { |
| 350 NET_LOG_USER("RequestScan", ""); | 320 NET_LOG_USER("RequestScan", ""); |
| 351 shill_property_handler_->RequestScan(); | 321 shill_property_handler_->RequestScan(); |
| 352 } | 322 } |
| 353 | 323 |
| 354 void NetworkStateHandler::WaitForScan(const std::string& type, | 324 void NetworkStateHandler::WaitForScan(const std::string& type, |
| 355 const base::Closure& callback) { | 325 const base::Closure& callback) { |
| 356 scan_complete_callbacks_[type].push_back(callback); | 326 scan_complete_callbacks_[type].push_back(callback); |
| 357 if (!GetScanningByType(type)) | 327 if (!GetScanningByType(NetworkTypePattern::Primitive(type))) |
| 358 RequestScan(); | 328 RequestScan(); |
| 359 } | 329 } |
| 360 | 330 |
| 361 void NetworkStateHandler::ConnectToBestWifiNetwork() { | 331 void NetworkStateHandler::ConnectToBestWifiNetwork() { |
| 362 NET_LOG_USER("ConnectToBestWifiNetwork", ""); | 332 NET_LOG_USER("ConnectToBestWifiNetwork", ""); |
| 363 WaitForScan(flimflam::kTypeWifi, | 333 WaitForScan(flimflam::kTypeWifi, |
| 364 base::Bind(&internal::ShillPropertyHandler::ConnectToBestServices, | 334 base::Bind(&internal::ShillPropertyHandler::ConnectToBestServices, |
| 365 shill_property_handler_->AsWeakPtr())); | 335 shill_property_handler_->AsWeakPtr())); |
| 366 } | 336 } |
| 367 | 337 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 return; | 709 return; |
| 740 ScanCallbackList& callback_list = scan_complete_callbacks_[type]; | 710 ScanCallbackList& callback_list = scan_complete_callbacks_[type]; |
| 741 for (ScanCallbackList::iterator iter = callback_list.begin(); | 711 for (ScanCallbackList::iterator iter = callback_list.begin(); |
| 742 iter != callback_list.end(); ++iter) { | 712 iter != callback_list.end(); ++iter) { |
| 743 (*iter).Run(); | 713 (*iter).Run(); |
| 744 } | 714 } |
| 745 scan_complete_callbacks_.erase(type); | 715 scan_complete_callbacks_.erase(type); |
| 746 } | 716 } |
| 747 | 717 |
| 748 std::string NetworkStateHandler::GetTechnologyForType( | 718 std::string NetworkStateHandler::GetTechnologyForType( |
| 749 const std::string& type) const { | 719 const NetworkTypePattern& type) const { |
| 750 if (type == kMatchTypeMobile) { | 720 if (type.MatchesType(flimflam::kTypeEthernet)) |
| 751 if (shill_property_handler_->IsTechnologyAvailable(flimflam::kTypeWimax)) | 721 return flimflam::kTypeEthernet; |
| 722 |
| 723 if (type.MatchesType(flimflam::kTypeWifi)) |
| 724 return flimflam::kTypeWifi; |
| 725 |
| 726 if (type.Equals(NetworkTypePattern::Wimax())) |
| 752 return flimflam::kTypeWimax; | 727 return flimflam::kTypeWimax; |
| 753 else | 728 |
| 729 // Prefer Wimax over Cellular only if it's available. |
| 730 if (type.MatchesType(flimflam::kTypeWimax) && |
| 731 shill_property_handler_->IsTechnologyAvailable(flimflam::kTypeWimax)) { |
| 732 return flimflam::kTypeWimax; |
| 733 } |
| 734 |
| 735 if (type.MatchesType(flimflam::kTypeCellular)) |
| 754 return flimflam::kTypeCellular; | 736 return flimflam::kTypeCellular; |
| 755 } | 737 |
| 756 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || | 738 NOTREACHED(); |
| 757 type == kMatchTypeWireless) { | 739 return std::string(); |
| 758 NOTREACHED(); | |
| 759 return flimflam::kTypeWifi; | |
| 760 } | |
| 761 return type; | |
| 762 } | 740 } |
| 763 | 741 |
| 764 } // namespace chromeos | 742 } // namespace chromeos |
| OLD | NEW |