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

Side by Side Diff: extensions/renderer/extension_frame_helper.cc

Issue 2633253002: Split content script injections into multiple tasks (Closed)
Patch Set: rebase Created 3 years, 9 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 "extensions/renderer/extension_frame_helper.h" 5 #include "extensions/renderer/extension_frame_helper.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/timer/elapsed_timer.h" 9 #include "base/timer/elapsed_timer.h"
10 #include "content/public/renderer/render_frame.h" 10 #include "content/public/renderer/render_frame.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 &document_element_created_callbacks_); 162 &document_element_created_callbacks_);
163 // |this| might be dead by now. 163 // |this| might be dead by now.
164 } 164 }
165 165
166 void ExtensionFrameHelper::RunScriptsAtDocumentEnd() { 166 void ExtensionFrameHelper::RunScriptsAtDocumentEnd() {
167 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(), 167 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(),
168 &document_load_finished_callbacks_); 168 &document_load_finished_callbacks_);
169 // |this| might be dead by now. 169 // |this| might be dead by now.
170 } 170 }
171 171
172 void ExtensionFrameHelper::RunScriptsAtDocumentIdle() {
173 RunCallbacksWhileFrameIsValid(weak_ptr_factory_.GetWeakPtr(),
174 &document_idle_callbacks_);
175 // |this| might be dead by now.
176 }
177
172 void ExtensionFrameHelper::ScheduleAtDocumentStart( 178 void ExtensionFrameHelper::ScheduleAtDocumentStart(
173 const base::Closure& callback) { 179 const base::Closure& callback) {
174 document_element_created_callbacks_.push_back(callback); 180 document_element_created_callbacks_.push_back(callback);
175 } 181 }
176 182
177 void ExtensionFrameHelper::ScheduleAtDocumentEnd( 183 void ExtensionFrameHelper::ScheduleAtDocumentEnd(
178 const base::Closure& callback) { 184 const base::Closure& callback) {
179 document_load_finished_callbacks_.push_back(callback); 185 document_load_finished_callbacks_.push_back(callback);
180 } 186 }
181 187
188 void ExtensionFrameHelper::ScheduleAtDocumentIdle(
189 const base::Closure& callback) {
190 document_idle_callbacks_.push_back(callback);
191 }
192
182 void ExtensionFrameHelper::DidMatchCSS( 193 void ExtensionFrameHelper::DidMatchCSS(
183 const blink::WebVector<blink::WebString>& newly_matching_selectors, 194 const blink::WebVector<blink::WebString>& newly_matching_selectors,
184 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { 195 const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
185 extension_dispatcher_->content_watcher()->DidMatchCSS( 196 extension_dispatcher_->content_watcher()->DidMatchCSS(
186 render_frame()->GetWebFrame(), newly_matching_selectors, 197 render_frame()->GetWebFrame(), newly_matching_selectors,
187 stopped_matching_selectors); 198 stopped_matching_selectors);
188 } 199 }
189 200
190 void ExtensionFrameHelper::DidStartProvisionalLoad( 201 void ExtensionFrameHelper::DidStartProvisionalLoad(
191 blink::WebDataSource* data_source) { 202 blink::WebDataSource* data_source) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 const base::ListValue& args) { 328 const base::ListValue& args) {
318 extension_dispatcher_->InvokeModuleSystemMethod( 329 extension_dispatcher_->InvokeModuleSystemMethod(
319 render_frame(), extension_id, module_name, function_name, args); 330 render_frame(), extension_id, module_name, function_name, args);
320 } 331 }
321 332
322 void ExtensionFrameHelper::OnDestruct() { 333 void ExtensionFrameHelper::OnDestruct() {
323 delete this; 334 delete this;
324 } 335 }
325 336
326 } // namespace extensions 337 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698