| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 void ShillPropertyHandler::ManagerPropertiesCallback( | 238 void ShillPropertyHandler::ManagerPropertiesCallback( |
| 239 DBusMethodCallStatus call_status, | 239 DBusMethodCallStatus call_status, |
| 240 const base::DictionaryValue& properties) { | 240 const base::DictionaryValue& properties) { |
| 241 if (call_status != DBUS_METHOD_CALL_SUCCESS) { | 241 if (call_status != DBUS_METHOD_CALL_SUCCESS) { |
| 242 NET_LOG_ERROR("ManagerPropertiesCallback", | 242 NET_LOG_ERROR("ManagerPropertiesCallback", |
| 243 base::StringPrintf("Failed: %d", call_status)); | 243 base::StringPrintf("Failed: %d", call_status)); |
| 244 return; | 244 return; |
| 245 } | 245 } |
| 246 NET_LOG_EVENT("ManagerPropertiesCallback", "Success"); | 246 NET_LOG_EVENT("ManagerPropertiesCallback", "Success"); |
| 247 const base::Value* update_service_value = NULL; | |
| 248 const base::Value* update_service_complete_value = NULL; | |
| 249 for (base::DictionaryValue::Iterator iter(properties); | 247 for (base::DictionaryValue::Iterator iter(properties); |
| 250 !iter.IsAtEnd(); iter.Advance()) { | 248 !iter.IsAtEnd(); iter.Advance()) { |
| 251 // Defer updating Services until all other properties have been updated. | 249 ManagerPropertyChanged(iter.key(), iter.value()); |
| 252 if (iter.key() == shill::kServicesProperty) | |
| 253 update_service_value = &iter.value(); | |
| 254 else if (iter.key() == shill::kServiceCompleteListProperty) | |
| 255 update_service_complete_value = &iter.value(); | |
| 256 else | |
| 257 ManagerPropertyChanged(iter.key(), iter.value()); | |
| 258 } | 250 } |
| 259 // Update Service lists after other Manager properties. Update | |
| 260 // ServiceCompleteList first so that Services (visible) entries already exist. | |
| 261 if (update_service_complete_value) { | |
| 262 ManagerPropertyChanged(shill::kServiceCompleteListProperty, | |
| 263 *update_service_complete_value); | |
| 264 } | |
| 265 if (update_service_value) | |
| 266 ManagerPropertyChanged(shill::kServicesProperty, *update_service_value); | |
| 267 | 251 |
| 268 CheckPendingStateListUpdates(""); | 252 CheckPendingStateListUpdates(""); |
| 269 } | 253 } |
| 270 | 254 |
| 271 void ShillPropertyHandler::CheckPendingStateListUpdates( | 255 void ShillPropertyHandler::CheckPendingStateListUpdates( |
| 272 const std::string& key) { | 256 const std::string& key) { |
| 273 // Once there are no pending updates, signal the state list changed callbacks. | 257 // Once there are no pending updates, signal the state list changed callbacks. |
| 274 if ((key.empty() || key == shill::kServiceCompleteListProperty) && | 258 if ((key.empty() || key == shill::kServiceCompleteListProperty) && |
| 275 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) { | 259 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) { |
| 276 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); | 260 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); |
| 277 } | 261 } |
| 278 if ((key.empty() || key == shill::kDevicesProperty) && | 262 if ((key.empty() || key == shill::kDevicesProperty) && |
| 279 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { | 263 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { |
| 280 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); | 264 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); |
| 281 } | 265 } |
| 282 // For emitted Services updates only, we also need to signal that the list | |
| 283 // changed in case the visibility changed. | |
| 284 if (key == shill::kServicesProperty && | |
| 285 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) { | |
| 286 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); | |
| 287 } | |
| 288 } | 266 } |
| 289 | 267 |
| 290 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, | 268 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, |
| 291 const base::Value& value) { | 269 const base::Value& value) { |
| 292 NET_LOG_DEBUG("ManagerPropertyChanged", key); | 270 NET_LOG_DEBUG("ManagerPropertyChanged", key); |
| 293 if (key == shill::kDefaultServiceProperty) { | 271 if (key == shill::kDefaultServiceProperty) { |
| 294 std::string service_path; | 272 std::string service_path; |
| 295 value.GetAsString(&service_path); | 273 value.GetAsString(&service_path); |
| 296 listener_->DefaultNetworkServiceChanged(service_path); | 274 listener_->DefaultNetworkServiceChanged(service_path); |
| 297 } else if (key == shill::kServicesProperty) { | 275 } else if (key == shill::kServicesProperty) { |
| 298 const base::ListValue* vlist = GetListValue(key, value); | 276 const base::ListValue* vlist = GetListValue(key, value); |
| 299 if (vlist) { | 277 if (vlist) { |
| 300 // Update the visibility of networks in ServiceCompleteList. Note that | 278 // We only use the Services property to determine which networks we |
| 301 // this relies on Shill emitting changes to ServiceCompleteList before | 279 // observe. This is more convenient and reliable than waiting to revceive |
| 302 // changes to Services. TODO(stevenjb): Eliminate this and rely on | 280 // the Visible property of each kServiceCompleteList entry. We limit the |
| 303 // Service.Visible instead. | 281 // number of observed networks to kMaxObserved. |
| 304 listener_->UpdateVisibleNetworks(*vlist); | |
| 305 | |
| 306 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK, | |
| 307 // however that prevents us from receiving Strength updates from inactive | |
| 308 // networks. The overhead for observing all services is not unreasonable | |
| 309 // (and we limit the max number of observed services to kMaxObserved). | |
| 310 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist); | 282 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
| 311 } | 283 } |
| 312 } else if (key == shill::kServiceCompleteListProperty) { | 284 } else if (key == shill::kServiceCompleteListProperty) { |
| 313 const base::ListValue* vlist = GetListValue(key, value); | 285 const base::ListValue* vlist = GetListValue(key, value); |
| 314 if (vlist) { | 286 if (vlist) { |
| 315 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); | 287 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
| 316 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist); | 288 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
| 289 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
| 317 } | 290 } |
| 318 } else if (key == shill::kServiceWatchListProperty) { | |
| 319 // Currently we ignore the watch list. | |
| 320 } else if (key == shill::kDevicesProperty) { | 291 } else if (key == shill::kDevicesProperty) { |
| 321 const base::ListValue* vlist = GetListValue(key, value); | 292 const base::ListValue* vlist = GetListValue(key, value); |
| 322 if (vlist) { | 293 if (vlist) { |
| 323 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_DEVICE, *vlist); | 294 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_DEVICE, *vlist); |
| 324 UpdateProperties(ManagedState::MANAGED_TYPE_DEVICE, *vlist); | 295 UpdateProperties(ManagedState::MANAGED_TYPE_DEVICE, *vlist); |
| 325 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist); | 296 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist); |
| 326 } | 297 } |
| 327 } else if (key == shill::kAvailableTechnologiesProperty) { | 298 } else if (key == shill::kAvailableTechnologiesProperty) { |
| 328 const base::ListValue* vlist = GetListValue(key, value); | 299 const base::ListValue* vlist = GetListValue(key, value); |
| 329 if (vlist) | 300 if (vlist) |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 NET_LOG_ERROR("Failed to get IP Config properties", | 532 NET_LOG_ERROR("Failed to get IP Config properties", |
| 562 base::StringPrintf("%s: %d", path.c_str(), call_status)); | 533 base::StringPrintf("%s: %d", path.c_str(), call_status)); |
| 563 return; | 534 return; |
| 564 } | 535 } |
| 565 NET_LOG_EVENT("IP Config properties received", path); | 536 NET_LOG_EVENT("IP Config properties received", path); |
| 566 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); | 537 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); |
| 567 } | 538 } |
| 568 | 539 |
| 569 } // namespace internal | 540 } // namespace internal |
| 570 } // namespace chromeos | 541 } // namespace chromeos |
| OLD | NEW |