Chromium Code Reviews| Index: content/browser/web_contents/web_contents_impl.cc |
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
| index 8086e0c42d33a34032c97e32c28794076d642086..5f7de21e43e903f2335b5b7bf17421947c30af41 100644 |
| --- a/content/browser/web_contents/web_contents_impl.cc |
| +++ b/content/browser/web_contents/web_contents_impl.cc |
| @@ -42,6 +42,7 @@ |
| #include "content/browser/frame_host/render_frame_host_impl.h" |
| #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| #include "content/browser/geolocation/geolocation_service_context.h" |
| +#include "content/browser/gpu/gpu_surface_tracker.h" |
| #include "content/browser/host_zoom_map_impl.h" |
| #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| #include "content/browser/manifest/manifest_manager_host.h" |
| @@ -1331,14 +1332,37 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
| // it should be hidden. |
| should_normally_be_visible_ = !params.initially_hidden; |
| - // Either both routing ids can be given, or neither can be. |
| + // The routing ids / surface id must either all be set or all be unset. |
| DCHECK((params.routing_id == MSG_ROUTING_NONE && |
| - params.main_frame_routing_id == MSG_ROUTING_NONE) || |
| + params.main_frame_routing_id == MSG_ROUTING_NONE && |
| + params.main_frame_widget_routing_id == MSG_ROUTING_NONE && |
| + params.surface_id == 0) || |
| (params.routing_id != MSG_ROUTING_NONE && |
| - params.main_frame_routing_id != MSG_ROUTING_NONE)); |
| - GetRenderManager()->Init(params.browser_context, params.site_instance, |
| - params.routing_id, params.main_frame_routing_id, |
| - MSG_ROUTING_NONE, 0 /* surface_id */); |
| + params.main_frame_routing_id != MSG_ROUTING_NONE && |
| + params.main_frame_widget_routing_id != MSG_ROUTING_NONE && |
| + params.surface_id != 0)); |
| + |
| + // TODO(dcheng): Perhaps |params| should be bassed by value rather than by |
| + // reference. That way, the members can be changed in-place, and other code in |
| + // this block won't accidentally use sentinel values. |
|
ncarter (slow)
2015/09/03 20:24:37
I'm not totally sold on the content of the TODO --
dcheng
2015/09/03 21:29:24
TODO removed.
|
| + scoped_refptr<SiteInstance> site_instance = params.site_instance; |
| + if (!site_instance) |
| + site_instance = SiteInstance::Create(params.browser_context); |
| + |
| + // A main RenderFrameHost always has a RenderWidgetHost, since it is always a |
| + // local root by definition. |
| + int32 main_frame_widget_routing_id = params.main_frame_widget_routing_id; |
| + int32 surface_id = params.surface_id; |
| + if (main_frame_widget_routing_id == MSG_ROUTING_NONE) { |
| + main_frame_widget_routing_id = |
| + site_instance->GetProcess()->GetNextRoutingID(); |
| + surface_id = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
| + site_instance->GetProcess()->GetID(), main_frame_widget_routing_id); |
| + } |
| + |
| + GetRenderManager()->Init(site_instance.get(), params.routing_id, |
| + params.main_frame_routing_id, |
| + main_frame_widget_routing_id, surface_id); |
| frame_tree_.root()->SetFrameName(params.main_frame_name); |
| WebContentsViewDelegate* delegate = |
| @@ -1644,8 +1668,10 @@ void WebContentsImpl::LostMouseLock() { |
| void WebContentsImpl::CreateNewWindow( |
| SiteInstance* source_site_instance, |
| - int route_id, |
| - int main_frame_route_id, |
| + int32 route_id, |
| + int32 main_frame_route_id, |
| + int32 main_frame_widget_route_id, |
| + int32 surface_id, |
| const ViewHostMsg_CreateWindow_Params& params, |
| SessionStorageNamespace* session_storage_namespace) { |
| // We usually create the new window in the same BrowsingInstance (group of |
| @@ -1704,14 +1730,10 @@ void WebContentsImpl::CreateNewWindow( |
| CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
| if (delegate_ && |
| - !delegate_->ShouldCreateWebContents(this, |
| - route_id, |
| - main_frame_route_id, |
| - params.window_container_type, |
| - params.frame_name, |
| - params.target_url, |
| - partition_id, |
| - session_storage_namespace)) { |
| + !delegate_->ShouldCreateWebContents( |
| + this, route_id, main_frame_route_id, main_frame_widget_route_id, |
| + surface_id, params.window_container_type, params.frame_name, |
| + params.target_url, partition_id, session_storage_namespace)) { |
| if (route_id != MSG_ROUTING_NONE && |
| !RenderViewHost::FromID(render_process_id, route_id)) { |
| // If the embedder didn't create a WebContents for this route, we need to |
| @@ -1721,6 +1743,8 @@ void WebContentsImpl::CreateNewWindow( |
| GetRenderViewHost()->GetProcess()->ResumeRequestsForView(route_id); |
| GetRenderViewHost()->GetProcess()->ResumeRequestsForView( |
| main_frame_route_id); |
| + GetRenderViewHost()->GetProcess()->ResumeRequestsForView( |
| + main_frame_widget_route_id); |
| return; |
| } |
| @@ -1729,7 +1753,9 @@ void WebContentsImpl::CreateNewWindow( |
| CreateParams create_params(GetBrowserContext(), site_instance.get()); |
| create_params.routing_id = route_id; |
| create_params.main_frame_routing_id = main_frame_route_id; |
| + create_params.main_frame_widget_routing_id = main_frame_widget_route_id; |
| create_params.main_frame_name = params.frame_name; |
| + create_params.surface_id = surface_id; |
| create_params.opener_render_process_id = render_process_id; |
| create_params.opener_render_frame_id = params.opener_render_frame_id; |
| create_params.opener_suppressed = params.opener_suppressed; |