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

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

Issue 2229383003: chromeos: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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
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 <stddef.h> 7 #include <stddef.h>
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 "ethernet,wifi,cellular"; 68 "ethernet,wifi,cellular";
69 69
70 NetworkStateHandler::NetworkStateHandler() {} 70 NetworkStateHandler::NetworkStateHandler() {}
71 71
72 NetworkStateHandler::~NetworkStateHandler() { 72 NetworkStateHandler::~NetworkStateHandler() {
73 // Normally Shutdown() will get called in ~NetworkHandler, however unit 73 // Normally Shutdown() will get called in ~NetworkHandler, however unit
74 // tests do not use that class so this needs to call Shutdown when we 74 // tests do not use that class so this needs to call Shutdown when we
75 // destry the class. 75 // destry the class.
76 if (!did_shutdown_) 76 if (!did_shutdown_)
77 Shutdown(); 77 Shutdown();
78 STLDeleteContainerPointers(network_list_.begin(), network_list_.end()); 78 base::STLDeleteContainerPointers(network_list_.begin(), network_list_.end());
79 STLDeleteContainerPointers(device_list_.begin(), device_list_.end()); 79 base::STLDeleteContainerPointers(device_list_.begin(), device_list_.end());
80 } 80 }
81 81
82 void NetworkStateHandler::Shutdown() { 82 void NetworkStateHandler::Shutdown() {
83 DCHECK(!did_shutdown_); 83 DCHECK(!did_shutdown_);
84 did_shutdown_ = true; 84 did_shutdown_ = true;
85 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, OnShuttingDown()); 85 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, OnShuttingDown());
86 } 86 }
87 87
88 void NetworkStateHandler::InitShillPropertyHandler() { 88 void NetworkStateHandler::InitShillPropertyHandler() {
89 shill_property_handler_.reset(new internal::ShillPropertyHandler(this)); 89 shill_property_handler_.reset(new internal::ShillPropertyHandler(this));
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 ManagedStateList* managed_list = GetManagedList(type); 457 ManagedStateList* managed_list = GetManagedList(type);
458 NET_LOG_DEBUG("UpdateManagedList: " + ManagedState::TypeToString(type), 458 NET_LOG_DEBUG("UpdateManagedList: " + ManagedState::TypeToString(type),
459 base::StringPrintf("%" PRIuS, entries.GetSize())); 459 base::StringPrintf("%" PRIuS, entries.GetSize()));
460 // Create a map of existing entries. Assumes all entries in |managed_list| 460 // Create a map of existing entries. Assumes all entries in |managed_list|
461 // are unique. 461 // are unique.
462 typedef std::map<std::string, ManagedState*> ManagedMap; 462 typedef std::map<std::string, ManagedState*> ManagedMap;
463 ManagedMap managed_map; 463 ManagedMap managed_map;
464 for (ManagedStateList::iterator iter = managed_list->begin(); 464 for (ManagedStateList::iterator iter = managed_list->begin();
465 iter != managed_list->end(); ++iter) { 465 iter != managed_list->end(); ++iter) {
466 ManagedState* managed = *iter; 466 ManagedState* managed = *iter;
467 DCHECK(!ContainsKey(managed_map, managed->path())); 467 DCHECK(!base::ContainsKey(managed_map, managed->path()));
468 managed_map[managed->path()] = managed; 468 managed_map[managed->path()] = managed;
469 } 469 }
470 // Clear the list (pointers are temporarily owned by managed_map). 470 // Clear the list (pointers are temporarily owned by managed_map).
471 managed_list->clear(); 471 managed_list->clear();
472 // Updates managed_list and request updates for new entries. 472 // Updates managed_list and request updates for new entries.
473 std::set<std::string> list_entries; 473 std::set<std::string> list_entries;
474 for (base::ListValue::const_iterator iter = entries.begin(); 474 for (base::ListValue::const_iterator iter = entries.begin();
475 iter != entries.end(); ++iter) { 475 iter != entries.end(); ++iter) {
476 std::string path; 476 std::string path;
477 (*iter)->GetAsString(&path); 477 (*iter)->GetAsString(&path);
478 if (path.empty() || path == shill::kFlimflamServicePath) { 478 if (path.empty() || path == shill::kFlimflamServicePath) {
479 NET_LOG_ERROR(base::StringPrintf("Bad path in list:%d", type), path); 479 NET_LOG_ERROR(base::StringPrintf("Bad path in list:%d", type), path);
480 continue; 480 continue;
481 } 481 }
482 ManagedMap::iterator found = managed_map.find(path); 482 ManagedMap::iterator found = managed_map.find(path);
483 if (found == managed_map.end()) { 483 if (found == managed_map.end()) {
484 if (list_entries.count(path) != 0) { 484 if (list_entries.count(path) != 0) {
485 NET_LOG_ERROR("Duplicate entry in list", path); 485 NET_LOG_ERROR("Duplicate entry in list", path);
486 continue; 486 continue;
487 } 487 }
488 ManagedState* managed = ManagedState::Create(type, path); 488 ManagedState* managed = ManagedState::Create(type, path);
489 managed_list->push_back(managed); 489 managed_list->push_back(managed);
490 } else { 490 } else {
491 managed_list->push_back(found->second); 491 managed_list->push_back(found->second);
492 managed_map.erase(found); 492 managed_map.erase(found);
493 } 493 }
494 list_entries.insert(path); 494 list_entries.insert(path);
495 } 495 }
496 // Delete any remaining entries in managed_map. 496 // Delete any remaining entries in managed_map.
497 STLDeleteContainerPairSecondPointers(managed_map.begin(), managed_map.end()); 497 base::STLDeleteContainerPairSecondPointers(managed_map.begin(),
498 managed_map.end());
498 } 499 }
499 500
500 void NetworkStateHandler::ProfileListChanged() { 501 void NetworkStateHandler::ProfileListChanged() {
501 NET_LOG_EVENT("ProfileListChanged", "Re-Requesting Network Properties"); 502 NET_LOG_EVENT("ProfileListChanged", "Re-Requesting Network Properties");
502 for (ManagedStateList::iterator iter = network_list_.begin(); 503 for (ManagedStateList::iterator iter = network_list_.begin();
503 iter != network_list_.end(); ++iter) { 504 iter != network_list_.end(); ++iter) {
504 NetworkState* network = (*iter)->AsNetworkState(); 505 NetworkState* network = (*iter)->AsNetworkState();
505 DCHECK(network); 506 DCHECK(network);
506 shill_property_handler_->RequestProperties( 507 shill_property_handler_->RequestProperties(
507 ManagedState::MANAGED_TYPE_NETWORK, network->path()); 508 ManagedState::MANAGED_TYPE_NETWORK, network->path());
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 if (type.MatchesType(shill::kTypeBluetooth)) 1007 if (type.MatchesType(shill::kTypeBluetooth))
1007 technologies.push_back(new std::string(shill::kTypeBluetooth)); 1008 technologies.push_back(new std::string(shill::kTypeBluetooth));
1008 if (type.MatchesType(shill::kTypeVPN)) 1009 if (type.MatchesType(shill::kTypeVPN))
1009 technologies.push_back(new std::string(shill::kTypeVPN)); 1010 technologies.push_back(new std::string(shill::kTypeVPN));
1010 1011
1011 CHECK_GT(technologies.size(), 0ul); 1012 CHECK_GT(technologies.size(), 0ul);
1012 return technologies; 1013 return technologies;
1013 } 1014 }
1014 1015
1015 } // namespace chromeos 1016 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_configuration_handler_unittest.cc ('k') | chromeos/network/policy_applicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698