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

Side by Side Diff: content/renderer/render_frame_impl.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 "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 // Return if the world_id is not valid. world_id is passed as a plain int 1992 // Return if the world_id is not valid. world_id is passed as a plain int
1993 // over IPC and needs to be verified here, in the IPC endpoint. 1993 // over IPC and needs to be verified here, in the IPC endpoint.
1994 NOTREACHED(); 1994 NOTREACHED();
1995 return; 1995 return;
1996 } 1996 }
1997 1997
1998 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); 1998 v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
1999 WebScriptSource script = WebScriptSource(WebString::fromUTF16(jscript)); 1999 WebScriptSource script = WebScriptSource(WebString::fromUTF16(jscript));
2000 JavaScriptIsolatedWorldRequest* request = new JavaScriptIsolatedWorldRequest( 2000 JavaScriptIsolatedWorldRequest* request = new JavaScriptIsolatedWorldRequest(
2001 id, notify_result, routing_id_, weak_factory_.GetWeakPtr()); 2001 id, notify_result, routing_id_, weak_factory_.GetWeakPtr());
2002 frame_->requestExecuteScriptInIsolatedWorld(world_id, &script, 1, false, 2002 frame_->requestExecuteScriptInIsolatedWorld(
2003 request); 2003 world_id, &script, 1, false, WebLocalFrame::Synchronous, request);
2004 } 2004 }
2005 2005
2006 RenderFrameImpl::JavaScriptIsolatedWorldRequest::JavaScriptIsolatedWorldRequest( 2006 RenderFrameImpl::JavaScriptIsolatedWorldRequest::JavaScriptIsolatedWorldRequest(
2007 int id, 2007 int id,
2008 bool notify_result, 2008 bool notify_result,
2009 int routing_id, 2009 int routing_id,
2010 base::WeakPtr<RenderFrameImpl> render_frame_impl) 2010 base::WeakPtr<RenderFrameImpl> render_frame_impl)
2011 : id_(id), 2011 : id_(id),
2012 notify_result_(notify_result), 2012 notify_result_(notify_result),
2013 routing_id_(routing_id), 2013 routing_id_(routing_id),
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3861 error.unreachableURL = frame->document().url(); 3861 error.unreachableURL = frame->document().url();
3862 error.domain = WebString::fromUTF8(error_domain); 3862 error.domain = WebString::fromUTF8(error_domain);
3863 error.reason = http_status_code; 3863 error.reason = http_status_code;
3864 // This call may run scripts, e.g. via the beforeunload event. 3864 // This call may run scripts, e.g. via the beforeunload event.
3865 LoadNavigationErrorPage(frame->dataSource()->getRequest(), error, true, 3865 LoadNavigationErrorPage(frame->dataSource()->getRequest(), error, true,
3866 nullptr); 3866 nullptr);
3867 } 3867 }
3868 // Do not use |this| or |frame| here without checking |weak_self|. 3868 // Do not use |this| or |frame| here without checking |weak_self|.
3869 } 3869 }
3870 3870
3871 void RenderFrameImpl::runScriptsAtDocumentIdle(blink::WebLocalFrame* frame) {
3872 DCHECK_EQ(frame_, frame);
3873 base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr();
3874 if (!weak_self.get())
3875 return;
3876
3877 GetContentClient()->renderer()->RunScriptsAtDocumentIdle(this);
3878 // ContentClient might have deleted |frame| and |this| by now!
3879 }
3880
3871 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) { 3881 void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) {
3872 DCHECK_EQ(frame_, frame); 3882 DCHECK_EQ(frame_, frame);
3873 if (!frame->parent()) { 3883 if (!frame->parent()) {
3874 FrameMsg_UILoadMetricsReportType::Value report_type = 3884 FrameMsg_UILoadMetricsReportType::Value report_type =
3875 static_cast<FrameMsg_UILoadMetricsReportType::Value>( 3885 static_cast<FrameMsg_UILoadMetricsReportType::Value>(
3876 frame->dataSource()->getRequest().inputPerfMetricReportPolicy()); 3886 frame->dataSource()->getRequest().inputPerfMetricReportPolicy());
3877 base::TimeTicks ui_timestamp = 3887 base::TimeTicks ui_timestamp =
3878 base::TimeTicks() + 3888 base::TimeTicks() +
3879 base::TimeDelta::FromSecondsD( 3889 base::TimeDelta::FromSecondsD(
3880 frame->dataSource()->getRequest().uiStartTime()); 3890 frame->dataSource()->getRequest().uiStartTime());
(...skipping 2978 matching lines...) Expand 10 before | Expand all | Expand 10 after
6859 // event target. Potentially a Pepper plugin will receive the event. 6869 // event target. Potentially a Pepper plugin will receive the event.
6860 // In order to tell whether a plugin gets the last mouse event and which it 6870 // In order to tell whether a plugin gets the last mouse event and which it
6861 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6871 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6862 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6872 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6863 // |pepper_last_mouse_event_target_|. 6873 // |pepper_last_mouse_event_target_|.
6864 pepper_last_mouse_event_target_ = nullptr; 6874 pepper_last_mouse_event_target_ = nullptr;
6865 #endif 6875 #endif
6866 } 6876 }
6867 6877
6868 } // namespace content 6878 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698