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

Side by Side 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 unified diff | Download patch
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/chromeos/cros/network_library_impl_cros.h" 5 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_writer.h" // for debug output only. 9 #include "base/json/json_writer.h" // for debug output only.
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 CrosRequestNetworkServiceDisconnect(service_path); 511 CrosRequestNetworkServiceDisconnect(service_path);
512 CrosRequestRemoveNetworkService(service_path); 512 CrosRequestRemoveNetworkService(service_path);
513 } 513 }
514 514
515 void NetworkLibraryImplCros::EnableOfflineMode(bool enable) { 515 void NetworkLibraryImplCros::EnableOfflineMode(bool enable) {
516 // If network device is already enabled/disabled, then don't do anything. 516 // If network device is already enabled/disabled, then don't do anything.
517 if (CrosSetOfflineMode(enable)) 517 if (CrosSetOfflineMode(enable))
518 offline_mode_ = enable; 518 offline_mode_ = enable;
519 } 519 }
520 520
521 NetworkIPConfigVector NetworkLibraryImplCros::GetIPConfigs( 521
522 void NetworkLibraryImplCros::GetIPConfigsCallback(
523 const NetworkGetIPConfigsCallback& callback,
524 HardwareAddressFormat format,
525 const NetworkIPConfigVector& ipconfig_vector,
526 const std::string& hardware_address) {
527 std::string hardware_address_tmp = hardware_address;
528 for (size_t i = 0; i < hardware_address_tmp.size(); ++i)
529 hardware_address_tmp[i] = toupper(hardware_address_tmp[i]);
530 if (format == FORMAT_COLON_SEPARATED_HEX) {
531 if (hardware_address_tmp.size() % 2 == 0) {
532 std::string output;
533 for (size_t i = 0; i < hardware_address_tmp.size(); ++i) {
534 if ((i != 0) && (i % 2 == 0))
535 output.push_back(':');
536 output.push_back(hardware_address_tmp[i]);
537 }
538 hardware_address_tmp.swap(output);
539 }
540 } else {
541 DCHECK_EQ(format, FORMAT_RAW_HEX);
542 }
543 callback.Run(ipconfig_vector, hardware_address_tmp);
544 }
545
546 void NetworkLibraryImplCros::GetIPConfigs(
547 const std::string& device_path,
548 HardwareAddressFormat format,
549 const NetworkGetIPConfigsCallback& callback) {
550 CrosListIPConfigs(device_path,
551 base::Bind(&NetworkLibraryImplCros::GetIPConfigsCallback,
552 weak_ptr_factory_.GetWeakPtr(),
553 callback,
554 format));
555 }
556
557 NetworkIPConfigVector NetworkLibraryImplCros::GetIPConfigsAndBlock(
522 const std::string& device_path, 558 const std::string& device_path,
523 std::string* hardware_address, 559 std::string* hardware_address,
524 HardwareAddressFormat format) { 560 HardwareAddressFormat format) {
525 NetworkIPConfigVector ipconfig_vector; 561 NetworkIPConfigVector ipconfig_vector;
526 CrosListIPConfigs(device_path, &ipconfig_vector, NULL, hardware_address); 562 CrosListIPConfigsAndBlock(device_path,
563 &ipconfig_vector,
564 NULL,
565 hardware_address);
527 566
528 for (size_t i = 0; i < hardware_address->size(); ++i) 567 for (size_t i = 0; i < hardware_address->size(); ++i)
529 (*hardware_address)[i] = toupper((*hardware_address)[i]); 568 (*hardware_address)[i] = toupper((*hardware_address)[i]);
530 if (format == FORMAT_COLON_SEPARATED_HEX) { 569 if (format == FORMAT_COLON_SEPARATED_HEX) {
531 if (hardware_address->size() % 2 == 0) { 570 if (hardware_address->size() % 2 == 0) {
532 std::string output; 571 std::string output;
533 for (size_t i = 0; i < hardware_address->size(); ++i) { 572 for (size_t i = 0; i < hardware_address->size(); ++i) {
534 if ((i != 0) && (i % 2 == 0)) 573 if ((i != 0) && (i % 2 == 0))
535 output.push_back(':'); 574 output.push_back(':');
536 output.push_back((*hardware_address)[i]); 575 output.push_back((*hardware_address)[i]);
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 // Find the network associated with this service path, and attempt to refresh 1322 // Find the network associated with this service path, and attempt to refresh
1284 // its IP parameters, so that the changes to the service properties can take 1323 // its IP parameters, so that the changes to the service properties can take
1285 // effect. 1324 // effect.
1286 Network* network = FindNetworkByPath(service_path); 1325 Network* network = FindNetworkByPath(service_path);
1287 1326
1288 if (network && network->connecting_or_connected()) 1327 if (network && network->connecting_or_connected())
1289 RefreshIPConfig(network); 1328 RefreshIPConfig(network);
1290 } 1329 }
1291 1330
1292 } // namespace chromeos 1331 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library_impl_cros.h ('k') | chrome/browser/chromeos/cros/network_library_impl_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698