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

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

Issue 212953010: Revert of Always list EthernetEAP as a Favorite for debugging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « chromeos/network/managed_state.cc ('k') | chromeos/network/shill_property_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/network_state_handler.h" 5 #include "chromeos/network/network_state_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/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 297
298 void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type, 298 void NetworkStateHandler::GetFavoriteListByType(const NetworkTypePattern& type,
299 FavoriteStateList* list) const { 299 FavoriteStateList* list) const {
300 DCHECK(list); 300 DCHECK(list);
301 FavoriteStateList result; 301 FavoriteStateList result;
302 list->clear(); 302 list->clear();
303 for (ManagedStateList::const_iterator iter = favorite_list_.begin(); 303 for (ManagedStateList::const_iterator iter = favorite_list_.begin();
304 iter != favorite_list_.end(); ++iter) { 304 iter != favorite_list_.end(); ++iter) {
305 const FavoriteState* favorite = (*iter)->AsFavoriteState(); 305 const FavoriteState* favorite = (*iter)->AsFavoriteState();
306 DCHECK(favorite); 306 DCHECK(favorite);
307 if (favorite->update_received() && favorite->IsFavorite() && 307 if (favorite->update_received() && favorite->is_favorite() &&
308 favorite->Matches(type)) { 308 favorite->Matches(type)) {
309 list->push_back(favorite); 309 list->push_back(favorite);
310 } 310 }
311 } 311 }
312 } 312 }
313 313
314 const FavoriteState* NetworkStateHandler::GetFavoriteState( 314 const FavoriteState* NetworkStateHandler::GetFavoriteState(
315 const std::string& service_path) const { 315 const std::string& service_path) const {
316 ManagedState* managed = 316 ManagedState* managed =
317 GetModifiableManagedState(&favorite_list_, service_path); 317 GetModifiableManagedState(&favorite_list_, service_path);
318 if (!managed) 318 if (!managed)
319 return NULL; 319 return NULL;
320 const FavoriteState* favorite = managed->AsFavoriteState(); 320 const FavoriteState* favorite = managed->AsFavoriteState();
321 DCHECK(favorite); 321 DCHECK(favorite);
322 if (!favorite->update_received() || !favorite->IsFavorite()) 322 if (!favorite->update_received() || !favorite->is_favorite())
323 return NULL; 323 return NULL;
324 return favorite; 324 return favorite;
325 } 325 }
326 326
327 void NetworkStateHandler::RequestScan() const { 327 void NetworkStateHandler::RequestScan() const {
328 NET_LOG_USER("RequestScan", ""); 328 NET_LOG_USER("RequestScan", "");
329 shill_property_handler_->RequestScan(); 329 shill_property_handler_->RequestScan();
330 } 330 }
331 331
332 void NetworkStateHandler::WaitForScan(const std::string& type, 332 void NetworkStateHandler::WaitForScan(const std::string& type,
(...skipping 15 matching lines...) Expand all
348 NetworkState* network = GetModifiableNetworkState(service_path); 348 NetworkState* network = GetModifiableNetworkState(service_path);
349 if (network) 349 if (network)
350 network->set_update_requested(true); 350 network->set_update_requested(true);
351 NET_LOG_EVENT("RequestUpdate", service_path); 351 NET_LOG_EVENT("RequestUpdate", service_path);
352 shill_property_handler_->RequestProperties( 352 shill_property_handler_->RequestProperties(
353 ManagedState::MANAGED_TYPE_NETWORK, service_path); 353 ManagedState::MANAGED_TYPE_NETWORK, service_path);
354 } 354 }
355 355
356 void NetworkStateHandler::RequestUpdateForAllNetworks() { 356 void NetworkStateHandler::RequestUpdateForAllNetworks() {
357 NET_LOG_EVENT("RequestUpdateForAllNetworks", ""); 357 NET_LOG_EVENT("RequestUpdateForAllNetworks", "");
358 // Use favorite_list_ so that all services, visible and non, are updated. 358 for (ManagedStateList::iterator iter = network_list_.begin();
359 for (ManagedStateList::iterator iter = favorite_list_.begin(); 359 iter != network_list_.end(); ++iter) {
360 iter != favorite_list_.end(); ++iter) {
361 ManagedState* network = *iter; 360 ManagedState* network = *iter;
362 network->set_update_requested(true); 361 network->set_update_requested(true);
363 shill_property_handler_->RequestProperties( 362 shill_property_handler_->RequestProperties(
364 ManagedState::MANAGED_TYPE_NETWORK, network->path()); 363 ManagedState::MANAGED_TYPE_NETWORK, network->path());
365 } 364 }
366 } 365 }
367 366
368 void NetworkStateHandler::ClearLastErrorForNetwork( 367 void NetworkStateHandler::ClearLastErrorForNetwork(
369 const std::string& service_path) { 368 const std::string& service_path) {
370 NetworkState* network = GetModifiableNetworkState(service_path); 369 NetworkState* network = GetModifiableNetworkState(service_path);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 managed_map.erase(found); 476 managed_map.erase(found);
478 } 477 }
479 list_entries.insert(path); 478 list_entries.insert(path);
480 } 479 }
481 // Delete any remaining entries in managed_map. 480 // Delete any remaining entries in managed_map.
482 STLDeleteContainerPairSecondPointers(managed_map.begin(), managed_map.end()); 481 STLDeleteContainerPairSecondPointers(managed_map.begin(), managed_map.end());
483 } 482 }
484 483
485 void NetworkStateHandler::ProfileListChanged() { 484 void NetworkStateHandler::ProfileListChanged() {
486 NET_LOG_EVENT("ProfileListChanged", "Re-Requesting Network Properties"); 485 NET_LOG_EVENT("ProfileListChanged", "Re-Requesting Network Properties");
487 for (ManagedStateList::iterator iter = favorite_list_.begin(); 486 for (ManagedStateList::iterator iter = network_list_.begin();
488 iter != favorite_list_.end(); ++iter) { 487 iter != network_list_.end(); ++iter) {
489 shill_property_handler_->RequestProperties( 488 shill_property_handler_->RequestProperties(
490 ManagedState::MANAGED_TYPE_NETWORK, (*iter)->path()); 489 ManagedState::MANAGED_TYPE_NETWORK, (*iter)->path());
491 } 490 }
492 } 491 }
493 492
494 void NetworkStateHandler::UpdateManagedStateProperties( 493 void NetworkStateHandler::UpdateManagedStateProperties(
495 ManagedState::ManagedType type, 494 ManagedState::ManagedType type,
496 const std::string& path, 495 const std::string& path,
497 const base::DictionaryValue& properties) { 496 const base::DictionaryValue& properties) {
498 ManagedStateList* managed_list = GetManagedList(type); 497 ManagedStateList* managed_list = GetManagedList(type);
499 ManagedState* managed = GetModifiableManagedState(managed_list, path); 498 ManagedState* managed = GetModifiableManagedState(managed_list, path);
500 if (!managed) { 499 if (!managed) {
501 if (type != ManagedState::MANAGED_TYPE_FAVORITE) { 500 if (type != ManagedState::MANAGED_TYPE_FAVORITE) {
502 // The network has been removed from the list of visible networks. 501 // The network has been removed from the list of visible networks.
503 NET_LOG_DEBUG("UpdateManagedStateProperties: Not found", path); 502 NET_LOG_DEBUG("UpdateManagedStateProperties: Not found", path);
504 return; 503 return;
505 } 504 }
506 // A Favorite may not have been created yet if it was added later (e.g. 505 // A Favorite may not have been created yet if it was added later (e.g.
507 // through ConfigureService) since ServiceCompleteList updates are not 506 // through ConfigureService) since ServiceCompleteList updates are not
508 // emitted. Add and update the state here. 507 // emitted. Add and update the state here.
509 managed = new FavoriteState(path); 508 managed = new FavoriteState(path);
510 managed_list->push_back(managed); 509 managed_list->push_back(managed);
511 } 510 }
512 managed->set_update_received(); 511 managed->set_update_received();
513 512
514 std::string desc = GetManagedStateLogType(managed) + " Properties Received"; 513 std::string desc = GetManagedStateLogType(managed) + " PropertiesReceived";
515 NET_LOG_DEBUG(desc, GetManagedStateLogName(managed)); 514 NET_LOG_DEBUG(desc, GetManagedStateLogName(managed));
516 515
517 if (type == ManagedState::MANAGED_TYPE_NETWORK) { 516 if (type == ManagedState::MANAGED_TYPE_NETWORK) {
518 UpdateNetworkStateProperties(managed->AsNetworkState(), properties); 517 UpdateNetworkStateProperties(managed->AsNetworkState(), properties);
519 } else { 518 } else {
520 // Device, Favorite 519 // Device, Favorite
521 for (base::DictionaryValue::Iterator iter(properties); 520 for (base::DictionaryValue::Iterator iter(properties);
522 !iter.IsAtEnd(); iter.Advance()) { 521 !iter.IsAtEnd(); iter.Advance()) {
523 managed->PropertyChanged(iter.key(), iter.value()); 522 managed->PropertyChanged(iter.key(), iter.value());
524 } 523 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 NET_LOG_DEBUG("FavoriteListChanged", 672 NET_LOG_DEBUG("FavoriteListChanged",
674 base::StringPrintf("Size:%" PRIuS, favorite_list_.size())); 673 base::StringPrintf("Size:%" PRIuS, favorite_list_.size()));
675 // The FavoriteState list only changes when the NetworkState list changes, 674 // The FavoriteState list only changes when the NetworkState list changes,
676 // so no need to signal observers here again. 675 // so no need to signal observers here again.
677 676
678 // Update UMA stats. 677 // Update UMA stats.
679 size_t shared = 0, unshared = 0; 678 size_t shared = 0, unshared = 0;
680 for (ManagedStateList::iterator iter = favorite_list_.begin(); 679 for (ManagedStateList::iterator iter = favorite_list_.begin();
681 iter != favorite_list_.end(); ++iter) { 680 iter != favorite_list_.end(); ++iter) {
682 FavoriteState* favorite = (*iter)->AsFavoriteState(); 681 FavoriteState* favorite = (*iter)->AsFavoriteState();
683 if (!favorite->IsFavorite()) 682 if (!favorite->is_favorite())
684 continue; 683 continue;
685 if (favorite->IsPrivate()) 684 if (favorite->IsPrivate())
686 ++unshared; 685 ++unshared;
687 else 686 else
688 ++shared; 687 ++shared;
689 } 688 }
690 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared); 689 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared);
691 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared); 690 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared);
692 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { 691 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) {
693 NotifyDeviceListChanged(); 692 NotifyDeviceListChanged();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 } 840 }
842 841
843 if (type.MatchesType(shill::kTypeCellular)) 842 if (type.MatchesType(shill::kTypeCellular))
844 return shill::kTypeCellular; 843 return shill::kTypeCellular;
845 844
846 NOTREACHED(); 845 NOTREACHED();
847 return std::string(); 846 return std::string();
848 } 847 }
849 848
850 } // namespace chromeos 849 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/managed_state.cc ('k') | chromeos/network/shill_property_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698