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

Side by Side Diff: extensions/browser/script_executor.cc

Issue 2424593002: Reduce FOR_EACH_OBSERVER usage in extensions (Closed)
Patch Set: script_observers_ 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
« no previous file with comments | « extensions/browser/process_manager.cc ('k') | extensions/browser/user_script_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/browser/script_executor.h" 5 #include "extensions/browser/script_executor.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // We never finished the root frame injection. 161 // We never finished the root frame injection.
162 root_frame_error_ = 162 root_frame_error_ =
163 root_is_main_frame_ ? kRendererDestroyed : kFrameRemoved; 163 root_is_main_frame_ ? kRendererDestroyed : kFrameRemoved;
164 results_.Clear(); 164 results_.Clear();
165 } 165 }
166 166
167 if (script_observers_.get() && root_frame_error_.empty() && 167 if (script_observers_.get() && root_frame_error_.empty() &&
168 host_id_.type() == HostID::EXTENSIONS) { 168 host_id_.type() == HostID::EXTENSIONS) {
169 ScriptExecutionObserver::ExecutingScriptsMap id_map; 169 ScriptExecutionObserver::ExecutingScriptsMap id_map;
170 id_map[host_id_.id()] = std::set<std::string>(); 170 id_map[host_id_.id()] = std::set<std::string>();
171 FOR_EACH_OBSERVER( 171 for (auto& observer : *script_observers_)
172 ScriptExecutionObserver, *script_observers_, 172 observer.OnScriptsExecuted(web_contents(), id_map, root_frame_url_);
173 OnScriptsExecuted(web_contents(), id_map, root_frame_url_));
174 } 173 }
175 174
176 if (!callback_.is_null()) 175 if (!callback_.is_null())
177 callback_.Run(root_frame_error_, root_frame_url_, results_); 176 callback_.Run(root_frame_error_, root_frame_url_, results_);
178 delete this; 177 delete this;
179 } 178 }
180 179
181 base::WeakPtr<base::ObserverList<ScriptExecutionObserver>> script_observers_; 180 base::WeakPtr<base::ObserverList<ScriptExecutionObserver>> script_observers_;
182 181
183 // The id of the host (the extension or the webui) doing the injection. 182 // The id of the host (the extension or the webui) doing the injection.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 params.file_url = file_url; 268 params.file_url = file_url;
270 params.wants_result = (result_type == JSON_SERIALIZED_RESULT); 269 params.wants_result = (result_type == JSON_SERIALIZED_RESULT);
271 params.user_gesture = user_gesture; 270 params.user_gesture = user_gesture;
272 271
273 // Handler handles IPCs and deletes itself on completion. 272 // Handler handles IPCs and deletes itself on completion.
274 new Handler(script_observers_, web_contents_, params, frame_scope, frame_id, 273 new Handler(script_observers_, web_contents_, params, frame_scope, frame_id,
275 callback); 274 callback);
276 } 275 }
277 276
278 } // namespace extensions 277 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/process_manager.cc ('k') | extensions/browser/user_script_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698