OLD | NEW |
---|---|
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" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 NetworkDevicePropertyChangedCallback(path, key, value); | 402 NetworkDevicePropertyChangedCallback(path, key, value); |
403 else | 403 else |
404 NOTREACHED(); | 404 NOTREACHED(); |
405 } | 405 } |
406 | 406 |
407 void ShillPropertyHandler::NetworkServicePropertyChangedCallback( | 407 void ShillPropertyHandler::NetworkServicePropertyChangedCallback( |
408 const std::string& path, | 408 const std::string& path, |
409 const std::string& key, | 409 const std::string& key, |
410 const base::Value& value) { | 410 const base::Value& value) { |
411 if (key == shill::kIPConfigProperty) { | 411 if (key == shill::kIPConfigProperty) { |
412 // Handle IPConfig here and call listener_->UpdateNetworkServiceIPAddress | 412 // Request the IPConfig for the network and update network properties |
413 // when the request completes. | 413 // when the request completes. |
414 std::string ip_config_path; | 414 std::string ip_config_path; |
415 value.GetAsString(&ip_config_path); | 415 value.GetAsString(&ip_config_path); |
416 DCHECK(!ip_config_path.empty()); | 416 DCHECK(!ip_config_path.empty()); |
417 DBusThreadManager::Get()->GetShillIPConfigClient()->GetProperties( | 417 DBusThreadManager::Get()->GetShillIPConfigClient()->GetProperties( |
418 dbus::ObjectPath(ip_config_path), | 418 dbus::ObjectPath(ip_config_path), |
419 base::Bind(&ShillPropertyHandler::GetIPConfigCallback, | 419 base::Bind(&ShillPropertyHandler::GetIPConfigCallback, |
420 weak_ptr_factory_.GetWeakPtr(), path)); | 420 weak_ptr_factory_.GetWeakPtr(), path)); |
421 } else { | 421 } else { |
422 listener_->UpdateNetworkServiceProperty(path, key, value); | 422 listener_->UpdateNetworkServiceProperty(path, key, value); |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 void ShillPropertyHandler::GetIPConfigCallback( | 426 void ShillPropertyHandler::GetIPConfigCallback( |
427 const std::string& service_path, | 427 const std::string& service_path, |
428 DBusMethodCallStatus call_status, | 428 DBusMethodCallStatus call_status, |
429 const base::DictionaryValue& properties) { | 429 const base::DictionaryValue& properties) { |
430 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 430 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
431 LOG(ERROR) << "Failed to get IP properties for: " << service_path; | 431 LOG(ERROR) << "Failed to get IP Config properties for: " << service_path; |
432 return; | 432 return; |
433 } | 433 } |
434 std::string ip_address; | 434 const base::Value* ip_address; |
435 if (!properties.GetStringWithoutPathExpansion(flimflam::kAddressProperty, | 435 if (!properties.GetWithoutPathExpansion(flimflam::kAddressProperty, |
436 &ip_address)) { | 436 &ip_address)) { |
437 LOG(ERROR) << "Failed to get IP Address property for: " << service_path; | 437 LOG(ERROR) << "Failed to get IP Address property for: " << service_path; |
438 return; | 438 return; |
439 } | 439 } |
440 listener_->UpdateNetworkServiceIPAddress(service_path, ip_address); | 440 listener_->UpdateNetworkServiceProperty(service_path, |
441 flimflam::kAddressProperty, | |
pneubeck (no reviews)
2013/03/28 10:37:54
Use the complete nested key, like:
printf('%s.%s'
gauravsh
2013/03/28 18:48:54
I don't see the gain. Is it because you are worrie
stevenjb
2013/03/28 19:27:13
Yes, please do not. NetworkState is a convenience
pneubeck (no reviews)
2013/03/29 19:16:52
This comment was based on the proposed changes to
stevenjb
2013/03/29 19:41:25
OK, I thought about it some more, and now agree th
| |
442 *ip_address); | |
443 | |
444 const base::Value* dns_servers = NULL; | |
445 if (!properties.GetWithoutPathExpansion(flimflam::kNameServersProperty, | |
446 &dns_servers)) { | |
447 LOG(ERROR) << "Failed to get Name servers property for: " << service_path; | |
448 return; | |
449 } | |
450 listener_->UpdateNetworkServiceProperty(service_path, | |
pneubeck (no reviews)
2013/03/28 10:37:54
ditto
gauravsh
2013/03/28 18:48:54
See my question above.
| |
451 flimflam::kNameServersProperty, | |
452 *dns_servers); | |
441 } | 453 } |
442 | 454 |
443 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( | 455 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( |
444 const std::string& path, | 456 const std::string& path, |
445 const std::string& key, | 457 const std::string& key, |
446 const base::Value& value) { | 458 const base::Value& value) { |
447 listener_->UpdateDeviceProperty(path, key, value); | 459 listener_->UpdateDeviceProperty(path, key, value); |
448 } | 460 } |
449 | 461 |
450 } // namespace internal | 462 } // namespace internal |
451 } // namespace chromeos | 463 } // namespace chromeos |
OLD | NEW |