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

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions.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/cros_network_functions.h" 5 #include "chrome/browser/chromeos/cros/cros_network_functions.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 ipconfig_vector->push_back( 339 ipconfig_vector->push_back(
340 NetworkIPConfig(device_path, 340 NetworkIPConfig(device_path,
341 ParseIPConfigType(type_string), 341 ParseIPConfigType(type_string),
342 address, 342 address,
343 CrosPrefixLengthToNetmask(prefix_len), 343 CrosPrefixLengthToNetmask(prefix_len),
344 gateway, 344 gateway,
345 name_servers_string)); 345 name_servers_string));
346 return true; 346 return true;
347 } 347 }
348 348
349 void ListIPConfigsCallback(const NetworkGetIPConfigsCallback& callback,
350 const std::string& device_path,
351 DBusMethodCallStatus call_status,
352 const base::DictionaryValue& properties) {
353 NetworkIPConfigVector ipconfig_vector;
354 std::string hardware_address;
355 const ListValue* ips = NULL;
356 if (call_status != DBUS_METHOD_CALL_SUCCESS ||
357 !properties.GetListWithoutPathExpansion(flimflam::kIPConfigsProperty,
358 &ips)) {
359 callback.Run(ipconfig_vector, hardware_address);
360 return;
361 }
362
363 for (size_t i = 0; i < ips->GetSize(); i++) {
364 std::string ipconfig_path;
365 if (!ips->GetString(i, &ipconfig_path)) {
366 LOG(WARNING) << "Found NULL ip for device " << device_path;
367 continue;
368 }
369 ParseIPConfig(device_path, ipconfig_path, &ipconfig_vector);
370 }
371 // Get the hardware address as well.
372 properties.GetStringWithoutPathExpansion(flimflam::kAddressProperty,
373 &hardware_address);
374
375 callback.Run(ipconfig_vector, hardware_address);
376 }
377
349 } // namespace 378 } // namespace
350 379
351 SMS::SMS() 380 SMS::SMS()
352 : validity(0), 381 : validity(0),
353 msgclass(0) { 382 msgclass(0) {
354 } 383 }
355 384
356 SMS::~SMS() {} 385 SMS::~SMS() {}
357 386
358 bool CrosActivateCellularModem(const std::string& service_path, 387 bool CrosActivateCellularModem(const std::string& service_path,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 } 676 }
648 677
649 bool CrosSetOfflineMode(bool offline) { 678 bool CrosSetOfflineMode(bool offline) {
650 base::FundamentalValue value(offline); 679 base::FundamentalValue value(offline);
651 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty( 680 DBusThreadManager::Get()->GetShillManagerClient()->SetProperty(
652 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing), 681 flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing),
653 base::Bind(&IgnoreErrors)); 682 base::Bind(&IgnoreErrors));
654 return true; 683 return true;
655 } 684 }
656 685
657 bool CrosListIPConfigs(const std::string& device_path, 686 void CrosListIPConfigs(const std::string& device_path,
658 NetworkIPConfigVector* ipconfig_vector, 687 const NetworkGetIPConfigsCallback& callback) {
659 std::vector<std::string>* ipconfig_paths, 688 const dbus::ObjectPath device_object_path(device_path);
660 std::string* hardware_address) { 689 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties(
690 device_object_path,
691 base::Bind(&ListIPConfigsCallback, callback, device_path));
692 }
693
694 bool CrosListIPConfigsAndBlock(const std::string& device_path,
695 NetworkIPConfigVector* ipconfig_vector,
696 std::vector<std::string>* ipconfig_paths,
697 std::string* hardware_address) {
661 if (hardware_address) 698 if (hardware_address)
662 hardware_address->clear(); 699 hardware_address->clear();
663 const dbus::ObjectPath device_object_path(device_path); 700 const dbus::ObjectPath device_object_path(device_path);
664 ShillDeviceClient* device_client = 701 ShillDeviceClient* device_client =
665 DBusThreadManager::Get()->GetShillDeviceClient(); 702 DBusThreadManager::Get()->GetShillDeviceClient();
666 // TODO(hashimoto): Remove this blocking D-Bus method call. 703 // TODO(hashimoto): Remove this blocking D-Bus method call.
667 // crosbug.com/29902 704 // crosbug.com/29902
668 scoped_ptr<base::DictionaryValue> properties( 705 scoped_ptr<base::DictionaryValue> properties(
669 device_client->CallGetPropertiesAndBlock(device_object_path)); 706 device_client->CallGetPropertiesAndBlock(device_object_path));
670 if (!properties.get()) 707 if (!properties.get())
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 const std::string& carrier, 941 const std::string& carrier,
905 const NetworkOperationCallback& callback) { 942 const NetworkOperationCallback& callback) {
906 DBusThreadManager::Get()->GetShillDeviceClient()->SetCarrier( 943 DBusThreadManager::Get()->GetShillDeviceClient()->SetCarrier(
907 dbus::ObjectPath(device_path), carrier, 944 dbus::ObjectPath(device_path), carrier,
908 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE, 945 base::Bind(callback, device_path, NETWORK_METHOD_ERROR_NONE,
909 std::string()), 946 std::string()),
910 base::Bind(&OnNetworkActionError, callback, device_path)); 947 base::Bind(&OnNetworkActionError, callback, device_path));
911 } 948 }
912 949
913 } // namespace chromeos 950 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.h ('k') | chrome/browser/chromeos/cros/cros_network_functions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698