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

Side by Side Diff: chromeos/network/shill_property_handler.cc

Issue 12634019: NetworkChangeNotifierChromeos: Handle IPConfig property changes on the default network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 months 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 | Annotate | Revision Log
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 "chromeos/network/shill_property_handler.h" 5 #include "chromeos/network/shill_property_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/dbus/shill_device_client.h" 14 #include "chromeos/dbus/shill_device_client.h"
15 #include "chromeos/dbus/shill_ipconfig_client.h" 15 #include "chromeos/dbus/shill_ipconfig_client.h"
16 #include "chromeos/dbus/shill_manager_client.h" 16 #include "chromeos/dbus/shill_manager_client.h"
17 #include "chromeos/dbus/shill_service_client.h" 17 #include "chromeos/dbus/shill_service_client.h"
18 #include "chromeos/network/network_event_log.h" 18 #include "chromeos/network/network_event_log.h"
19 #include "chromeos/network/network_state.h"
19 #include "dbus/object_path.h" 20 #include "dbus/object_path.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h" 21 #include "third_party/cros_system_api/dbus/service_constants.h"
21 22
22 namespace { 23 namespace {
23 24
24 const char kLogModule[] = "ShillPropertyHandler"; 25 const char kLogModule[] = "ShillPropertyHandler";
25 26
26 // Limit the number of services or devices we observe. Since they are listed in 27 // Limit the number of services or devices we observe. Since they are listed in
27 // priority order, it should be reasonable to ignore services past this. 28 // priority order, it should be reasonable to ignore services past this.
28 const size_t kMaxObserved = 100; 29 const size_t kMaxObserved = 100;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 NetworkDevicePropertyChangedCallback(path, key, value); 409 NetworkDevicePropertyChangedCallback(path, key, value);
409 else 410 else
410 NOTREACHED(); 411 NOTREACHED();
411 } 412 }
412 413
413 void ShillPropertyHandler::NetworkServicePropertyChangedCallback( 414 void ShillPropertyHandler::NetworkServicePropertyChangedCallback(
414 const std::string& path, 415 const std::string& path,
415 const std::string& key, 416 const std::string& key,
416 const base::Value& value) { 417 const base::Value& value) {
417 if (key == shill::kIPConfigProperty) { 418 if (key == shill::kIPConfigProperty) {
418 // Handle IPConfig here and call listener_->UpdateNetworkServiceIPAddress 419 // Request the IPConfig for the network and update network properties
419 // when the request completes. 420 // when the request completes.
420 std::string ip_config_path; 421 std::string ip_config_path;
421 value.GetAsString(&ip_config_path); 422 value.GetAsString(&ip_config_path);
422 DCHECK(!ip_config_path.empty()); 423 DCHECK(!ip_config_path.empty());
423 DBusThreadManager::Get()->GetShillIPConfigClient()->GetProperties( 424 DBusThreadManager::Get()->GetShillIPConfigClient()->GetProperties(
424 dbus::ObjectPath(ip_config_path), 425 dbus::ObjectPath(ip_config_path),
425 base::Bind(&ShillPropertyHandler::GetIPConfigCallback, 426 base::Bind(&ShillPropertyHandler::GetIPConfigCallback,
426 AsWeakPtr(), path)); 427 AsWeakPtr(), path));
427 } else { 428 } else {
428 listener_->UpdateNetworkServiceProperty(path, key, value); 429 listener_->UpdateNetworkServiceProperty(path, key, value);
429 } 430 }
430 } 431 }
431 432
432 void ShillPropertyHandler::GetIPConfigCallback( 433 void ShillPropertyHandler::GetIPConfigCallback(
433 const std::string& service_path, 434 const std::string& service_path,
434 DBusMethodCallStatus call_status, 435 DBusMethodCallStatus call_status,
435 const base::DictionaryValue& properties) { 436 const base::DictionaryValue& properties) {
436 if (call_status != DBUS_METHOD_CALL_SUCCESS) { 437 if (call_status != DBUS_METHOD_CALL_SUCCESS) {
437 LOG(ERROR) << "Failed to get IP properties for: " << service_path; 438 LOG(ERROR) << "Failed to get IP Config properties for: " << service_path;
438 return; 439 return;
439 } 440 }
440 std::string ip_address; 441 const base::Value* ip_address;
441 if (!properties.GetStringWithoutPathExpansion(flimflam::kAddressProperty, 442 if (!properties.GetWithoutPathExpansion(flimflam::kAddressProperty,
442 &ip_address)) { 443 &ip_address)) {
443 LOG(ERROR) << "Failed to get IP Address property for: " << service_path; 444 LOG(ERROR) << "Failed to get IP Address property for: " << service_path;
444 return; 445 return;
445 } 446 }
446 listener_->UpdateNetworkServiceIPAddress(service_path, ip_address); 447 listener_->UpdateNetworkServiceProperty(
448 service_path,
449 NetworkState::IPConfigProperty(flimflam::kAddressProperty),
450 *ip_address);
451
452 const base::Value* dns_servers = NULL;
453 if (!properties.GetWithoutPathExpansion(
454 flimflam::kNameServersProperty, &dns_servers)) {
455 LOG(ERROR) << "Failed to get Name servers property for: " << service_path;
456 return;
457 }
458 listener_->UpdateNetworkServiceProperty(
459 service_path,
460 NetworkState::IPConfigProperty(flimflam::kNameServersProperty),
461 *dns_servers);
447 } 462 }
448 463
449 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( 464 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback(
450 const std::string& path, 465 const std::string& path,
451 const std::string& key, 466 const std::string& key,
452 const base::Value& value) { 467 const base::Value& value) {
453 listener_->UpdateDeviceProperty(path, key, value); 468 listener_->UpdateDeviceProperty(path, key, value);
454 } 469 }
455 470
456 } // namespace internal 471 } // namespace internal
457 } // namespace chromeos 472 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/shill_property_handler.h ('k') | chromeos/network/shill_property_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698