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

Side by Side Diff: chrome/browser/command_updater.cc

Issue 2426223002: Reduce FOR_EACH_OBSERVER macro usage in chrome/browser (Closed)
Patch Set: 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 (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 "chrome/browser/command_updater.h" 5 #include "chrome/browser/command_updater.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (command) 66 if (command)
67 command->observers.RemoveObserver(observer); 67 command->observers.RemoveObserver(observer);
68 } 68 }
69 } 69 }
70 70
71 void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) { 71 void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) {
72 Command* command = GetCommand(id, true); 72 Command* command = GetCommand(id, true);
73 if (command->enabled == enabled) 73 if (command->enabled == enabled)
74 return; // Nothing to do. 74 return; // Nothing to do.
75 command->enabled = enabled; 75 command->enabled = enabled;
76 FOR_EACH_OBSERVER(CommandObserver, command->observers, 76 for (auto& observer : command->observers)
77 EnabledStateChangedForCommand(id, enabled)); 77 observer.EnabledStateChangedForCommand(id, enabled);
78 } 78 }
79 79
80 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) { 80 CommandUpdater::Command* CommandUpdater::GetCommand(int id, bool create) {
81 bool supported = SupportsCommand(id); 81 bool supported = SupportsCommand(id);
82 if (supported) 82 if (supported)
83 return commands_[id].get(); 83 return commands_[id].get();
84 84
85 DCHECK(create); 85 DCHECK(create);
86 std::unique_ptr<Command>& entry = commands_[id]; 86 std::unique_ptr<Command>& entry = commands_[id];
87 entry = base::MakeUnique<Command>(); 87 entry = base::MakeUnique<Command>();
88 return entry.get(); 88 return entry.get();
89 } 89 }
OLDNEW
« no previous file with comments | « chrome/browser/background/background_contents.cc ('k') | chrome/browser/media/android/router/media_router_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698