Chromium Code Reviews| 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 <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 const std::string& name, | 54 const std::string& name, |
| 55 const base::Value& value)> Handler; | 55 const base::Value& value)> Handler; |
| 56 | 56 |
| 57 ShillPropertyObserver(ManagedState::ManagedType type, | 57 ShillPropertyObserver(ManagedState::ManagedType type, |
| 58 const std::string& path, | 58 const std::string& path, |
| 59 const Handler& handler) | 59 const Handler& handler) |
| 60 : type_(type), | 60 : type_(type), |
| 61 path_(path), | 61 path_(path), |
| 62 handler_(handler) { | 62 handler_(handler) { |
| 63 if (type_ == ManagedState::MANAGED_TYPE_NETWORK) { | 63 if (type_ == ManagedState::MANAGED_TYPE_NETWORK) { |
| 64 DVLOG(2) << "ShillPropertyObserver: Network: " << path; | |
| 64 DBusThreadManager::Get()->GetShillServiceClient()-> | 65 DBusThreadManager::Get()->GetShillServiceClient()-> |
| 65 AddPropertyChangedObserver(dbus::ObjectPath(path_), this); | 66 AddPropertyChangedObserver(dbus::ObjectPath(path_), this); |
| 66 } else if (type_ == ManagedState::MANAGED_TYPE_DEVICE) { | 67 } else if (type_ == ManagedState::MANAGED_TYPE_DEVICE) { |
| 68 DVLOG(2) << "ShillPropertyObserver: Device: " << path; | |
| 67 DBusThreadManager::Get()->GetShillDeviceClient()-> | 69 DBusThreadManager::Get()->GetShillDeviceClient()-> |
| 68 AddPropertyChangedObserver(dbus::ObjectPath(path_), this); | 70 AddPropertyChangedObserver(dbus::ObjectPath(path_), this); |
| 69 } else { | 71 } else { |
| 70 NOTREACHED(); | 72 NOTREACHED(); |
| 71 } | 73 } |
| 72 } | 74 } |
| 73 | 75 |
| 74 virtual ~ShillPropertyObserver() { | 76 virtual ~ShillPropertyObserver() { |
| 75 if (type_ == ManagedState::MANAGED_TYPE_NETWORK) { | 77 if (type_ == ManagedState::MANAGED_TYPE_NETWORK) { |
| 76 DBusThreadManager::Get()->GetShillServiceClient()-> | 78 DBusThreadManager::Get()->GetShillServiceClient()-> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 base::Bind(&network_handler::ShillErrorCallbackFunction, | 201 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 200 "ConnectToBestServices Failed", | 202 "ConnectToBestServices Failed", |
| 201 "", network_handler::ErrorCallback())); | 203 "", network_handler::ErrorCallback())); |
| 202 } | 204 } |
| 203 | 205 |
| 204 void ShillPropertyHandler::RequestProperties(ManagedState::ManagedType type, | 206 void ShillPropertyHandler::RequestProperties(ManagedState::ManagedType type, |
| 205 const std::string& path) { | 207 const std::string& path) { |
| 206 if (pending_updates_[type].find(path) != pending_updates_[type].end()) | 208 if (pending_updates_[type].find(path) != pending_updates_[type].end()) |
| 207 return; // Update already requested. | 209 return; // Update already requested. |
| 208 | 210 |
| 209 NET_LOG_DEBUG("Request Properties", path); | 211 NET_LOG_DEBUG("Request Properties: " + ManagedState::TypeToString(type), |
| 212 path); | |
| 210 pending_updates_[type].insert(path); | 213 pending_updates_[type].insert(path); |
| 211 if (type == ManagedState::MANAGED_TYPE_NETWORK || | 214 if (type == ManagedState::MANAGED_TYPE_NETWORK || |
| 212 type == ManagedState::MANAGED_TYPE_FAVORITE) { | 215 type == ManagedState::MANAGED_TYPE_FAVORITE) { |
| 213 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( | 216 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( |
| 214 dbus::ObjectPath(path), | 217 dbus::ObjectPath(path), |
| 215 base::Bind(&ShillPropertyHandler::GetPropertiesCallback, | 218 base::Bind(&ShillPropertyHandler::GetPropertiesCallback, |
| 216 AsWeakPtr(), type, path)); | 219 AsWeakPtr(), type, path)); |
| 217 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { | 220 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { |
| 218 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( | 221 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( |
| 219 dbus::ObjectPath(path), | 222 dbus::ObjectPath(path), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE); | 285 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE); |
| 283 } | 286 } |
| 284 if ((key.empty() || key == shill::kDevicesProperty) && | 287 if ((key.empty() || key == shill::kDevicesProperty) && |
| 285 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { | 288 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { |
| 286 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); | 289 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); |
| 287 } | 290 } |
| 288 } | 291 } |
| 289 | 292 |
| 290 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, | 293 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, |
| 291 const base::Value& value) { | 294 const base::Value& value) { |
| 295 NET_LOG_DEBUG("ManagerPropertyChanged", key); | |
|
stevenjb
2014/05/28 22:47:22
This should be happening infrequently, i.e. it sho
| |
| 292 if (key == shill::kDefaultServiceProperty) { | 296 if (key == shill::kDefaultServiceProperty) { |
| 293 std::string service_path; | 297 std::string service_path; |
| 294 value.GetAsString(&service_path); | 298 value.GetAsString(&service_path); |
| 295 listener_->DefaultNetworkServiceChanged(service_path); | 299 listener_->DefaultNetworkServiceChanged(service_path); |
| 296 } else if (key == shill::kServicesProperty) { | 300 } else if (key == shill::kServicesProperty) { |
| 297 const base::ListValue* vlist = GetListValue(key, value); | 301 const base::ListValue* vlist = GetListValue(key, value); |
| 298 if (vlist) { | 302 if (vlist) { |
| 299 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); | 303 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
| 300 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist); | 304 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
| 301 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK, | 305 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 VLOG(2) << "Ignored Manager Property: " << key; | 343 VLOG(2) << "Ignored Manager Property: " << key; |
| 340 } | 344 } |
| 341 } | 345 } |
| 342 | 346 |
| 343 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, | 347 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, |
| 344 const base::ListValue& entries) { | 348 const base::ListValue& entries) { |
| 345 std::set<std::string>& requested_updates = requested_updates_[type]; | 349 std::set<std::string>& requested_updates = requested_updates_[type]; |
| 346 std::set<std::string>& requested_service_updates = | 350 std::set<std::string>& requested_service_updates = |
| 347 requested_updates_[ManagedState::MANAGED_TYPE_NETWORK]; // For favorites | 351 requested_updates_[ManagedState::MANAGED_TYPE_NETWORK]; // For favorites |
| 348 std::set<std::string> new_requested_updates; | 352 std::set<std::string> new_requested_updates; |
| 349 NET_LOG_DEBUG( | 353 NET_LOG_DEBUG("UpdateProperties: " + ManagedState::TypeToString(type), |
| 350 base::StringPrintf("UpdateProperties: %" PRIuS, entries.GetSize()), | 354 base::StringPrintf("%" PRIuS, entries.GetSize())); |
| 351 ManagedState::TypeToString(type)); | |
| 352 for (base::ListValue::const_iterator iter = entries.begin(); | 355 for (base::ListValue::const_iterator iter = entries.begin(); |
| 353 iter != entries.end(); ++iter) { | 356 iter != entries.end(); ++iter) { |
| 354 std::string path; | 357 std::string path; |
| 355 (*iter)->GetAsString(&path); | 358 (*iter)->GetAsString(&path); |
| 356 if (path.empty()) | 359 if (path.empty()) |
| 357 continue; | 360 continue; |
| 358 // Only request properties once. Favorites that are visible will be updated | 361 // Only request properties once. Favorites that are visible will be updated |
| 359 // when the Network entry is updated. Since 'Services' is always processed | 362 // when the Network entry is updated. Since 'Services' is always processed |
| 360 // before ServiceCompleteList, only Favorites that are not visible will be | 363 // before ServiceCompleteList, only Favorites that are not visible will be |
| 361 // requested here, and GetPropertiesCallback() will only get called with | 364 // requested here, and GetPropertiesCallback() will only get called with |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 NET_LOG_ERROR("Failed to get IP Config properties", | 585 NET_LOG_ERROR("Failed to get IP Config properties", |
| 583 base::StringPrintf("%s: %d", path.c_str(), call_status)); | 586 base::StringPrintf("%s: %d", path.c_str(), call_status)); |
| 584 return; | 587 return; |
| 585 } | 588 } |
| 586 NET_LOG_EVENT("IP Config properties received", path); | 589 NET_LOG_EVENT("IP Config properties received", path); |
| 587 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); | 590 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); |
| 588 } | 591 } |
| 589 | 592 |
| 590 } // namespace internal | 593 } // namespace internal |
| 591 } // namespace chromeos | 594 } // namespace chromeos |
| OLD | NEW |