| 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 "chrome/browser/chromeos/cros/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
| 6 | 6 |
| 7 #include "base/i18n/icu_encoding_detection.h" | 7 #include "base/i18n/icu_encoding_detection.h" |
| 8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
| 9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
| 10 #include "base/json/json_writer.h" // for debug output only. | 10 #include "base/json/json_writer.h" // for debug output only. |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } else if (new_state == STATE_IDLE && IsConnectingState(old_state) | 313 } else if (new_state == STATE_IDLE && IsConnectingState(old_state) |
| 314 && connection_started()) { | 314 && connection_started()) { |
| 315 // If we requested a connect and never went through a connected state, | 315 // If we requested a connect and never went through a connected state, |
| 316 // treat it as a failure. | 316 // treat it as a failure. |
| 317 VLOG(1) << service_path() << ": Inferring Failure state."; | 317 VLOG(1) << service_path() << ": Inferring Failure state."; |
| 318 notify_failure_ = true; | 318 notify_failure_ = true; |
| 319 error_ = ERROR_UNKNOWN; | 319 error_ = ERROR_UNKNOWN; |
| 320 } else if (new_state != STATE_UNKNOWN) { | 320 } else if (new_state != STATE_UNKNOWN) { |
| 321 notify_failure_ = false; | 321 notify_failure_ = false; |
| 322 // State changed, so refresh IP address. | 322 // State changed, so refresh IP address. |
| 323 // Note: blocking DBus call. TODO(stevenjb): refactor this. | |
| 324 InitIPAddress(); | 323 InitIPAddress(); |
| 325 } | 324 } |
| 326 VLOG(1) << name() << ".State [" << service_path() << "]: " << GetStateString() | 325 VLOG(1) << name() << ".State [" << service_path() << "]: " << GetStateString() |
| 327 << " (was: " << ConnectionStateString(old_state) << ")"; | 326 << " (was: " << ConnectionStateString(old_state) << ")"; |
| 328 if (!IsConnectingState(new_state) && new_state != STATE_UNKNOWN) | 327 if (!IsConnectingState(new_state) && new_state != STATE_UNKNOWN) |
| 329 set_connection_started(false); | 328 set_connection_started(false); |
| 330 } | 329 } |
| 331 | 330 |
| 332 void Network::SetError(ConnectionError error) { | 331 void Network::SetError(ConnectionError error) { |
| 333 error_ = error; | 332 error_ = error; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 505 |
| 507 void Network::SetProxyConfig(const std::string& proxy_config) { | 506 void Network::SetProxyConfig(const std::string& proxy_config) { |
| 508 SetOrClearStringProperty( | 507 SetOrClearStringProperty( |
| 509 flimflam::kProxyConfigProperty, proxy_config, &proxy_config_); | 508 flimflam::kProxyConfigProperty, proxy_config, &proxy_config_); |
| 510 } | 509 } |
| 511 | 510 |
| 512 void Network::InitIPAddress() { | 511 void Network::InitIPAddress() { |
| 513 ip_address_.clear(); | 512 ip_address_.clear(); |
| 514 if (!EnsureCrosLoaded()) | 513 if (!EnsureCrosLoaded()) |
| 515 return; | 514 return; |
| 516 // If connected, get ip config. | 515 // If connected, get IPConfig. |
| 517 if (connected() && !device_path_.empty()) { | 516 if (connected() && !device_path_.empty()) { |
| 518 NetworkIPConfigVector ipconfigs; | 517 CrosListIPConfigs(device_path_, |
| 519 if (CrosListIPConfigs(device_path_, &ipconfigs, NULL, NULL)) { | 518 base::Bind(&Network::InitIPAddressCallback, |
| 520 for (size_t i = 0; i < ipconfigs.size(); ++i) { | 519 service_path_)); |
| 521 const NetworkIPConfig& ipconfig = ipconfigs[i]; | 520 } |
| 522 if (ipconfig.address.size() > 0) { | 521 } |
| 523 ip_address_ = ipconfig.address; | 522 |
| 524 break; | 523 // static |
| 525 } | 524 void Network::InitIPAddressCallback( |
| 526 } | 525 const std::string& service_path, |
| 526 const NetworkIPConfigVector& ip_configs, |
| 527 const std::string& hardware_address) { |
| 528 Network* network = |
| 529 CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath(service_path); |
| 530 if (!network) |
| 531 return; |
| 532 for (size_t i = 0; i < ip_configs.size(); ++i) { |
| 533 const NetworkIPConfig& ipconfig = ip_configs[i]; |
| 534 if (ipconfig.address.size() > 0) { |
| 535 network->ip_address_ = ipconfig.address; |
| 536 break; |
| 527 } | 537 } |
| 528 } | 538 } |
| 529 } | 539 } |
| 530 | 540 |
| 531 bool Network::UpdateStatus(const std::string& key, | 541 bool Network::UpdateStatus(const std::string& key, |
| 532 const Value& value, | 542 const Value& value, |
| 533 PropertyIndex* index) { | 543 PropertyIndex* index) { |
| 534 if (network_parser_.get()) | 544 if (network_parser_.get()) |
| 535 return network_parser_->UpdateStatus(key, value, this, index); | 545 return network_parser_->UpdateStatus(key, value, this, index); |
| 536 return false; | 546 return false; |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 } | 1316 } |
| 1307 } | 1317 } |
| 1308 connect.Run(); | 1318 connect.Run(); |
| 1309 } | 1319 } |
| 1310 | 1320 |
| 1311 //////////////////////////////////////////////////////////////////////////////// | 1321 //////////////////////////////////////////////////////////////////////////////// |
| 1312 // WimaxNetwork | 1322 // WimaxNetwork |
| 1313 | 1323 |
| 1314 WimaxNetwork::WimaxNetwork(const std::string& service_path) | 1324 WimaxNetwork::WimaxNetwork(const std::string& service_path) |
| 1315 : WirelessNetwork(service_path, TYPE_WIMAX), | 1325 : WirelessNetwork(service_path, TYPE_WIMAX), |
| 1316 passphrase_required_(false), | 1326 passphrase_required_(false) { |
| 1317 ALLOW_THIS_IN_INITIALIZER_LIST(weak_pointer_factory_(this)) { | |
| 1318 } | 1327 } |
| 1319 | 1328 |
| 1320 WimaxNetwork::~WimaxNetwork() { | 1329 WimaxNetwork::~WimaxNetwork() { |
| 1321 } | 1330 } |
| 1322 | 1331 |
| 1323 void WimaxNetwork::EraseCredentials() { | 1332 void WimaxNetwork::EraseCredentials() { |
| 1324 WipeString(&eap_passphrase_); | 1333 WipeString(&eap_passphrase_); |
| 1325 WipeString(&eap_identity_); | 1334 WipeString(&eap_identity_); |
| 1326 } | 1335 } |
| 1327 | 1336 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1358 NetworkLibrary* impl; | 1367 NetworkLibrary* impl; |
| 1359 if (stub) | 1368 if (stub) |
| 1360 impl = new NetworkLibraryImplStub(); | 1369 impl = new NetworkLibraryImplStub(); |
| 1361 else | 1370 else |
| 1362 impl = new NetworkLibraryImplCros(); | 1371 impl = new NetworkLibraryImplCros(); |
| 1363 impl->Init(); | 1372 impl->Init(); |
| 1364 return impl; | 1373 return impl; |
| 1365 } | 1374 } |
| 1366 | 1375 |
| 1367 } // namespace chromeos | 1376 } // namespace chromeos |
| OLD | NEW |