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

Side by Side Diff: chrome/browser/extensions/error_console/error_console.cc

Issue 2422963002: Remove FOR_EACH_OBSERVER macro usage in chrome/browser/extensions (Closed)
Patch Set: extensions 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/error_console/error_console.h" 5 #include "chrome/browser/extensions/error_console/error_console.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 pref_registrar_.Add(prefs::kExtensionsUIDeveloperMode, 68 pref_registrar_.Add(prefs::kExtensionsUIDeveloperMode,
69 base::Bind(&ErrorConsole::OnPrefChanged, 69 base::Bind(&ErrorConsole::OnPrefChanged,
70 base::Unretained(this))); 70 base::Unretained(this)));
71 71
72 registry_observer_.Add(ExtensionRegistry::Get(profile_)); 72 registry_observer_.Add(ExtensionRegistry::Get(profile_));
73 73
74 CheckEnabled(); 74 CheckEnabled();
75 } 75 }
76 76
77 ErrorConsole::~ErrorConsole() { 77 ErrorConsole::~ErrorConsole() {
78 FOR_EACH_OBSERVER(Observer, observers_, OnErrorConsoleDestroyed()); 78 for (auto& observer : observers_)
79 observer.OnErrorConsoleDestroyed();
79 } 80 }
80 81
81 // static 82 // static
82 ErrorConsole* ErrorConsole::Get(content::BrowserContext* browser_context) { 83 ErrorConsole* ErrorConsole::Get(content::BrowserContext* browser_context) {
83 return ErrorConsoleFactory::GetForBrowserContext(browser_context); 84 return ErrorConsoleFactory::GetForBrowserContext(browser_context);
84 } 85 }
85 86
86 void ErrorConsole::SetReportingForExtension(const std::string& extension_id, 87 void ErrorConsole::SetReportingForExtension(const std::string& extension_id,
87 ExtensionError::Type type, 88 ExtensionError::Type type,
88 bool enabled) { 89 bool enabled) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 void ErrorConsole::ReportError(std::unique_ptr<ExtensionError> error) { 140 void ErrorConsole::ReportError(std::unique_ptr<ExtensionError> error) {
140 DCHECK(thread_checker_.CalledOnValidThread()); 141 DCHECK(thread_checker_.CalledOnValidThread());
141 if (!enabled_ || !crx_file::id_util::IdIsValid(error->extension_id())) 142 if (!enabled_ || !crx_file::id_util::IdIsValid(error->extension_id()))
142 return; 143 return;
143 144
144 int mask = GetMaskForExtension(error->extension_id()); 145 int mask = GetMaskForExtension(error->extension_id());
145 if (!(mask & (1 << error->type()))) 146 if (!(mask & (1 << error->type())))
146 return; 147 return;
147 148
148 const ExtensionError* weak_error = errors_.AddError(std::move(error)); 149 const ExtensionError* weak_error = errors_.AddError(std::move(error));
149 FOR_EACH_OBSERVER(Observer, observers_, OnErrorAdded(weak_error)); 150 for (auto& observer : observers_)
151 observer.OnErrorAdded(weak_error);
150 } 152 }
151 153
152 void ErrorConsole::RemoveErrors(const ErrorMap::Filter& filter) { 154 void ErrorConsole::RemoveErrors(const ErrorMap::Filter& filter) {
153 std::set<std::string> affected_ids; 155 std::set<std::string> affected_ids;
154 errors_.RemoveErrors(filter, &affected_ids); 156 errors_.RemoveErrors(filter, &affected_ids);
155 FOR_EACH_OBSERVER(Observer, observers_, OnErrorsRemoved(affected_ids)); 157 for (auto& observer : observers_)
158 observer.OnErrorsRemoved(affected_ids);
156 } 159 }
157 160
158 const ErrorList& ErrorConsole::GetErrorsForExtension( 161 const ErrorList& ErrorConsole::GetErrorsForExtension(
159 const std::string& extension_id) const { 162 const std::string& extension_id) const {
160 return errors_.GetErrorsForExtension(extension_id); 163 return errors_.GetErrorsForExtension(extension_id);
161 } 164 }
162 165
163 void ErrorConsole::AddObserver(Observer* observer) { 166 void ErrorConsole::AddObserver(Observer* observer) {
164 DCHECK(thread_checker_.CalledOnValidThread()); 167 DCHECK(thread_checker_.CalledOnValidThread());
165 observers_.AddObserver(observer); 168 observers_.AddObserver(observer);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 ExtensionRegistry::Get(profile_)->GetExtensionById( 294 ExtensionRegistry::Get(profile_)->GetExtensionById(
292 extension_id, ExtensionRegistry::EVERYTHING); 295 extension_id, ExtensionRegistry::EVERYTHING);
293 if (extension && extension->location() == Manifest::UNPACKED) 296 if (extension && extension->location() == Manifest::UNPACKED)
294 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; 297 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1;
295 298
296 // Otherwise, use the default mask. 299 // Otherwise, use the default mask.
297 return default_mask_; 300 return default_mask_;
298 } 301 }
299 302
300 } // namespace extensions 303 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/blacklist.cc ('k') | chrome/browser/extensions/extension_error_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698