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

Unified Diff: chrome/browser/command_updater.cc

Issue 2318303002: Remove stl_util's STLDeleteContainerPairSecondPointers. (Closed)
Patch Set: fix Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/command_updater.h ('k') | chrome/browser/content_settings/local_shared_objects_container.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/command_updater.cc
diff --git a/chrome/browser/command_updater.cc b/chrome/browser/command_updater.cc
index 63e50305256ce60d4394d512aa5d74ed0973d66a..950a17e0a254cc5e9b4d798ccd039a2709d71b09 100644
--- a/chrome/browser/command_updater.cc
+++ b/chrome/browser/command_updater.cc
@@ -7,8 +7,8 @@
#include <algorithm>
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/observer_list.h"
-#include "base/stl_util.h"
#include "chrome/browser/command_observer.h"
#include "chrome/browser/command_updater_delegate.h"
@@ -25,8 +25,6 @@ CommandUpdater::CommandUpdater(CommandUpdaterDelegate* delegate)
}
CommandUpdater::~CommandUpdater() {
- base::STLDeleteContainerPairSecondPointers(commands_.begin(),
- commands_.end());
}
bool CommandUpdater::SupportsCommand(int id) const {
@@ -34,7 +32,7 @@ bool CommandUpdater::SupportsCommand(int id) const {
}
bool CommandUpdater::IsCommandEnabled(int id) const {
- const CommandMap::const_iterator command(commands_.find(id));
+ auto command = commands_.find(id);
if (command == commands_.end())
return false;
return command->second->enabled;
@@ -63,10 +61,8 @@ void CommandUpdater::RemoveCommandObserver(int id, CommandObserver* observer) {
}
void CommandUpdater::RemoveCommandObserver(CommandObserver* observer) {
- for (CommandMap::const_iterator it = commands_.begin();
- it != commands_.end();
- ++it) {
- Command* command = it->second;
+ for (const auto& command_pair : commands_) {
+ Command* command = command_pair.second.get();
if (command)
command->observers.RemoveObserver(observer);
}
@@ -84,9 +80,10 @@ void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) {
CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) {
bool supported = SupportsCommand(id);
if (supported)
- return commands_[id];
+ return commands_[id].get();
+
DCHECK(create);
- Command* command = new Command;
- commands_[id] = command;
- return command;
+ std::unique_ptr<Command>& entry = commands_[id];
+ entry = base::MakeUnique<Command>();
+ return entry.get();
}
« no previous file with comments | « chrome/browser/command_updater.h ('k') | chrome/browser/content_settings/local_shared_objects_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698