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; |
204 if (pending_updates_[type].find(path) != pending_updates_[type].end()) | 205 if (pending_updates_[type].find(path) != pending_updates_[type].end()) |
205 return; // Update already requested. | 206 return; // Update already requested. |
206 | 207 |
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 NET_LOG_DEBUG( | 347 VLOG(2) << "Update Properties: " << type << " Entries: " << entries.GetSize(); |
348 base::StringPrintf("UpdateProperties: %" PRIuS, entries.GetSize()), | |
349 ManagedState::TypeToString(type)); | |
350 for (base::ListValue::const_iterator iter = entries.begin(); | 348 for (base::ListValue::const_iterator iter = entries.begin(); |
351 iter != entries.end(); ++iter) { | 349 iter != entries.end(); ++iter) { |
352 std::string path; | 350 std::string path; |
353 (*iter)->GetAsString(&path); | 351 (*iter)->GetAsString(&path); |
354 if (path.empty()) | 352 if (path.empty()) |
355 continue; | 353 continue; |
356 if (type == ManagedState::MANAGED_TYPE_FAVORITE && | 354 if (type == ManagedState::MANAGED_TYPE_FAVORITE && |
357 requested_service_updates.count(path) > 0) | 355 requested_service_updates.count(path) > 0) |
358 continue; // Update already requested | 356 continue; // Update already requested |
359 | 357 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 "EnableTechnology Failed", | 458 "EnableTechnology Failed", |
461 technology, error_callback, | 459 technology, error_callback, |
462 dbus_error_name, dbus_error_message); | 460 dbus_error_name, dbus_error_message); |
463 } | 461 } |
464 | 462 |
465 void ShillPropertyHandler::GetPropertiesCallback( | 463 void ShillPropertyHandler::GetPropertiesCallback( |
466 ManagedState::ManagedType type, | 464 ManagedState::ManagedType type, |
467 const std::string& path, | 465 const std::string& path, |
468 DBusMethodCallStatus call_status, | 466 DBusMethodCallStatus call_status, |
469 const base::DictionaryValue& properties) { | 467 const base::DictionaryValue& properties) { |
470 NET_LOG_DEBUG("GetPropertiesCallback: " + ManagedState::TypeToString(type), | 468 VLOG(2) << "GetPropertiesCallback: " << type << " : " << path; |
471 path); | |
472 pending_updates_[type].erase(path); | 469 pending_updates_[type].erase(path); |
473 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 470 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
474 // The shill service no longer exists. This can happen when a network | 471 // The shill service no longer exists. This can happen when a network |
475 // has been removed. | 472 // has been removed. |
476 NET_LOG_DEBUG("Failed to get properties", | 473 NET_LOG_DEBUG("Failed to get properties", |
477 base::StringPrintf("%s: %d", path.c_str(), call_status)); | 474 base::StringPrintf("%s: %d", path.c_str(), call_status)); |
478 return; | 475 return; |
479 } | 476 } |
480 // Update Favorite properties for networks in the Services list. | 477 // Update Favorite properties for networks in the Services list. |
481 if (type == ManagedState::MANAGED_TYPE_NETWORK) { | 478 if (type == ManagedState::MANAGED_TYPE_NETWORK) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 576 |
580 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( | 577 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( |
581 const std::string& path, | 578 const std::string& path, |
582 const std::string& key, | 579 const std::string& key, |
583 const base::Value& value) { | 580 const base::Value& value) { |
584 listener_->UpdateDeviceProperty(path, key, value); | 581 listener_->UpdateDeviceProperty(path, key, value); |
585 } | 582 } |
586 | 583 |
587 } // namespace internal | 584 } // namespace internal |
588 } // namespace chromeos | 585 } // namespace chromeos |
OLD | NEW |