Commit d16fec1b authored by nasko@chromium.org's avatar nasko@chromium.org

Decouple RVH creation from CrossProcessFrameConnector.

The RenderViewHost creation today takes a CrossProcessFrameConnector pointer, which it uses to decide whether to create a top-level or child frame view. Replace this with a boolean and associate the CrossProcessFrameConnector with the view at a later point in time.

BUG=357747

Review URL: https://codereview.chromium.org/270883003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271461 0039d316-1c4b-4281-b951-d872f2087c98
parent eb4ca49e
...@@ -53,9 +53,12 @@ void CrossProcessFrameConnector::set_view( ...@@ -53,9 +53,12 @@ void CrossProcessFrameConnector::set_view(
view_ = view; view_ = view;
// Attach ourselves to the new view. // Attach ourselves to the new view and size it appropriately.
if (view_) if (view_) {
view_->set_cross_process_frame_connector(this); view_->set_cross_process_frame_connector(this);
SetDeviceScaleFactor(device_scale_factor_);
SetSize(child_frame_rect_);
}
} }
void CrossProcessFrameConnector::RenderProcessGone() { void CrossProcessFrameConnector::RenderProcessGone() {
...@@ -123,20 +126,11 @@ void CrossProcessFrameConnector::OnReclaimCompositorResources( ...@@ -123,20 +126,11 @@ void CrossProcessFrameConnector::OnReclaimCompositorResources(
void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect, void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect,
float scale_factor) { float scale_factor) {
if (scale_factor != device_scale_factor_) { if (scale_factor != device_scale_factor_)
device_scale_factor_ = scale_factor; SetDeviceScaleFactor(scale_factor);
if (view_) {
RenderWidgetHostImpl* child_widget =
RenderWidgetHostImpl::From(view_->GetRenderWidgetHost());
child_widget->NotifyScreenInfoChanged();
}
}
if (!frame_rect.size().IsEmpty()) { if (!frame_rect.size().IsEmpty())
child_frame_rect_ = frame_rect; SetSize(frame_rect);
if (view_)
view_->SetSize(frame_rect.size());
}
} }
gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { gfx::Rect CrossProcessFrameConnector::ChildFrameRect() {
...@@ -175,4 +169,19 @@ void CrossProcessFrameConnector::OnForwardInputEvent( ...@@ -175,4 +169,19 @@ void CrossProcessFrameConnector::OnForwardInputEvent(
} }
} }
void CrossProcessFrameConnector::SetDeviceScaleFactor(float scale_factor) {
device_scale_factor_ = scale_factor;
if (view_) {
RenderWidgetHostImpl* child_widget =
RenderWidgetHostImpl::From(view_->GetRenderWidgetHost());
child_widget->NotifyScreenInfoChanged();
}
}
void CrossProcessFrameConnector::SetSize(gfx::Rect frame_rect) {
child_frame_rect_ = frame_rect;
if (view_)
view_->SetSize(frame_rect.size());
}
} // namespace content } // namespace content
...@@ -101,6 +101,9 @@ class CrossProcessFrameConnector { ...@@ -101,6 +101,9 @@ class CrossProcessFrameConnector {
void OnForwardInputEvent(const blink::WebInputEvent* event); void OnForwardInputEvent(const blink::WebInputEvent* event);
void OnInitializeChildFrame(gfx::Rect frame_rect, float scale_factor); void OnInitializeChildFrame(gfx::Rect frame_rect, float scale_factor);
void SetDeviceScaleFactor(float scale_factor);
void SetSize(gfx::Rect frame_rect);
// The RenderFrameHost that routes messages to the parent frame's renderer // The RenderFrameHost that routes messages to the parent frame's renderer
// process. // process.
// TODO(kenrb): The type becomes RenderFrameProxyHost when that class comes // TODO(kenrb): The type becomes RenderFrameProxyHost when that class comes
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "content/browser/frame_host/render_frame_host_factory.h" #include "content/browser/frame_host/render_frame_host_factory.h"
#include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/frame_host/render_frame_proxy_host.h" #include "content/browser/frame_host/render_frame_proxy_host.h"
#include "content/browser/frame_host/render_widget_host_view_child_frame.h"
#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h"
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "content/public/browser/render_widget_host_iterator.h" #include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/user_metrics.h" #include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_ui_controller.h" #include "content/public/browser/web_ui_controller.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
...@@ -176,7 +178,7 @@ RenderFrameHostImpl* RenderFrameHostManager::Navigate( ...@@ -176,7 +178,7 @@ RenderFrameHostImpl* RenderFrameHostManager::Navigate(
// soon anyway, and we don't have the NavigationEntry for this host. // soon anyway, and we don't have the NavigationEntry for this host.
delegate_->CreateRenderViewForRenderManager( delegate_->CreateRenderViewForRenderManager(
render_frame_host_->render_view_host(), MSG_ROUTING_NONE, render_frame_host_->render_view_host(), MSG_ROUTING_NONE,
MSG_ROUTING_NONE, NULL); MSG_ROUTING_NONE, frame_tree_node_->IsMainFrame());
} }
// If the renderer crashed, then try to create a new one to satisfy this // If the renderer crashed, then try to create a new one to satisfy this
...@@ -186,7 +188,9 @@ RenderFrameHostImpl* RenderFrameHostManager::Navigate( ...@@ -186,7 +188,9 @@ RenderFrameHostImpl* RenderFrameHostManager::Navigate(
int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager(
dest_render_frame_host->GetSiteInstance()); dest_render_frame_host->GetSiteInstance());
if (!InitRenderView(dest_render_frame_host->render_view_host(), if (!InitRenderView(dest_render_frame_host->render_view_host(),
opener_route_id, MSG_ROUTING_NONE)) opener_route_id,
MSG_ROUTING_NONE,
frame_tree_node_->IsMainFrame()))
return NULL; return NULL;
// Now that we've created a new renderer, be sure to hide it if it isn't // Now that we've created a new renderer, be sure to hide it if it isn't
...@@ -501,6 +505,9 @@ void RenderFrameHostManager::SwapOutOldPage() { ...@@ -501,6 +505,9 @@ void RenderFrameHostManager::SwapOutOldPage() {
// process navigations, but it will be destroyed if the Frame is // process navigations, but it will be destroyed if the Frame is
// navigated back to the same site instance as its parent. // navigated back to the same site instance as its parent.
// TODO(kenrb): This will change when RenderFrameProxyHost is created. // TODO(kenrb): This will change when RenderFrameProxyHost is created.
// TODO(nasko): Move CrossProcessFrameConnector to be owned by
// RenderFrameProxyHost instead of RenderFrameHostManager once proxy
// support lands.
if (!cross_process_frame_connector_) { if (!cross_process_frame_connector_) {
cross_process_frame_connector_ = cross_process_frame_connector_ =
new CrossProcessFrameConnector(render_frame_host_.get()); new CrossProcessFrameConnector(render_frame_host_.get());
...@@ -965,7 +972,8 @@ int RenderFrameHostManager::CreateRenderFrame( ...@@ -965,7 +972,8 @@ int RenderFrameHostManager::CreateRenderFrame(
} }
bool success = InitRenderView( bool success = InitRenderView(
render_view_host, opener_route_id, proxy_routing_id); render_view_host, opener_route_id, proxy_routing_id,
frame_tree_node_->IsMainFrame());
if (success && frame_tree_node_->IsMainFrame()) { if (success && frame_tree_node_->IsMainFrame()) {
// Don't show the main frame's view until we get a DidNavigate from it. // Don't show the main frame's view until we get a DidNavigate from it.
render_view_host->GetView()->Hide(); render_view_host->GetView()->Hide();
...@@ -984,7 +992,8 @@ int RenderFrameHostManager::CreateRenderFrame( ...@@ -984,7 +992,8 @@ int RenderFrameHostManager::CreateRenderFrame(
bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host,
int opener_route_id, int opener_route_id,
int proxy_routing_id) { int proxy_routing_id,
bool for_main_frame) {
// We may have initialized this RenderViewHost for another RenderFrameHost. // We may have initialized this RenderViewHost for another RenderFrameHost.
if (render_view_host->IsRenderViewLive()) if (render_view_host->IsRenderViewLive())
return true; return true;
...@@ -1006,8 +1015,7 @@ bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host, ...@@ -1006,8 +1015,7 @@ bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host,
} }
return delegate_->CreateRenderViewForRenderManager( return delegate_->CreateRenderViewForRenderManager(
render_view_host, opener_route_id, proxy_routing_id, render_view_host, opener_route_id, proxy_routing_id, for_main_frame);
cross_process_frame_connector_);
} }
void RenderFrameHostManager::CommitPending() { void RenderFrameHostManager::CommitPending() {
...@@ -1164,8 +1172,20 @@ void RenderFrameHostManager::CommitPending() { ...@@ -1164,8 +1172,20 @@ void RenderFrameHostManager::CommitPending() {
// this RFH was the last active one in the SiteInstance. Now that we // this RFH was the last active one in the SiteInstance. Now that we
// know that all RFHs are swapped out, we can delete all the RFHs and RVHs // know that all RFHs are swapped out, we can delete all the RFHs and RVHs
// in this SiteInstance. // in this SiteInstance.
if (!active_view_count) if (!active_view_count) {
ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id); ShutdownRenderFrameHostsInSiteInstance(old_site_instance_id);
} else {
// If this is a subframe, it should have a CrossProcessFrameConnector
// created already and we just need to link it to the proper view in the
// new process.
if (!is_main_frame) {
RenderWidgetHostView* rwhv =
render_frame_host_->render_view_host()->GetView();
RenderWidgetHostViewChildFrame* rwhv_child =
static_cast<RenderWidgetHostViewChildFrame*>(rwhv);
cross_process_frame_connector_->set_view(rwhv_child);
}
}
} }
} }
......
...@@ -57,12 +57,14 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { ...@@ -57,12 +57,14 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
// corresponding to this view host. If this method is not called and the // corresponding to this view host. If this method is not called and the
// process is not shared, then the WebContentsImpl will act as though the // process is not shared, then the WebContentsImpl will act as though the
// renderer is not running (i.e., it will render "sad tab"). This method is // renderer is not running (i.e., it will render "sad tab"). This method is
// automatically called from LoadURL. // automatically called from LoadURL. |for_main_frame| indicates whether
// this RenderViewHost is used to render a top-level frame, so the
// appropriate RenderWidgetHostView type is used.
virtual bool CreateRenderViewForRenderManager( virtual bool CreateRenderViewForRenderManager(
RenderViewHost* render_view_host, RenderViewHost* render_view_host,
int opener_route_id, int opener_route_id,
int proxy_routing_id, int proxy_routing_id,
CrossProcessFrameConnector* cross_process_frame_connector) = 0; bool for_main_frame) = 0;
virtual void BeforeUnloadFiredFromRenderManager( virtual void BeforeUnloadFiredFromRenderManager(
bool proceed, const base::TimeTicks& proceed_time, bool proceed, const base::TimeTicks& proceed_time,
bool* proceed_to_fire_unload) = 0; bool* proceed_to_fire_unload) = 0;
...@@ -379,7 +381,8 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { ...@@ -379,7 +381,8 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
// be for the RenderFrame, since frames can have openers. // be for the RenderFrame, since frames can have openers.
bool InitRenderView(RenderViewHost* render_view_host, bool InitRenderView(RenderViewHost* render_view_host,
int opener_route_id, int opener_route_id,
int proxy_routing_id); int proxy_routing_id,
bool for_main_frame);
// Sets the pending RenderFrameHost/WebUI to be the active one. Note that this // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
// doesn't require the pending render_frame_host_ pointer to be non-NULL, // doesn't require the pending render_frame_host_ pointer to be non-NULL,
......
...@@ -3896,7 +3896,7 @@ bool WebContentsImpl::CreateRenderViewForRenderManager( ...@@ -3896,7 +3896,7 @@ bool WebContentsImpl::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host, RenderViewHost* render_view_host,
int opener_route_id, int opener_route_id,
int proxy_routing_id, int proxy_routing_id,
CrossProcessFrameConnector* frame_connector) { bool for_main_frame) {
TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderViewForRenderManager"); TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderViewForRenderManager");
// Can be NULL during tests. // Can be NULL during tests.
RenderWidgetHostViewBase* rwh_view; RenderWidgetHostViewBase* rwh_view;
...@@ -3904,10 +3904,9 @@ bool WebContentsImpl::CreateRenderViewForRenderManager( ...@@ -3904,10 +3904,9 @@ bool WebContentsImpl::CreateRenderViewForRenderManager(
// until RenderWidgetHost is attached to RenderFrameHost. We need to special // until RenderWidgetHost is attached to RenderFrameHost. We need to special
// case this because RWH is still a base class of RenderViewHost, and child // case this because RWH is still a base class of RenderViewHost, and child
// frame RWHVs are unique in that they do not have their own WebContents. // frame RWHVs are unique in that they do not have their own WebContents.
if (frame_connector) { if (!for_main_frame) {
RenderWidgetHostViewChildFrame* rwh_view_child = RenderWidgetHostViewChildFrame* rwh_view_child =
new RenderWidgetHostViewChildFrame(render_view_host); new RenderWidgetHostViewChildFrame(render_view_host);
frame_connector->set_view(rwh_view_child);
rwh_view = rwh_view_child; rwh_view = rwh_view_child;
} else { } else {
rwh_view = view_->CreateViewForWidget(render_view_host); rwh_view = view_->CreateViewForWidget(render_view_host);
......
...@@ -519,7 +519,7 @@ class CONTENT_EXPORT WebContentsImpl ...@@ -519,7 +519,7 @@ class CONTENT_EXPORT WebContentsImpl
RenderViewHost* render_view_host, RenderViewHost* render_view_host,
int opener_route_id, int opener_route_id,
int proxy_routing_id, int proxy_routing_id,
CrossProcessFrameConnector* frame_connector) OVERRIDE; bool for_main_frame) OVERRIDE;
virtual void BeforeUnloadFiredFromRenderManager( virtual void BeforeUnloadFiredFromRenderManager(
bool proceed, const base::TimeTicks& proceed_time, bool proceed, const base::TimeTicks& proceed_time,
bool* proceed_to_fire_unload) OVERRIDE; bool* proceed_to_fire_unload) OVERRIDE;
......
...@@ -100,7 +100,7 @@ bool TestWebContents::CreateRenderViewForRenderManager( ...@@ -100,7 +100,7 @@ bool TestWebContents::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host, RenderViewHost* render_view_host,
int opener_route_id, int opener_route_id,
int proxy_routing_id, int proxy_routing_id,
CrossProcessFrameConnector* frame_connector) { bool for_main_frame) {
UpdateMaxPageIDIfNecessary(render_view_host); UpdateMaxPageIDIfNecessary(render_view_host);
// This will go to a TestRenderViewHost. // This will go to a TestRenderViewHost.
static_cast<RenderViewHostImpl*>( static_cast<RenderViewHostImpl*>(
......
...@@ -60,7 +60,7 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester { ...@@ -60,7 +60,7 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester {
RenderViewHost* render_view_host, RenderViewHost* render_view_host,
int opener_route_id, int opener_route_id,
int proxy_routing_id, int proxy_routing_id,
CrossProcessFrameConnector* frame_connector) OVERRIDE; bool for_main_frame) OVERRIDE;
virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE {} virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE {}
// Returns a clone of this TestWebContents. The returned object is also a // Returns a clone of this TestWebContents. The returned object is also a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment