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

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

Issue 210433002: Always list EthernetEAP as a Favorite for debugging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 9 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->is_favorite() && 307 if (favorite->update_received() && favorite->IsFavorite() &&
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->is_favorite()) 322 if (!favorite->update_received() || !favorite->IsFavorite())
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 for (ManagedStateList::iterator iter = network_list_.begin(); 358 // Use favorite_list_ so that all services, visible and non, are updated.
359 iter != network_list_.end(); ++iter) { 359 for (ManagedStateList::iterator iter = favorite_list_.begin();
360 iter != favorite_list_.end(); ++iter) {
360 ManagedState* network = *iter; 361 ManagedState* network = *iter;
361 network->set_update_requested(true); 362 network->set_update_requested(true);
362 shill_property_handler_->RequestProperties( 363 shill_property_handler_->RequestProperties(
363 ManagedState::MANAGED_TYPE_NETWORK, network->path()); 364 ManagedState::MANAGED_TYPE_NETWORK, network->path());
364 } 365 }
365 } 366 }
366 367
367 void NetworkStateHandler::ClearLastErrorForNetwork( 368 void NetworkStateHandler::ClearLastErrorForNetwork(
368 const std::string& service_path) { 369 const std::string& service_path) {
369 NetworkState* network = GetModifiableNetworkState(service_path); 370 NetworkState* network = GetModifiableNetworkState(service_path);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 managed_map.erase(found); 477 managed_map.erase(found);
477 } 478 }
478 list_entries.insert(path); 479 list_entries.insert(path);
479 } 480 }
480 // Delete any remaining entries in managed_map. 481 // Delete any remaining entries in managed_map.
481 STLDeleteContainerPairSecondPointers(managed_map.begin(), managed_map.end()); 482 STLDeleteContainerPairSecondPointers(managed_map.begin(), managed_map.end());
482 } 483 }
483 484
484 void NetworkStateHandler::ProfileListChanged() { 485 void NetworkStateHandler::ProfileListChanged() {
485 NET_LOG_EVENT("ProfileListChanged", "Re-Requesting Network Properties"); 486 NET_LOG_EVENT("ProfileListChanged", "Re-Requesting Network Properties");
486 for (ManagedStateList::iterator iter = network_list_.begin(); 487 for (ManagedStateList::iterator iter = favorite_list_.begin();
487 iter != network_list_.end(); ++iter) { 488 iter != favorite_list_.end(); ++iter) {
488 shill_property_handler_->RequestProperties( 489 shill_property_handler_->RequestProperties(
489 ManagedState::MANAGED_TYPE_NETWORK, (*iter)->path()); 490 ManagedState::MANAGED_TYPE_NETWORK, (*iter)->path());
490 } 491 }
491 } 492 }
492 493
493 void NetworkStateHandler::UpdateManagedStateProperties( 494 void NetworkStateHandler::UpdateManagedStateProperties(
494 ManagedState::ManagedType type, 495 ManagedState::ManagedType type,
495 const std::string& path, 496 const std::string& path,
496 const base::DictionaryValue& properties) { 497 const base::DictionaryValue& properties) {
497 ManagedStateList* managed_list = GetManagedList(type); 498 ManagedStateList* managed_list = GetManagedList(type);
498 ManagedState* managed = GetModifiableManagedState(managed_list, path); 499 ManagedState* managed = GetModifiableManagedState(managed_list, path);
499 if (!managed) { 500 if (!managed) {
500 if (type != ManagedState::MANAGED_TYPE_FAVORITE) { 501 if (type != ManagedState::MANAGED_TYPE_FAVORITE) {
501 // The network has been removed from the list of visible networks. 502 // The network has been removed from the list of visible networks.
502 NET_LOG_DEBUG("UpdateManagedStateProperties: Not found", path); 503 NET_LOG_DEBUG("UpdateManagedStateProperties: Not found", path);
503 return; 504 return;
504 } 505 }
505 // A Favorite may not have been created yet if it was added later (e.g. 506 // A Favorite may not have been created yet if it was added later (e.g.
506 // through ConfigureService) since ServiceCompleteList updates are not 507 // through ConfigureService) since ServiceCompleteList updates are not
507 // emitted. Add and update the state here. 508 // emitted. Add and update the state here.
508 managed = new FavoriteState(path); 509 managed = new FavoriteState(path);
509 managed_list->push_back(managed); 510 managed_list->push_back(managed);
510 } 511 }
511 managed->set_update_received(); 512 managed->set_update_received();
512 513
513 std::string desc = GetManagedStateLogType(managed) + " PropertiesReceived"; 514 std::string desc = GetManagedStateLogType(managed) + " Properties Received";
514 NET_LOG_DEBUG(desc, GetManagedStateLogName(managed)); 515 NET_LOG_DEBUG(desc, GetManagedStateLogName(managed));
515 516
516 if (type == ManagedState::MANAGED_TYPE_NETWORK) { 517 if (type == ManagedState::MANAGED_TYPE_NETWORK) {
517 UpdateNetworkStateProperties(managed->AsNetworkState(), properties); 518 UpdateNetworkStateProperties(managed->AsNetworkState(), properties);
518 } else { 519 } else {
519 // Device, Favorite 520 // Device, Favorite
520 for (base::DictionaryValue::Iterator iter(properties); 521 for (base::DictionaryValue::Iterator iter(properties);
521 !iter.IsAtEnd(); iter.Advance()) { 522 !iter.IsAtEnd(); iter.Advance()) {
522 managed->PropertyChanged(iter.key(), iter.value()); 523 managed->PropertyChanged(iter.key(), iter.value());
523 } 524 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 NET_LOG_DEBUG("FavoriteListChanged", 673 NET_LOG_DEBUG("FavoriteListChanged",
673 base::StringPrintf("Size:%" PRIuS, favorite_list_.size())); 674 base::StringPrintf("Size:%" PRIuS, favorite_list_.size()));
674 // The FavoriteState list only changes when the NetworkState list changes, 675 // The FavoriteState list only changes when the NetworkState list changes,
675 // so no need to signal observers here again. 676 // so no need to signal observers here again.
676 677
677 // Update UMA stats. 678 // Update UMA stats.
678 size_t shared = 0, unshared = 0; 679 size_t shared = 0, unshared = 0;
679 for (ManagedStateList::iterator iter = favorite_list_.begin(); 680 for (ManagedStateList::iterator iter = favorite_list_.begin();
680 iter != favorite_list_.end(); ++iter) { 681 iter != favorite_list_.end(); ++iter) {
681 FavoriteState* favorite = (*iter)->AsFavoriteState(); 682 FavoriteState* favorite = (*iter)->AsFavoriteState();
682 if (!favorite->is_favorite()) 683 if (!favorite->IsFavorite())
683 continue; 684 continue;
684 if (favorite->IsPrivate()) 685 if (favorite->IsPrivate())
685 ++unshared; 686 ++unshared;
686 else 687 else
687 ++shared; 688 ++shared;
688 } 689 }
689 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared); 690 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared);
690 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared); 691 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared);
691 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { 692 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) {
692 NotifyDeviceListChanged(); 693 NotifyDeviceListChanged();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 } 841 }
841 842
842 if (type.MatchesType(shill::kTypeCellular)) 843 if (type.MatchesType(shill::kTypeCellular))
843 return shill::kTypeCellular; 844 return shill::kTypeCellular;
844 845
845 NOTREACHED(); 846 NOTREACHED();
846 return std::string(); 847 return std::string();
847 } 848 }
848 849
849 } // namespace chromeos 850 } // 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