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

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: 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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1213
1214 void InternetOptionsHandler::PopulateDictionaryDetails( 1214 void InternetOptionsHandler::PopulateDictionaryDetails(
1215 const chromeos::Network* network) { 1215 const chromeos::Network* network) {
1216 DCHECK(network); 1216 DCHECK(network);
1217 1217
1218 // Send off an asynchronous request to Shill to get the service properties 1218 // Send off an asynchronous request to Shill to get the service properties
1219 // and continue in the callback. 1219 // and continue in the callback.
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()));
1224 } 1224 }
1225 1225
1226 void InternetOptionsHandler::PopulateDictionaryDetailsCallback( 1226 void InternetOptionsHandler::PopulateDictionaryDetailsCallback(
1227 const chromeos::Network* network,
1228 const std::string& service_path, 1227 const std::string& service_path,
1229 const base::DictionaryValue* shill_properties) { 1228 const base::DictionaryValue* shill_properties) {
1229 chromeos::Network* network = cros_->FindNetworkByPath(service_path);
1230 if (!network)
1231 return;
1232 // Have to copy the properties because the object will go out of scope when
1233 // this function call completes (it's owned by the calling function).
1234 base::DictionaryValue* shill_props_copy = shill_properties->DeepCopy();
1235 cros_->GetIPConfigs(
1236 network->device_path(),
1237 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX,
1238 base::Bind(&InternetOptionsHandler::PopulateIPConfigsCallback,
1239 weak_factory_.GetWeakPtr(),
1240 service_path,
1241 base::Owned(shill_props_copy)));
1242 }
1243
1244 void InternetOptionsHandler::PopulateIPConfigsCallback(
1245 const std::string& service_path,
1246 base::DictionaryValue* shill_properties,
1247 const chromeos::NetworkIPConfigVector& ipconfigs,
1248 const std::string& hardware_address) {
1230 if (VLOG_IS_ON(2)) { 1249 if (VLOG_IS_ON(2)) {
1231 std::string properties_json; 1250 std::string properties_json;
1232 base::JSONWriter::WriteWithOptions(shill_properties, 1251 base::JSONWriter::WriteWithOptions(shill_properties,
1233 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1252 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1234 &properties_json); 1253 &properties_json);
1235 VLOG(2) << "Shill Properties: " << std::endl << properties_json; 1254 VLOG(2) << "Shill Properties: " << std::endl << properties_json;
1236 } 1255 }
1256 chromeos::Network* network = cros_->FindNetworkByPath(service_path);
1257 if (!network)
1258 return;
1237 1259
1238 Profile::FromWebUI(web_ui())->GetProxyConfigTracker()->UISetCurrentNetwork( 1260 Profile::FromWebUI(web_ui())->GetProxyConfigTracker()->UISetCurrentNetwork(
1239 network->service_path()); 1261 service_path);
1240 1262
1241 const chromeos::NetworkUIData& ui_data = network->ui_data(); 1263 const chromeos::NetworkUIData& ui_data = network->ui_data();
1242 const chromeos::NetworkPropertyUIData property_ui_data(ui_data); 1264 const chromeos::NetworkPropertyUIData property_ui_data(ui_data);
1243 const base::DictionaryValue* onc = 1265 const base::DictionaryValue* onc =
1244 cros_->FindOncForNetwork(network->unique_id()); 1266 cros_->FindOncForNetwork(network->unique_id());
1245 1267
1246 base::DictionaryValue dictionary; 1268 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()) 1269 if (!hardware_address.empty())
1252 dictionary.SetString(kTagHardwareAddress, hardware_address); 1270 dictionary.SetString(kTagHardwareAddress, hardware_address);
1253 1271
1254 // The DHCP IPConfig contains the values that are actually in use at the 1272 // The DHCP IPConfig contains the values that are actually in use at the
1255 // moment, even if some are overridden by static IP values. 1273 // moment, even if some are overridden by static IP values.
1256 scoped_ptr<DictionaryValue> ipconfig_dhcp(new DictionaryValue); 1274 scoped_ptr<DictionaryValue> ipconfig_dhcp(new DictionaryValue);
1257 std::string ipconfig_name_servers; 1275 std::string ipconfig_name_servers;
1258 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); 1276 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin();
1259 it != ipconfigs.end(); ++it) { 1277 it != ipconfigs.end(); ++it) {
1260 const chromeos::NetworkIPConfig& ipconfig = *it; 1278 const chromeos::NetworkIPConfig& ipconfig = *it;
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 1830
1813 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); 1831 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled());
1814 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); 1832 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available());
1815 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); 1833 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy());
1816 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once 1834 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once
1817 // we have proper back-end support. 1835 // we have proper back-end support.
1818 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); 1836 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode());
1819 } 1837 }
1820 1838
1821 } // namespace options 1839 } // 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