summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/cros/network_library.cc
diff options
context:
space:
mode:
authorgspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 18:33:57 +0000
committergspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 18:33:57 +0000
commitabfb3027980cef20b60cbacf899da96e84beaf5c (patch)
tree59b8dfc73a7cb3c45e0ed701f6d5e27b361fd5e7 /chrome/browser/chromeos/cros/network_library.cc
parent0b399bdf49c08d4165c5289606fe8a4c14479dfd (diff)
downloadchromium_src-abfb3027980cef20b60cbacf899da96e84beaf5c.zip
chromium_src-abfb3027980cef20b60cbacf899da96e84beaf5c.tar.gz
chromium_src-abfb3027980cef20b60cbacf899da96e84beaf5c.tar.bz2
This is the first pass at making GetIPConfigs asynchronous.
This renames the old GetIPConfigs to GetIPConfigsAndBlock, and deprecates it. Several sites which used to use the old blocking GetIPConfigs have been rewritten to use the non-blocking asynchronous version. There are still two places that were too complex to convert: MoreMenuModel::InitMenuItems SystemTrayDelegate::GetNetworkAddresses Both of those sites rely on getting their results immediately and would need their callers to change significantly to switch to async. In order to allow the IPConfigs to be fetched asynchronously, we need to both get the shill properties for the service and the ipconfigs, so we have to have two layers of async calls. This requires that we convert DictionaryValueCallbacks to use scoped_ptrs so we can avoid a deep copy of the properties. BUG=chromium:147657 TEST=ran on device, tested network menus and settings. Ran unit tests. Review URL: https://chromiumcodereview.appspot.com/11367048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167427 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/cros/network_library.cc')
-rw-r--r--chrome/browser/chromeos/cros/network_library.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index ba81959..8600d88 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -320,7 +320,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()
@@ -513,17 +512,28 @@ void Network::InitIPAddress() {
ip_address_.clear();
if (!EnsureCrosLoaded())
return;
- // If connected, get ip config.
+ // If connected, get IPConfig.
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,
+ service_path_));
+ }
+}
+
+// static
+void Network::InitIPAddressCallback(
+ const std::string& service_path,
+ const NetworkIPConfigVector& ip_configs,
+ const std::string& hardware_address) {
+ Network* network =
+ CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath(service_path);
+ if (!network)
+ return;
+ for (size_t i = 0; i < ip_configs.size(); ++i) {
+ const NetworkIPConfig& ipconfig = ip_configs[i];
+ if (ipconfig.address.size() > 0) {
+ network->ip_address_ = ipconfig.address;
+ break;
}
}
}
@@ -1313,8 +1323,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() {