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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/internet_options_handler.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: fix hardware address format in internet options handler 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/internet_options_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/webui/options/chromeos/internet_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 chromeos::CrosRequestNetworkServiceProperties( 1220 chromeos::CrosRequestNetworkServiceProperties(
1221 network->service_path(), 1221 network->service_path(),
1222 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, 1222 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback,
1223 weak_factory_.GetWeakPtr(), network)); 1223 weak_factory_.GetWeakPtr(), network));
1224 } 1224 }
1225 1225
1226 void InternetOptionsHandler::PopulateDictionaryDetailsCallback( 1226 void InternetOptionsHandler::PopulateDictionaryDetailsCallback(
1227 const chromeos::Network* network, 1227 const chromeos::Network* network,
1228 const std::string& service_path, 1228 const std::string& service_path,
1229 const base::DictionaryValue* shill_properties) { 1229 const base::DictionaryValue* shill_properties) {
1230 // Have to copy the properties because the object will be out of scope when
1231 // this function call completes (it's owned by the calling function).
1232 base::DictionaryValue* shill_props_copy = shill_properties->DeepCopy();
1233 cros_->GetIPConfigs(
1234 network->device_path(),
1235 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX,
1236 base::Bind(&InternetOptionsHandler::PopulateIPConfigsCallback,
1237 weak_factory_.GetWeakPtr(),
1238 network,
Dmitry Polukhin 2012/11/12 23:02:28 I haven't write this code initially so I might not
stevenjb 2012/11/12 23:09:43 Yikes. We should never be passing a Network* in a
Greg Spencer (Chromium) 2012/11/13 00:04:59 Fixed.
1239 base::Owned(shill_props_copy)));
1240 }
1241
1242 void InternetOptionsHandler::PopulateIPConfigsCallback(
1243 const chromeos::Network* network,
1244 base::DictionaryValue* shill_properties,
1245 const chromeos::NetworkIPConfigVector& ipconfigs,
1246 const std::string& hardware_address) {
1230 if (VLOG_IS_ON(2)) { 1247 if (VLOG_IS_ON(2)) {
1231 std::string properties_json; 1248 std::string properties_json;
1232 base::JSONWriter::WriteWithOptions(shill_properties, 1249 base::JSONWriter::WriteWithOptions(shill_properties,
1233 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1250 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1234 &properties_json); 1251 &properties_json);
1235 VLOG(2) << "Shill Properties: " << std::endl << properties_json; 1252 VLOG(2) << "Shill Properties: " << std::endl << properties_json;
1236 } 1253 }
1237 1254
1238 Profile::FromWebUI(web_ui())->GetProxyConfigTracker()->UISetCurrentNetwork( 1255 Profile::FromWebUI(web_ui())->GetProxyConfigTracker()->UISetCurrentNetwork(
1239 network->service_path()); 1256 network->service_path());
1240 1257
1241 const chromeos::NetworkUIData& ui_data = network->ui_data(); 1258 const chromeos::NetworkUIData& ui_data = network->ui_data();
1242 const chromeos::NetworkPropertyUIData property_ui_data(ui_data); 1259 const chromeos::NetworkPropertyUIData property_ui_data(ui_data);
1243 const base::DictionaryValue* onc = 1260 const base::DictionaryValue* onc =
1244 cros_->FindOncForNetwork(network->unique_id()); 1261 cros_->FindOncForNetwork(network->unique_id());
1245 1262
1246 base::DictionaryValue dictionary; 1263 base::DictionaryValue dictionary;
1247 std::string hardware_address;
1248 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs(
1249 network->device_path(), &hardware_address,
1250 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX);
1251 if (!hardware_address.empty()) 1264 if (!hardware_address.empty())
1252 dictionary.SetString(kTagHardwareAddress, hardware_address); 1265 dictionary.SetString(kTagHardwareAddress, hardware_address);
1253 1266
1254 // The DHCP IPConfig contains the values that are actually in use at the 1267 // The DHCP IPConfig contains the values that are actually in use at the
1255 // moment, even if some are overridden by static IP values. 1268 // moment, even if some are overridden by static IP values.
1256 scoped_ptr<DictionaryValue> ipconfig_dhcp(new DictionaryValue); 1269 scoped_ptr<DictionaryValue> ipconfig_dhcp(new DictionaryValue);
1257 std::string ipconfig_name_servers; 1270 std::string ipconfig_name_servers;
1258 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); 1271 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin();
1259 it != ipconfigs.end(); ++it) { 1272 it != ipconfigs.end(); ++it) {
1260 const chromeos::NetworkIPConfig& ipconfig = *it; 1273 const chromeos::NetworkIPConfig& ipconfig = *it;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 name_server_type = kNameServerTypeUser; 1310 name_server_type = kNameServerTypeUser;
1298 } 1311 }
1299 if (ipconfig_name_servers == kGoogleNameServers) { 1312 if (ipconfig_name_servers == kGoogleNameServers) {
1300 name_server_type = kNameServerTypeGoogle; 1313 name_server_type = kNameServerTypeGoogle;
1301 } 1314 }
1302 SetValueDictionary(&dictionary, 1315 SetValueDictionary(&dictionary,
1303 kDictionaryStaticIp, 1316 kDictionaryStaticIp,
1304 static_ip_dict.release(), 1317 static_ip_dict.release(),
1305 property_ui_data); 1318 property_ui_data);
1306 } else { 1319 } else {
1307 LOG(ERROR) << "Unable to fetch IP configuration for " << service_path; 1320 LOG(ERROR) << "Unable to fetch IP configuration for "
1321 << network->service_path();
1308 // If we were unable to fetch shill_properties for some reason, 1322 // If we were unable to fetch shill_properties for some reason,
1309 // then just go with some defaults. 1323 // then just go with some defaults.
1310 dictionary.SetBoolean(kIpConfigAutoConfig, false); 1324 dictionary.SetBoolean(kIpConfigAutoConfig, false);
1311 dictionary.Set(kDictionarySavedIp, new DictionaryValue); 1325 dictionary.Set(kDictionarySavedIp, new DictionaryValue);
1312 SetValueDictionary(&dictionary, kDictionaryStaticIp, new DictionaryValue, 1326 SetValueDictionary(&dictionary, kDictionaryStaticIp, new DictionaryValue,
1313 property_ui_data); 1327 property_ui_data);
1314 } 1328 }
1315 1329
1316 chromeos::ConnectionType type = network->type(); 1330 chromeos::ConnectionType type = network->type();
1317 dictionary.SetInteger(kTagType, type); 1331 dictionary.SetInteger(kTagType, type);
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 1826
1813 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); 1827 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled());
1814 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); 1828 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available());
1815 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); 1829 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy());
1816 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once 1830 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once
1817 // we have proper back-end support. 1831 // we have proper back-end support.
1818 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); 1832 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode());
1819 } 1833 }
1820 1834
1821 } // namespace options 1835 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/internet_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698