Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chromeos/network/shill_property_handler.cc

Issue 289383004: Merge FavoriteState into NetworkState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 VLOG(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 VLOG(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 18 matching lines...) Expand all
95 Handler handler_; 97 Handler handler_;
96 98
97 DISALLOW_COPY_AND_ASSIGN(ShillPropertyObserver); 99 DISALLOW_COPY_AND_ASSIGN(ShillPropertyObserver);
98 }; 100 };
99 101
100 //------------------------------------------------------------------------------ 102 //------------------------------------------------------------------------------
101 // ShillPropertyHandler 103 // ShillPropertyHandler
102 104
103 ShillPropertyHandler::ShillPropertyHandler(Listener* listener) 105 ShillPropertyHandler::ShillPropertyHandler(Listener* listener)
104 : listener_(listener), 106 : listener_(listener),
105 shill_manager_(DBusThreadManager::Get()->GetShillManagerClient()) { 107 shill_manager_(DBusThreadManager::Get()->GetShillManagerClient()),
108 new_observed_networks_(0) {
106 } 109 }
107 110
108 ShillPropertyHandler::~ShillPropertyHandler() { 111 ShillPropertyHandler::~ShillPropertyHandler() {
109 // Delete network service observers. 112 // Delete network service observers.
110 STLDeleteContainerPairSecondPointers( 113 STLDeleteContainerPairSecondPointers(
111 observed_networks_.begin(), observed_networks_.end()); 114 observed_networks_.begin(), observed_networks_.end());
112 STLDeleteContainerPairSecondPointers( 115 STLDeleteContainerPairSecondPointers(
113 observed_devices_.begin(), observed_devices_.end()); 116 observed_devices_.begin(), observed_devices_.end());
114 CHECK(shill_manager_ == DBusThreadManager::Get()->GetShillManagerClient()); 117 CHECK(shill_manager_ == DBusThreadManager::Get()->GetShillManagerClient());
115 shill_manager_->RemovePropertyChangedObserver(this); 118 shill_manager_->RemovePropertyChangedObserver(this);
116 } 119 }
117 120
118 void ShillPropertyHandler::Init() { 121 void ShillPropertyHandler::Init() {
119 UpdateManagerProperties(); 122 UpdateManagerProperties();
120 shill_manager_->AddPropertyChangedObserver(this); 123 shill_manager_->AddPropertyChangedObserver(this);
121 } 124 }
122 125
123 void ShillPropertyHandler::UpdateManagerProperties() { 126 void ShillPropertyHandler::UpdateManagerProperties() {
124 NET_LOG_EVENT("UpdateManagerProperties", ""); 127 NET_LOG_EVENT("UpdateManagerProperties", "");
128 new_observed_networks_ = 0;
125 shill_manager_->GetProperties( 129 shill_manager_->GetProperties(
126 base::Bind(&ShillPropertyHandler::ManagerPropertiesCallback, 130 base::Bind(&ShillPropertyHandler::ManagerPropertiesCallback,
127 AsWeakPtr())); 131 AsWeakPtr()));
128 } 132 }
129 133
130 bool ShillPropertyHandler::IsTechnologyAvailable( 134 bool ShillPropertyHandler::IsTechnologyAvailable(
131 const std::string& technology) const { 135 const std::string& technology) const {
132 return available_technologies_.count(technology) != 0; 136 return available_technologies_.count(technology) != 0;
133 } 137 }
134 138
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 base::Bind(&network_handler::ShillErrorCallbackFunction, 203 base::Bind(&network_handler::ShillErrorCallbackFunction,
200 "ConnectToBestServices Failed", 204 "ConnectToBestServices Failed",
201 "", network_handler::ErrorCallback())); 205 "", network_handler::ErrorCallback()));
202 } 206 }
203 207
204 void ShillPropertyHandler::RequestProperties(ManagedState::ManagedType type, 208 void ShillPropertyHandler::RequestProperties(ManagedState::ManagedType type,
205 const std::string& path) { 209 const std::string& path) {
206 if (pending_updates_[type].find(path) != pending_updates_[type].end()) 210 if (pending_updates_[type].find(path) != pending_updates_[type].end())
207 return; // Update already requested. 211 return; // Update already requested.
208 212
209 NET_LOG_DEBUG("Request Properties", path); 213 NET_LOG_DEBUG("Request Properties: " + ManagedState::TypeToString(type),
214 path);
210 pending_updates_[type].insert(path); 215 pending_updates_[type].insert(path);
211 if (type == ManagedState::MANAGED_TYPE_NETWORK || 216 if (type == ManagedState::MANAGED_TYPE_NETWORK) {
212 type == ManagedState::MANAGED_TYPE_FAVORITE) {
213 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties( 217 DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
214 dbus::ObjectPath(path), 218 dbus::ObjectPath(path),
215 base::Bind(&ShillPropertyHandler::GetPropertiesCallback, 219 base::Bind(&ShillPropertyHandler::GetPropertiesCallback,
216 AsWeakPtr(), type, path)); 220 AsWeakPtr(), type, path));
217 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { 221 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) {
218 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties( 222 DBusThreadManager::Get()->GetShillDeviceClient()->GetProperties(
219 dbus::ObjectPath(path), 223 dbus::ObjectPath(path),
220 base::Bind(&ShillPropertyHandler::GetPropertiesCallback, 224 base::Bind(&ShillPropertyHandler::GetPropertiesCallback,
221 AsWeakPtr(), type, path)); 225 AsWeakPtr(), type, path));
222 } else { 226 } else {
(...skipping 24 matching lines...) Expand all
247 for (base::DictionaryValue::Iterator iter(properties); 251 for (base::DictionaryValue::Iterator iter(properties);
248 !iter.IsAtEnd(); iter.Advance()) { 252 !iter.IsAtEnd(); iter.Advance()) {
249 // Defer updating Services until all other properties have been updated. 253 // Defer updating Services until all other properties have been updated.
250 if (iter.key() == shill::kServicesProperty) 254 if (iter.key() == shill::kServicesProperty)
251 update_service_value = &iter.value(); 255 update_service_value = &iter.value();
252 else if (iter.key() == shill::kServiceCompleteListProperty) 256 else if (iter.key() == shill::kServiceCompleteListProperty)
253 update_service_complete_value = &iter.value(); 257 update_service_complete_value = &iter.value();
254 else 258 else
255 ManagerPropertyChanged(iter.key(), iter.value()); 259 ManagerPropertyChanged(iter.key(), iter.value());
256 } 260 }
257 // Update Services which can safely assume other properties have been set. 261 // Update Service lists after other Manager properties. Update
258 if (update_service_value) 262 // ServiceCompleteList first so that Services (visible) entries already exist.
259 ManagerPropertyChanged(shill::kServicesProperty, *update_service_value);
260 // Update ServiceCompleteList which skips entries that have already been
261 // requested for Services.
262 if (update_service_complete_value) { 263 if (update_service_complete_value) {
263 ManagerPropertyChanged(shill::kServiceCompleteListProperty, 264 ManagerPropertyChanged(shill::kServiceCompleteListProperty,
264 *update_service_complete_value); 265 *update_service_complete_value);
265 } 266 }
267 if (update_service_value)
268 ManagerPropertyChanged(shill::kServicesProperty, *update_service_value);
266 269
267 CheckPendingStateListUpdates(""); 270 CheckPendingStateListUpdates("");
268 } 271 }
269 272
270 void ShillPropertyHandler::CheckPendingStateListUpdates( 273 void ShillPropertyHandler::CheckPendingStateListUpdates(
271 const std::string& key) { 274 const std::string& key) {
272 // Once there are no pending updates, signal the state list changed callbacks. 275 // Once there are no pending updates, signal the state list changed callbacks.
273 if ((key.empty() || key == shill::kServicesProperty) && 276 if ((key.empty() || key == shill::kServiceCompleteListProperty) &&
274 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) { 277 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) {
275 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); 278 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK);
276 } 279 }
277 // Both Network update requests and Favorite update requests will affect
278 // the list of favorites, so wait for both to complete.
279 if ((key.empty() || key == shill::kServiceCompleteListProperty) &&
280 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0 &&
281 pending_updates_[ManagedState::MANAGED_TYPE_FAVORITE].size() == 0) {
282 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE);
283 }
284 if ((key.empty() || key == shill::kDevicesProperty) && 280 if ((key.empty() || key == shill::kDevicesProperty) &&
285 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { 281 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) {
286 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); 282 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE);
287 } 283 }
284 // If we have added new observed (visible) networks, request an update, since
285 // Shill does not push changes to ServiceCompleteList.
286 if (key == shill::kServicesProperty && new_observed_networks_ > 0)
287 UpdateManagerProperties(); // clears new_observed_networks_
288 } 288 }
289 289
290 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, 290 void ShillPropertyHandler::ManagerPropertyChanged(const std::string& key,
291 const base::Value& value) { 291 const base::Value& value) {
292 NET_LOG_DEBUG("ManagerPropertyChanged", key);
292 if (key == shill::kDefaultServiceProperty) { 293 if (key == shill::kDefaultServiceProperty) {
293 std::string service_path; 294 std::string service_path;
294 value.GetAsString(&service_path); 295 value.GetAsString(&service_path);
295 listener_->DefaultNetworkServiceChanged(service_path); 296 listener_->DefaultNetworkServiceChanged(service_path);
296 } else if (key == shill::kServicesProperty) { 297 } else if (key == shill::kServicesProperty) {
297 const base::ListValue* vlist = GetListValue(key, value); 298 const base::ListValue* vlist = GetListValue(key, value);
298 if (vlist) { 299 if (vlist) {
299 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); 300 listener_->UpdateManagedNetworks(*vlist, false /* complete_list */);
300 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist); 301 // NOTE: Only call UpdateManagedNetworks for kServiceCompleteListProperty.
302 // This property only determines which networks are "visible", it does
303 // not affect the contents of the managed list.
304
301 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK, 305 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK,
302 // however that prevents us from receiving Strength updates from inactive 306 // however that prevents us from receiving Strength updates from inactive
303 // networks. The overhead for observing all services is not unreasonable 307 // networks. The overhead for observing all services is not unreasonable
304 // (and we limit the max number of observed services to kMaxObserved). 308 // (and we limit the max number of observed services to kMaxObserved).
305 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist); 309 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
306 } 310 }
307 } else if (key == shill::kServiceCompleteListProperty) { 311 } else if (key == shill::kServiceCompleteListProperty) {
308 const base::ListValue* vlist = GetListValue(key, value); 312 const base::ListValue* vlist = GetListValue(key, value);
309 if (vlist) { 313 if (vlist) {
310 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_FAVORITE, *vlist); 314 listener_->UpdateManagedNetworks(*vlist, true /* complete_list */);
311 UpdateProperties(ManagedState::MANAGED_TYPE_FAVORITE, *vlist); 315 UpdateProperties(ManagedState::MANAGED_TYPE_NETWORK, *vlist);
312 } 316 }
317 } else if (key == shill::kServiceWatchListProperty) {
318 // Currently we ignore the watch list.
313 } else if (key == shill::kDevicesProperty) { 319 } else if (key == shill::kDevicesProperty) {
314 const base::ListValue* vlist = GetListValue(key, value); 320 const base::ListValue* vlist = GetListValue(key, value);
315 if (vlist) { 321 if (vlist) {
316 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_DEVICE, *vlist); 322 listener_->UpdateManagedDevices(*vlist);
317 UpdateProperties(ManagedState::MANAGED_TYPE_DEVICE, *vlist); 323 UpdateProperties(ManagedState::MANAGED_TYPE_DEVICE, *vlist);
318 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist); 324 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist);
319 } 325 }
320 } else if (key == shill::kAvailableTechnologiesProperty) { 326 } else if (key == shill::kAvailableTechnologiesProperty) {
321 const base::ListValue* vlist = GetListValue(key, value); 327 const base::ListValue* vlist = GetListValue(key, value);
322 if (vlist) 328 if (vlist)
323 UpdateAvailableTechnologies(*vlist); 329 UpdateAvailableTechnologies(*vlist);
324 } else if (key == shill::kEnabledTechnologiesProperty) { 330 } else if (key == shill::kEnabledTechnologiesProperty) {
325 const base::ListValue* vlist = GetListValue(key, value); 331 const base::ListValue* vlist = GetListValue(key, value);
326 if (vlist) 332 if (vlist)
327 UpdateEnabledTechnologies(*vlist); 333 UpdateEnabledTechnologies(*vlist);
328 } else if (key == shill::kUninitializedTechnologiesProperty) { 334 } else if (key == shill::kUninitializedTechnologiesProperty) {
329 const base::ListValue* vlist = GetListValue(key, value); 335 const base::ListValue* vlist = GetListValue(key, value);
330 if (vlist) 336 if (vlist)
331 UpdateUninitializedTechnologies(*vlist); 337 UpdateUninitializedTechnologies(*vlist);
332 } else if (key == shill::kProfilesProperty) { 338 } else if (key == shill::kProfilesProperty) {
333 listener_->ProfileListChanged(); 339 listener_->ProfileListChanged();
334 } else if (key == shill::kCheckPortalListProperty) { 340 } else if (key == shill::kCheckPortalListProperty) {
335 std::string check_portal_list; 341 std::string check_portal_list;
336 if (value.GetAsString(&check_portal_list)) 342 if (value.GetAsString(&check_portal_list))
337 listener_->CheckPortalListChanged(check_portal_list); 343 listener_->CheckPortalListChanged(check_portal_list);
338 } else { 344 } else {
339 VLOG(2) << "Ignored Manager Property: " << key; 345 VLOG(2) << "Ignored Manager Property: " << key;
340 } 346 }
341 } 347 }
342 348
343 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type, 349 void ShillPropertyHandler::UpdateProperties(ManagedState::ManagedType type,
344 const base::ListValue& entries) { 350 const base::ListValue& entries) {
345 std::set<std::string>& requested_updates = requested_updates_[type]; 351 std::set<std::string>& requested_updates = requested_updates_[type];
346 std::set<std::string>& requested_service_updates =
347 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
359 // when the Network entry is updated. Since 'Services' is always processed
360 // before ServiceCompleteList, only Favorites that are not visible will be
361 // requested here, and GetPropertiesCallback() will only get called with
362 // type == FAVORITE for non-visible Favorites.
363 if (type == ManagedState::MANAGED_TYPE_FAVORITE &&
364 requested_service_updates.count(path) > 0) {
365 continue;
366 }
367 361
368 // We add a special case for devices here to work around an issue in shill 362 // We add a special case for devices here to work around an issue in shill
369 // that prevents it from sending property changed signals for cellular 363 // that prevents it from sending property changed signals for cellular
370 // devices (see crbug.com/321854). 364 // devices (see crbug.com/321854).
371 if (type == ManagedState::MANAGED_TYPE_DEVICE || 365 if (type == ManagedState::MANAGED_TYPE_DEVICE ||
372 requested_updates.find(path) == requested_updates.end()) 366 requested_updates.find(path) == requested_updates.end()) {
373 RequestProperties(type, path); 367 RequestProperties(type, path);
368 }
374 new_requested_updates.insert(path); 369 new_requested_updates.insert(path);
375 } 370 }
376 requested_updates.swap(new_requested_updates); 371 requested_updates.swap(new_requested_updates);
377 } 372 }
378 373
379 void ShillPropertyHandler::UpdateObserved(ManagedState::ManagedType type, 374 void ShillPropertyHandler::UpdateObserved(ManagedState::ManagedType type,
380 const base::ListValue& entries) { 375 const base::ListValue& entries) {
381 DCHECK(type == ManagedState::MANAGED_TYPE_NETWORK ||
382 type == ManagedState::MANAGED_TYPE_DEVICE);
383 ShillPropertyObserverMap& observer_map = 376 ShillPropertyObserverMap& observer_map =
384 (type == ManagedState::MANAGED_TYPE_NETWORK) 377 (type == ManagedState::MANAGED_TYPE_NETWORK)
385 ? observed_networks_ : observed_devices_; 378 ? observed_networks_ : observed_devices_;
386 ShillPropertyObserverMap new_observed; 379 ShillPropertyObserverMap new_observed;
387 for (base::ListValue::const_iterator iter1 = entries.begin(); 380 for (base::ListValue::const_iterator iter1 = entries.begin();
388 iter1 != entries.end(); ++iter1) { 381 iter1 != entries.end(); ++iter1) {
389 std::string path; 382 std::string path;
390 (*iter1)->GetAsString(&path); 383 (*iter1)->GetAsString(&path);
391 if (path.empty()) 384 if (path.empty())
392 continue; 385 continue;
393 ShillPropertyObserverMap::iterator iter2 = observer_map.find(path); 386 ShillPropertyObserverMap::iterator iter2 = observer_map.find(path);
394 if (iter2 != observer_map.end()) { 387 if (iter2 != observer_map.end()) {
395 new_observed[path] = iter2->second; 388 new_observed[path] = iter2->second;
396 } else { 389 } else {
397 // Create an observer for future updates. 390 // Create an observer for future updates.
398 new_observed[path] = new ShillPropertyObserver( 391 new_observed[path] = new ShillPropertyObserver(
399 type, path, base::Bind( 392 type, path, base::Bind(
400 &ShillPropertyHandler::PropertyChangedCallback, AsWeakPtr())); 393 &ShillPropertyHandler::PropertyChangedCallback, AsWeakPtr()));
394 if (type == ManagedState::MANAGED_TYPE_NETWORK)
395 ++new_observed_networks_;
401 } 396 }
402 observer_map.erase(path); 397 observer_map.erase(path);
403 // Limit the number of observed services. 398 // Limit the number of observed services.
404 if (new_observed.size() >= kMaxObserved) 399 if (new_observed.size() >= kMaxObserved)
405 break; 400 break;
406 } 401 }
407 // Delete network service observers still in observer_map. 402 // Delete network service observers still in observer_map.
408 for (ShillPropertyObserverMap::iterator iter = observer_map.begin(); 403 for (ShillPropertyObserverMap::iterator iter = observer_map.begin();
409 iter != observer_map.end(); ++iter) { 404 iter != observer_map.end(); ++iter) {
410 delete iter->second; 405 delete iter->second;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 NET_LOG_DEBUG("GetPropertiesCallback: " + ManagedState::TypeToString(type), 476 NET_LOG_DEBUG("GetPropertiesCallback: " + ManagedState::TypeToString(type),
482 path); 477 path);
483 pending_updates_[type].erase(path); 478 pending_updates_[type].erase(path);
484 if (call_status != DBUS_METHOD_CALL_SUCCESS) { 479 if (call_status != DBUS_METHOD_CALL_SUCCESS) {
485 // The shill service no longer exists. This can happen when a network 480 // The shill service no longer exists. This can happen when a network
486 // has been removed. 481 // has been removed.
487 NET_LOG_DEBUG("Failed to get properties", 482 NET_LOG_DEBUG("Failed to get properties",
488 base::StringPrintf("%s: %d", path.c_str(), call_status)); 483 base::StringPrintf("%s: %d", path.c_str(), call_status));
489 return; 484 return;
490 } 485 }
491 // Update Favorite properties for networks in the Services list. Call this
492 // for all networks, regardless of whether or not Profile is set, because
493 // we track all networks in the Favorites list (even if they aren't saved
494 // in a Profile). See notes in UpdateProperties() and favorite_state.h.
495 if (type == ManagedState::MANAGED_TYPE_NETWORK) {
496 listener_->UpdateManagedStateProperties(
497 ManagedState::MANAGED_TYPE_FAVORITE, path, properties);
498 }
499 listener_->UpdateManagedStateProperties(type, path, properties); 486 listener_->UpdateManagedStateProperties(type, path, properties);
500 487
501 if (type == ManagedState::MANAGED_TYPE_NETWORK) { 488 if (type == ManagedState::MANAGED_TYPE_NETWORK) {
502 // Request IPConfig properties. 489 // Request IPConfig properties.
503 const base::Value* value; 490 const base::Value* value;
504 if (properties.GetWithoutPathExpansion(shill::kIPConfigProperty, &value)) 491 if (properties.GetWithoutPathExpansion(shill::kIPConfigProperty, &value))
505 RequestIPConfig(type, path, *value); 492 RequestIPConfig(type, path, *value);
506 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { 493 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) {
507 // Clear and request IPConfig properties for each entry in IPConfigs. 494 // Clear and request IPConfig properties for each entry in IPConfigs.
508 const base::Value* value; 495 const base::Value* value;
509 if (properties.GetWithoutPathExpansion(shill::kIPConfigsProperty, &value)) 496 if (properties.GetWithoutPathExpansion(shill::kIPConfigsProperty, &value))
510 RequestIPConfigsList(type, path, *value); 497 RequestIPConfigsList(type, path, *value);
511 } 498 }
512 499
513 // Notify the listener only when all updates for that type have completed. 500 // Notify the listener only when all updates for that type have completed.
514 if (pending_updates_[type].size() == 0) { 501 if (pending_updates_[type].size() == 0)
515 listener_->ManagedStateListChanged(type); 502 listener_->ManagedStateListChanged(type);
516 // Notify that Favorites have changed when notifying for Networks if there
517 // are no additional Favorite updates pending.
518 if (type == ManagedState::MANAGED_TYPE_NETWORK &&
519 pending_updates_[ManagedState::MANAGED_TYPE_FAVORITE].size() == 0) {
520 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_FAVORITE);
521 }
522 }
523 } 503 }
524 504
525 void ShillPropertyHandler::PropertyChangedCallback( 505 void ShillPropertyHandler::PropertyChangedCallback(
526 ManagedState::ManagedType type, 506 ManagedState::ManagedType type,
527 const std::string& path, 507 const std::string& path,
528 const std::string& key, 508 const std::string& key,
529 const base::Value& value) { 509 const base::Value& value) {
530 if (type == ManagedState::MANAGED_TYPE_NETWORK && 510 if (type == ManagedState::MANAGED_TYPE_NETWORK &&
531 key == shill::kIPConfigProperty) { 511 key == shill::kIPConfigProperty) {
532 RequestIPConfig(type, path, value); 512 RequestIPConfig(type, path, value);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 NET_LOG_ERROR("Failed to get IP Config properties", 562 NET_LOG_ERROR("Failed to get IP Config properties",
583 base::StringPrintf("%s: %d", path.c_str(), call_status)); 563 base::StringPrintf("%s: %d", path.c_str(), call_status));
584 return; 564 return;
585 } 565 }
586 NET_LOG_EVENT("IP Config properties received", path); 566 NET_LOG_EVENT("IP Config properties received", path);
587 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties); 567 listener_->UpdateIPConfigProperties(type, path, ip_config_path, properties);
588 } 568 }
589 569
590 } // namespace internal 570 } // namespace internal
591 } // namespace chromeos 571 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698