Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3732)

Unified Diff: chrome/browser/chromeos/cros/network_library_impl_cros.cc

Issue 11367048: This is the first pass at making GetIPConfigs asynchronous. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/cros/network_library_impl_cros.cc
diff --git a/chrome/browser/chromeos/cros/network_library_impl_cros.cc b/chrome/browser/chromeos/cros/network_library_impl_cros.cc
index f3470874111d4e90f48333df484fc6cf89fe4078..21c7cb715508e4fdc5277460ba9b6b7676d7f501 100644
--- a/chrome/browser/chromeos/cros/network_library_impl_cros.cc
+++ b/chrome/browser/chromeos/cros/network_library_impl_cros.cc
@@ -234,8 +234,8 @@ void NetworkLibraryImplCros::CallConnectToNetwork(Network* network) {
void NetworkLibraryImplCros::WifiServiceUpdateAndConnect(
const std::string& service_path,
- const base::DictionaryValue* properties) {
- if (properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
+ if (properties.get()) {
Network* network = ParseNetwork(service_path, *properties);
CHECK_EQ(network->type(), TYPE_WIFI);
ConnectToWifiNetworkUsingConnectData(static_cast<WifiNetwork*>(network));
@@ -255,8 +255,8 @@ void NetworkLibraryImplCros::CallRequestWifiNetworkAndConnect(
void NetworkLibraryImplCros::VPNServiceUpdateAndConnect(
const std::string& service_path,
- const base::DictionaryValue* properties) {
- if (properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
+ if (properties.get()) {
VLOG(1) << "Connecting to new VPN Service: " << service_path;
Network* network = ParseNetwork(service_path, *properties);
CHECK_EQ(network->type(), TYPE_VPN);
@@ -478,7 +478,7 @@ void NetworkLibraryImplCros::RefreshIPConfig(Network* network) {
void NetworkLibraryImplCros::RefreshIPConfigCallback(
const std::string& device_path,
- const base::DictionaryValue* properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
const ListValue* ips = NULL;
if (!properties->GetListWithoutPathExpansion(
flimflam::kIPConfigsProperty, &ips))
@@ -518,12 +518,51 @@ void NetworkLibraryImplCros::EnableOfflineMode(bool enable) {
offline_mode_ = enable;
}
-NetworkIPConfigVector NetworkLibraryImplCros::GetIPConfigs(
+
+void NetworkLibraryImplCros::GetIPConfigsCallback(
+ const NetworkGetIPConfigsCallback& callback,
+ HardwareAddressFormat format,
+ const NetworkIPConfigVector& ipconfig_vector,
+ const std::string& hardware_address) {
+ std::string hardware_address_tmp = hardware_address;
+ for (size_t i = 0; i < hardware_address_tmp.size(); ++i)
+ hardware_address_tmp[i] = toupper(hardware_address_tmp[i]);
+ if (format == FORMAT_COLON_SEPARATED_HEX) {
+ if (hardware_address_tmp.size() % 2 == 0) {
+ std::string output;
+ for (size_t i = 0; i < hardware_address_tmp.size(); ++i) {
+ if ((i != 0) && (i % 2 == 0))
+ output.push_back(':');
+ output.push_back(hardware_address_tmp[i]);
+ }
+ hardware_address_tmp.swap(output);
+ }
+ } else {
+ DCHECK_EQ(format, FORMAT_RAW_HEX);
+ }
+ callback.Run(ipconfig_vector, hardware_address_tmp);
+}
+
+void NetworkLibraryImplCros::GetIPConfigs(
+ const std::string& device_path,
+ HardwareAddressFormat format,
+ const NetworkGetIPConfigsCallback& callback) {
+ CrosListIPConfigs(device_path,
+ base::Bind(&NetworkLibraryImplCros::GetIPConfigsCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback,
+ format));
+}
+
+NetworkIPConfigVector NetworkLibraryImplCros::GetIPConfigsAndBlock(
const std::string& device_path,
std::string* hardware_address,
HardwareAddressFormat format) {
NetworkIPConfigVector ipconfig_vector;
- CrosListIPConfigs(device_path, &ipconfig_vector, NULL, hardware_address);
+ CrosListIPConfigsAndBlock(device_path,
+ &ipconfig_vector,
+ NULL,
+ hardware_address);
for (size_t i = 0; i < hardware_address->size(); ++i)
(*hardware_address)[i] = toupper((*hardware_address)[i]);
@@ -697,8 +736,8 @@ bool NetworkLibraryImplCros::NetworkManagerStatusChanged(
void NetworkLibraryImplCros::NetworkManagerUpdate(
const std::string& manager_path,
- const base::DictionaryValue* properties) {
- if (!properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
+ if (!properties.get()) {
LOG(ERROR) << "Error retrieving manager properties: " << manager_path;
return;
}
@@ -866,8 +905,8 @@ void NetworkLibraryImplCros::UpdateWatchedNetworkServiceList(
void NetworkLibraryImplCros::NetworkServiceUpdate(
const std::string& service_path,
- const base::DictionaryValue* properties) {
- if (!properties)
+ scoped_ptr<base::DictionaryValue> properties) {
+ if (!properties.get())
return; // Network no longer in visible list, ignore.
VLOG(2) << "NetworkServiceUpdate: " << service_path;
ParseNetwork(service_path, *properties);
@@ -977,8 +1016,8 @@ void NetworkLibraryImplCros::RequestRememberedNetworksUpdate() {
void NetworkLibraryImplCros::UpdateProfile(
const std::string& profile_path,
- const base::DictionaryValue* properties) {
- if (!properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
+ if (!properties.get()) {
LOG(ERROR) << "Error retrieving profile: " << profile_path;
return;
}
@@ -1025,8 +1064,8 @@ void NetworkLibraryImplCros::UpdateProfile(
void NetworkLibraryImplCros::RememberedNetworkServiceUpdate(
const std::string& service_path,
- const base::DictionaryValue* properties) {
- if (!properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
+ if (!properties.get()) {
// Remembered network no longer exists.
DeleteRememberedNetwork(service_path);
} else {
@@ -1130,8 +1169,8 @@ void NetworkLibraryImplCros::UpdateNetworkDeviceList(const ListValue* devices) {
void NetworkLibraryImplCros::NetworkDeviceUpdate(
const std::string& device_path,
- const base::DictionaryValue* properties) {
- if (!properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
+ if (!properties.get()) {
// device no longer exists.
DeleteDevice(device_path);
} else {
@@ -1168,10 +1207,10 @@ void NetworkLibraryImplCros::ParseNetworkDevice(const std::string& device_path,
void NetworkLibraryImplCros::SetIPParametersCallback(
const IPParameterInfo& info,
const std::string& service_path,
- const base::DictionaryValue* properties) {
+ scoped_ptr<base::DictionaryValue> properties) {
// crbug.com/146616 will fix this once we have better
// handling of shill errors.
- if (!properties)
+ if (!properties.get())
return;
// Find the properties we're going to set, and minimize the DBus calls below

Powered by Google App Engine
This is Rietveld 408576698