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

Side by Side Diff: content/browser/renderer_host/render_widget_helper.cc

Issue 1542743002: [RDHI] Refactored blocked_loaders_map_ to key by render frame route id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nasko nit Created 4 years, 10 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 "content/browser/renderer_host/render_widget_helper.h" 5 #include "content/browser/renderer_host/render_widget_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/posix/eintr_wrapper.h" 10 #include "base/posix/eintr_wrapper.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 void RenderWidgetHelper::ResumeDeferredNavigation( 76 void RenderWidgetHelper::ResumeDeferredNavigation(
77 const GlobalRequestID& request_id) { 77 const GlobalRequestID& request_id) {
78 BrowserThread::PostTask( 78 BrowserThread::PostTask(
79 BrowserThread::IO, FROM_HERE, 79 BrowserThread::IO, FROM_HERE,
80 base::Bind(&RenderWidgetHelper::OnResumeDeferredNavigation, 80 base::Bind(&RenderWidgetHelper::OnResumeDeferredNavigation,
81 this, 81 this,
82 request_id)); 82 request_id));
83 } 83 }
84 84
85 void RenderWidgetHelper::ResumeRequestsForView(int route_id) {
86 // We only need to resume blocked requests if we used a valid route_id.
87 // See CreateNewWindow.
88 if (route_id != MSG_ROUTING_NONE) {
89 BrowserThread::PostTask(
90 BrowserThread::IO, FROM_HERE,
91 base::Bind(&RenderWidgetHelper::OnResumeRequestsForView,
92 this, route_id));
93 }
94 }
95
96 void RenderWidgetHelper::OnResumeDeferredNavigation( 85 void RenderWidgetHelper::OnResumeDeferredNavigation(
97 const GlobalRequestID& request_id) { 86 const GlobalRequestID& request_id) {
98 resource_dispatcher_host_->ResumeDeferredNavigation(request_id); 87 resource_dispatcher_host_->ResumeDeferredNavigation(request_id);
99 } 88 }
100 89
101 void RenderWidgetHelper::CreateNewWindow( 90 void RenderWidgetHelper::CreateNewWindow(
102 const ViewHostMsg_CreateWindow_Params& params, 91 const ViewHostMsg_CreateWindow_Params& params,
103 bool no_javascript_access, 92 bool no_javascript_access,
104 base::ProcessHandle render_process, 93 base::ProcessHandle render_process,
105 int32_t* route_id, 94 int32_t* route_id,
106 int32_t* main_frame_route_id, 95 int32_t* main_frame_route_id,
107 int32_t* main_frame_widget_route_id, 96 int32_t* main_frame_widget_route_id,
108 SessionStorageNamespace* session_storage_namespace) { 97 SessionStorageNamespace* session_storage_namespace) {
109 if (params.opener_suppressed || no_javascript_access) { 98 if (params.opener_suppressed || no_javascript_access) {
110 // If the opener is supppressed or script access is disallowed, we should 99 // If the opener is supppressed or script access is disallowed, we should
111 // open the window in a new BrowsingInstance, and thus a new process. That 100 // open the window in a new BrowsingInstance, and thus a new process. That
112 // means the current renderer process will not be able to route messages to 101 // means the current renderer process will not be able to route messages to
113 // it. Because of this, we will immediately show and navigate the window 102 // it. Because of this, we will immediately show and navigate the window
114 // in OnCreateWindowOnUI, using the params provided here. 103 // in OnCreateWindowOnUI, using the params provided here.
115 *route_id = MSG_ROUTING_NONE; 104 *route_id = MSG_ROUTING_NONE;
116 *main_frame_route_id = MSG_ROUTING_NONE; 105 *main_frame_route_id = MSG_ROUTING_NONE;
117 *main_frame_widget_route_id = MSG_ROUTING_NONE; 106 *main_frame_widget_route_id = MSG_ROUTING_NONE;
118 } else { 107 } else {
119 *route_id = GetNextRoutingID(); 108 *route_id = GetNextRoutingID();
120 *main_frame_route_id = GetNextRoutingID(); 109 *main_frame_route_id = GetNextRoutingID();
121 // TODO(avi): When RenderViewHostImpl has-a RenderWidgetHostImpl, this 110 // TODO(avi): When RenderViewHostImpl has-a RenderWidgetHostImpl, this
122 // should be updated to give the widget a distinct routing ID. 111 // should be updated to give the widget a distinct routing ID.
123 // https://crbug.com/545684 112 // https://crbug.com/545684
124 *main_frame_widget_route_id = *route_id; 113 *main_frame_widget_route_id = *route_id;
125 // Block resource requests until the view is created, since the HWND might 114 // Block resource requests until the frame is created, since the HWND might
126 // be needed if a response ends up creating a plugin. 115 // be needed if a response ends up creating a plugin. We'll only have a
116 // single frame at this point. These requests will be resumed either in
117 // WebContentsImpl::CreateNewWindow or RenderFrameHost::Init.
127 resource_dispatcher_host_->BlockRequestsForRoute( 118 resource_dispatcher_host_->BlockRequestsForRoute(
128 render_process_id_, *route_id); 119 GlobalFrameRoutingId(render_process_id_, *main_frame_route_id));
129 } 120 }
130 121
131 BrowserThread::PostTask( 122 BrowserThread::PostTask(
132 BrowserThread::UI, FROM_HERE, 123 BrowserThread::UI, FROM_HERE,
133 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, this, params, 124 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, this, params,
134 *route_id, *main_frame_route_id, *main_frame_widget_route_id, 125 *route_id, *main_frame_route_id, *main_frame_widget_route_id,
135 make_scoped_refptr(session_storage_namespace))); 126 make_scoped_refptr(session_storage_namespace)));
136 } 127 }
137 128
138 void RenderWidgetHelper::OnCreateWindowOnUI( 129 void RenderWidgetHelper::OnCreateWindowOnUI(
139 const ViewHostMsg_CreateWindow_Params& params, 130 const ViewHostMsg_CreateWindow_Params& params,
140 int32_t route_id, 131 int32_t route_id,
141 int32_t main_frame_route_id, 132 int32_t main_frame_route_id,
142 int32_t main_frame_widget_route_id, 133 int32_t main_frame_widget_route_id,
143 SessionStorageNamespace* session_storage_namespace) { 134 SessionStorageNamespace* session_storage_namespace) {
144 RenderViewHostImpl* host = 135 RenderViewHostImpl* host =
145 RenderViewHostImpl::FromID(render_process_id_, params.opener_id); 136 RenderViewHostImpl::FromID(render_process_id_, params.opener_id);
146 if (host) 137 if (host)
147 host->CreateNewWindow(route_id, main_frame_route_id, 138 host->CreateNewWindow(route_id, main_frame_route_id,
148 main_frame_widget_route_id, params, 139 main_frame_widget_route_id, params,
149 session_storage_namespace); 140 session_storage_namespace);
150 } 141 }
151 142
152 void RenderWidgetHelper::OnResumeRequestsForView(int route_id) {
153 resource_dispatcher_host_->ResumeBlockedRequestsForRoute(
154 render_process_id_, route_id);
155 }
156
157 void RenderWidgetHelper::CreateNewWidget(int opener_id, 143 void RenderWidgetHelper::CreateNewWidget(int opener_id,
158 blink::WebPopupType popup_type, 144 blink::WebPopupType popup_type,
159 int* route_id) { 145 int* route_id) {
160 *route_id = GetNextRoutingID(); 146 *route_id = GetNextRoutingID();
161 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 147 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
162 base::Bind(&RenderWidgetHelper::OnCreateWidgetOnUI, 148 base::Bind(&RenderWidgetHelper::OnCreateWidgetOnUI,
163 this, opener_id, *route_id, popup_type)); 149 this, opener_id, *route_id, popup_type));
164 } 150 }
165 151
166 void RenderWidgetHelper::CreateNewFullscreenWidget(int opener_id, 152 void RenderWidgetHelper::CreateNewFullscreenWidget(int opener_id,
(...skipping 16 matching lines...) Expand all
183 169
184 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int32_t opener_id, 170 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int32_t opener_id,
185 int32_t route_id) { 171 int32_t route_id) {
186 RenderViewHostImpl* host = RenderViewHostImpl::FromID( 172 RenderViewHostImpl* host = RenderViewHostImpl::FromID(
187 render_process_id_, opener_id); 173 render_process_id_, opener_id);
188 if (host) 174 if (host)
189 host->CreateNewFullscreenWidget(route_id); 175 host->CreateNewFullscreenWidget(route_id);
190 } 176 }
191 177
192 } // namespace content 178 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698