Chromium Code Reviews| Index: chrome/browser/chromeos/cros/network_library.cc |
| diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc |
| index ba81959f9ca67c62995c2401e8004f193d89b7ea..7fe99f24042d75010f71607cf3f411eba73fef12 100644 |
| --- a/chrome/browser/chromeos/cros/network_library.cc |
| +++ b/chrome/browser/chromeos/cros/network_library.cc |
| @@ -227,7 +227,8 @@ Network::Network(const std::string& service_path, |
| notify_failure_(false), |
| profile_type_(PROFILE_NONE), |
| service_path_(service_path), |
| - type_(type) { |
| + type_(type), |
| + ALLOW_THIS_IN_INITIALIZER_LIST(weak_pointer_factory_(this)) { |
| } |
| Network::~Network() { |
| @@ -320,7 +321,6 @@ void Network::SetState(ConnectionState new_state) { |
| } else if (new_state != STATE_UNKNOWN) { |
| notify_failure_ = false; |
| // State changed, so refresh IP address. |
| - // Note: blocking DBus call. TODO(stevenjb): refactor this. |
| InitIPAddress(); |
| } |
| VLOG(1) << name() << ".State [" << service_path() << "]: " << GetStateString() |
| @@ -515,15 +515,20 @@ void Network::InitIPAddress() { |
| return; |
| // If connected, get ip config. |
| if (connected() && !device_path_.empty()) { |
| - NetworkIPConfigVector ipconfigs; |
| - if (CrosListIPConfigs(device_path_, &ipconfigs, NULL, NULL)) { |
| - for (size_t i = 0; i < ipconfigs.size(); ++i) { |
| - const NetworkIPConfig& ipconfig = ipconfigs[i]; |
| - if (ipconfig.address.size() > 0) { |
| - ip_address_ = ipconfig.address; |
| - break; |
| - } |
| - } |
| + CrosListIPConfigs(device_path_, |
| + base::Bind(&Network::InitIPAddressCallback, |
| + weak_pointer_factory_.GetWeakPtr())); |
|
stevenjb
2012/11/05 23:22:58
I'd actually rather avoid the overhead of a WeakPt
|
| + } |
| +} |
| + |
| +void Network::InitIPAddressCallback( |
| + const NetworkIPConfigVector& ip_configs, |
| + const std::string& hardware_address) { |
| + for (size_t i = 0; i < ip_configs.size(); ++i) { |
| + const NetworkIPConfig& ipconfig = ip_configs[i]; |
| + if (ipconfig.address.size() > 0) { |
| + ip_address_ = ipconfig.address; |
| + break; |
| } |
| } |
| } |
| @@ -1313,8 +1318,7 @@ void WifiNetwork::MatchCertificatePattern(bool allow_enroll, |
| WimaxNetwork::WimaxNetwork(const std::string& service_path) |
| : WirelessNetwork(service_path, TYPE_WIMAX), |
| - passphrase_required_(false), |
| - ALLOW_THIS_IN_INITIALIZER_LIST(weak_pointer_factory_(this)) { |
| + passphrase_required_(false) { |
| } |
| WimaxNetwork::~WimaxNetwork() { |