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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 NET_LOG_EVENT("ConnectToBestServices", ""); | 194 NET_LOG_EVENT("ConnectToBestServices", ""); |
195 shill_manager_->ConnectToBestServices( | 195 shill_manager_->ConnectToBestServices( |
196 base::Bind(&base::DoNothing), | 196 base::Bind(&base::DoNothing), |
197 base::Bind(&network_handler::ShillErrorCallbackFunction, | 197 base::Bind(&network_handler::ShillErrorCallbackFunction, |
198 "ConnectToBestServices Failed", | 198 "ConnectToBestServices Failed", |
199 "", network_handler::ErrorCallback())); | 199 "", network_handler::ErrorCallback())); |
200 } | 200 } |
201 | 201 |
202 void ShillPropertyHandler::RequestProperties(ManagedState::ManagedType type, | 202 void ShillPropertyHandler::RequestProperties(ManagedState::ManagedType type, |
203 const std::string& path) { | 203 const std::string& path) { |
204 VLOG(2) << "Request Properties: " << type << " : " << path; | |
205 if (pending_updates_[type].find(path) != pending_updates_[type].end()) | 204 if (pending_updates_[type].find(path) != pending_updates_[type].end()) |
206 return; // Update already requested. | 205 return; // Update already requested. |
207 | 206 |
| 207 NET_LOG_DEBUG("Request Properties", path); |
208 pending_updates_[type].insert(path); | 208 pending_updates_[type].insert(path); |
209 if (type == ManagedState::MANAGED_TYPE_NETWORK || | 209 if (type == ManagedState::MANAGED_TYPE_NETWORK || |
210 type == ManagedState::MANAGED_TYPE_FAVORITE) { | 210 type == ManagedState::MANAGED_TYPE_FAVORITE) { |
211 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( | 211 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( |
212 dbus::ObjectPath(path), | 212 dbus::ObjectPath(path), |
213 base::Bind(&ShillPropertyHandler::GetPropertiesCallback, | 213 base::Bind(&ShillPropertyHandler::GetPropertiesCallback, |
214 AsWeakPtr(), type, path)); | 214 AsWeakPtr(), type, path)); |
215 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { | 215 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { |
216 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( | 216 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( |
217 dbus::ObjectPath(path), | 217 dbus::ObjectPath(path), |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 VLOG(2) << "Ignored Manager Property: " << key; | 337 VLOG(2) << "Ignored Manager Property: " << key; |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, | 341 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, |
342 const base::ListValue& entries) { | 342 const base::ListValue& entries) { |
343 std::set<std::string>& requested_updates = requested_updates_[type]; | 343 std::set<std::string>& requested_updates = requested_updates_[type]; |
344 std::set<std::string>& requested_service_updates = | 344 std::set<std::string>& requested_service_updates = |
345 requested_updates_[ManagedState::MANAGED_TYPE_NETWORK]; // For favorites | 345 requested_updates_[ManagedState::MANAGED_TYPE_NETWORK]; // For favorites |
346 std::set<std::string> new_requested_updates; | 346 std::set<std::string> new_requested_updates; |
347 VLOG(2) << "Update Properties: " << type << " Entries: " << entries.GetSize(); | 347 NET_LOG_DEBUG( |
| 348 base::StringPrintf("UpdateProperties: %" PRIuS, entries.GetSize()), |
| 349 ManagedState::TypeToString(type)); |
348 for (base::ListValue::const_iterator iter = entries.begin(); | 350 for (base::ListValue::const_iterator iter = entries.begin(); |
349 iter != entries.end(); ++iter) { | 351 iter != entries.end(); ++iter) { |
350 std::string path; | 352 std::string path; |
351 (*iter)->GetAsString(&path); | 353 (*iter)->GetAsString(&path); |
352 if (path.empty()) | 354 if (path.empty()) |
353 continue; | 355 continue; |
354 if (type == ManagedState::MANAGED_TYPE_FAVORITE && | 356 if (type == ManagedState::MANAGED_TYPE_FAVORITE && |
355 requested_service_updates.count(path) > 0) | 357 requested_service_updates.count(path) > 0) |
356 continue; // Update already requested | 358 continue; // Update already requested |
357 | 359 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 "EnableTechnology Failed", | 460 "EnableTechnology Failed", |
459 technology, error_callback, | 461 technology, error_callback, |
460 dbus_error_name, dbus_error_message); | 462 dbus_error_name, dbus_error_message); |
461 } | 463 } |
462 | 464 |
463 void ShillPropertyHandler::GetPropertiesCallback( | 465 void ShillPropertyHandler::GetPropertiesCallback( |
464 ManagedState::ManagedType type, | 466 ManagedState::ManagedType type, |
465 const std::string& path, | 467 const std::string& path, |
466 DBusMethodCallStatus call_status, | 468 DBusMethodCallStatus call_status, |
467 const base::DictionaryValue& properties) { | 469 const base::DictionaryValue& properties) { |
468 VLOG(2) << "GetPropertiesCallback: " << type << " : " << path; | 470 NET_LOG_DEBUG("GetPropertiesCallback: " + ManagedState::TypeToString(type), |
| 471 path); |
469 pending_updates_[type].erase(path); | 472 pending_updates_[type].erase(path); |
470 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 473 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
471 // The shill service no longer exists. This can happen when a network | 474 // The shill service no longer exists. This can happen when a network |
472 // has been removed. | 475 // has been removed. |
473 NET_LOG_DEBUG("Failed to get properties", | 476 NET_LOG_DEBUG("Failed to get properties", |
474 base::StringPrintf("%s: %d", path.c_str(), call_status)); | 477 base::StringPrintf("%s: %d", path.c_str(), call_status)); |
475 return; | 478 return; |
476 } | 479 } |
477 // Update Favorite properties for networks in the Services list. | 480 // Update Favorite properties for networks in the Services list. |
478 if (type == ManagedState::MANAGED_TYPE_NETWORK) { | 481 if (type == ManagedState::MANAGED_TYPE_NETWORK) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 579 |
577 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( | 580 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( |
578 const std::string& path, | 581 const std::string& path, |
579 const std::string& key, | 582 const std::string& key, |
580 const base::Value& value) { | 583 const base::Value& value) { |
581 listener_->UpdateDeviceProperty(path, key, value); | 584 listener_->UpdateDeviceProperty(path, key, value); |
582 } | 585 } |
583 | 586 |
584 } // namespace internal | 587 } // namespace internal |
585 } // namespace chromeos | 588 } // namespace chromeos |
OLD | NEW |