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

Side by Side Diff: chrome/browser/devtools/device/port_forwarding_controller.cc

Issue 2442953002: Remove stl_util's deletion function use from chrome/. (Closed)
Patch Set: fix Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/devtools/device/port_forwarding_controller.h" 5 #include "chrome/browser/devtools/device/port_forwarding_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 460 }
461 } else { 461 } else {
462 status.push_back(std::make_pair(rit->second->browser(), 462 status.push_back(std::make_pair(rit->second->browser(),
463 rit->second->GetPortStatusMap())); 463 rit->second->GetPortStatusMap()));
464 } 464 }
465 } 465 }
466 return status; 466 return status;
467 } 467 }
468 468
469 void PortForwardingController::CloseAllConnections() { 469 void PortForwardingController::CloseAllConnections() {
470 std::vector<Connection*> registry_copy;
471 Registry copy(registry_); 470 Registry copy(registry_);
472 base::STLDeleteValues(&copy); 471 for (auto& entry : copy)
472 delete entry.second;
Nico 2016/10/24 18:41:01 I don't understand why this is better than the lhs
Avi (use Gerrit) 2016/10/24 19:15:37 The existence of STLDelete* functions encourages p
Nico 2016/10/24 19:18:26 That's a good motivation, thanks.
473 } 473 }
474 474
475 void PortForwardingController::OnPrefsChange() { 475 void PortForwardingController::OnPrefsChange() {
476 forwarding_map_.clear(); 476 forwarding_map_.clear();
477 477
478 if (pref_service_->GetBoolean(prefs::kDevToolsPortForwardingEnabled)) { 478 if (pref_service_->GetBoolean(prefs::kDevToolsPortForwardingEnabled)) {
479 const base::DictionaryValue* dict = 479 const base::DictionaryValue* dict =
480 pref_service_->GetDictionary(prefs::kDevToolsPortForwardingConfig); 480 pref_service_->GetDictionary(prefs::kDevToolsPortForwardingConfig);
481 for (base::DictionaryValue::Iterator it(*dict); 481 for (base::DictionaryValue::Iterator it(*dict);
482 !it.IsAtEnd(); it.Advance()) { 482 !it.IsAtEnd(); it.Advance()) {
483 int port_num; 483 int port_num;
484 std::string location; 484 std::string location;
485 if (base::StringToInt(it.key(), &port_num) && 485 if (base::StringToInt(it.key(), &port_num) &&
486 dict->GetString(it.key(), &location)) 486 dict->GetString(it.key(), &location))
487 forwarding_map_[port_num] = location; 487 forwarding_map_[port_num] = location;
488 } 488 }
489 } 489 }
490 490
491 if (!forwarding_map_.empty()) 491 if (!forwarding_map_.empty())
492 UpdateConnections(); 492 UpdateConnections();
493 else 493 else
494 CloseAllConnections(); 494 CloseAllConnections();
495 } 495 }
496 496
497 void PortForwardingController::UpdateConnections() { 497 void PortForwardingController::UpdateConnections() {
498 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it) 498 for (Registry::iterator it = registry_.begin(); it != registry_.end(); ++it)
499 it->second->UpdateForwardingMap(forwarding_map_); 499 it->second->UpdateForwardingMap(forwarding_map_);
500 } 500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698