summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 03:48:59 +0000
committernasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 03:48:59 +0000
commit6ab9d68e7f228b9915296305fb93ed874010e34b (patch)
treeadf850d53ef906b77b8ffa883cb5e98fc0a669b2
parent33b1ce0e24c940414ddbec05c1c292ffcf6d4a04 (diff)
downloadchromium_src-6ab9d68e7f228b9915296305fb93ed874010e34b.zip
chromium_src-6ab9d68e7f228b9915296305fb93ed874010e34b.tar.gz
chromium_src-6ab9d68e7f228b9915296305fb93ed874010e34b.tar.bz2
Decouple RVH creation from CrossProcessFrameConnector.
This is a reland of https://codereview.chromium.org/270883003/, which was reverted because it missed to update one of the callers to CreateRenderViewForRenderManager. Patchset 1 is the equivalent to the previous commit. BUG=357747 Review URL: https://codereview.chromium.org/299703002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272078 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/frame_host/cross_process_frame_connector.cc39
-rw-r--r--content/browser/frame_host/cross_process_frame_connector.h3
-rw-r--r--content/browser/frame_host/render_frame_host_manager.cc34
-rw-r--r--content/browser/frame_host/render_frame_host_manager.h9
-rw-r--r--content/browser/web_contents/web_contents_impl.cc7
-rw-r--r--content/browser/web_contents/web_contents_impl.h2
-rw-r--r--content/test/test_web_contents.cc2
-rw-r--r--content/test/test_web_contents.h2
8 files changed, 66 insertions, 32 deletions
diff --git a/content/browser/frame_host/cross_process_frame_connector.cc b/content/browser/frame_host/cross_process_frame_connector.cc
index 0e40332..438f1f7 100644
--- a/content/browser/frame_host/cross_process_frame_connector.cc
+++ b/content/browser/frame_host/cross_process_frame_connector.cc
@@ -53,9 +53,12 @@ void CrossProcessFrameConnector::set_view(
view_ = view;
- // Attach ourselves to the new view.
- if (view_)
+ // Attach ourselves to the new view and size it appropriately.
+ if (view_) {
view_->set_cross_process_frame_connector(this);
+ SetDeviceScaleFactor(device_scale_factor_);
+ SetSize(child_frame_rect_);
+ }
}
void CrossProcessFrameConnector::RenderProcessGone() {
@@ -123,20 +126,11 @@ void CrossProcessFrameConnector::OnReclaimCompositorResources(
void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect,
float scale_factor) {
- if (scale_factor != device_scale_factor_) {
- device_scale_factor_ = scale_factor;
- if (view_) {
- RenderWidgetHostImpl* child_widget =
- RenderWidgetHostImpl::From(view_->GetRenderWidgetHost());
- child_widget->NotifyScreenInfoChanged();
- }
- }
+ if (scale_factor != device_scale_factor_)
+ SetDeviceScaleFactor(scale_factor);
- if (!frame_rect.size().IsEmpty()) {
- child_frame_rect_ = frame_rect;
- if (view_)
- view_->SetSize(frame_rect.size());
- }
+ if (!frame_rect.size().IsEmpty())
+ SetSize(frame_rect);
}
gfx::Rect CrossProcessFrameConnector::ChildFrameRect() {
@@ -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
diff --git a/content/browser/frame_host/cross_process_frame_connector.h b/content/browser/frame_host/cross_process_frame_connector.h
index 4a94087..b3d87a4 100644
--- a/content/browser/frame_host/cross_process_frame_connector.h
+++ b/content/browser/frame_host/cross_process_frame_connector.h
@@ -101,6 +101,9 @@ class CrossProcessFrameConnector {
void OnForwardInputEvent(const blink::WebInputEvent* event);
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
// process.
// TODO(kenrb): The type becomes RenderFrameProxyHost when that class comes
diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc
index d39d388..0dfdeaa 100644
--- a/content/browser/frame_host/render_frame_host_manager.cc
+++ b/content/browser/frame_host/render_frame_host_manager.cc
@@ -22,6 +22,7 @@
#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_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_view_host_factory.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
@@ -34,6 +35,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.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/web_ui_controller.h"
#include "content/public/common/content_switches.h"
@@ -176,7 +178,7 @@ RenderFrameHostImpl* RenderFrameHostManager::Navigate(
// soon anyway, and we don't have the NavigationEntry for this host.
delegate_->CreateRenderViewForRenderManager(
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
@@ -186,7 +188,9 @@ RenderFrameHostImpl* RenderFrameHostManager::Navigate(
int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager(
dest_render_frame_host->GetSiteInstance());
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;
// Now that we've created a new renderer, be sure to hide it if it isn't
@@ -501,6 +505,9 @@ void RenderFrameHostManager::SwapOutOldPage() {
// process navigations, but it will be destroyed if the Frame is
// navigated back to the same site instance as its parent.
// 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_) {
cross_process_frame_connector_ =
new CrossProcessFrameConnector(render_frame_host_.get());
@@ -965,7 +972,8 @@ int RenderFrameHostManager::CreateRenderFrame(
}
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()) {
// Don't show the main frame's view until we get a DidNavigate from it.
render_view_host->GetView()->Hide();
@@ -984,7 +992,8 @@ int RenderFrameHostManager::CreateRenderFrame(
bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host,
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.
if (render_view_host->IsRenderViewLive())
return true;
@@ -1006,8 +1015,7 @@ bool RenderFrameHostManager::InitRenderView(RenderViewHost* render_view_host,
}
return delegate_->CreateRenderViewForRenderManager(
- render_view_host, opener_route_id, proxy_routing_id,
- cross_process_frame_connector_);
+ render_view_host, opener_route_id, proxy_routing_id, for_main_frame);
}
void RenderFrameHostManager::CommitPending() {
@@ -1164,8 +1172,20 @@ void RenderFrameHostManager::CommitPending() {
// 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
// in this SiteInstance.
- if (!active_view_count)
+ if (!active_view_count) {
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);
+ }
+ }
}
}
diff --git a/content/browser/frame_host/render_frame_host_manager.h b/content/browser/frame_host/render_frame_host_manager.h
index dce2dbb..d71845e 100644
--- a/content/browser/frame_host/render_frame_host_manager.h
+++ b/content/browser/frame_host/render_frame_host_manager.h
@@ -57,12 +57,14 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
// 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
// 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(
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
- CrossProcessFrameConnector* cross_process_frame_connector) = 0;
+ bool for_main_frame) = 0;
virtual void BeforeUnloadFiredFromRenderManager(
bool proceed, const base::TimeTicks& proceed_time,
bool* proceed_to_fire_unload) = 0;
@@ -379,7 +381,8 @@ class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
// be for the RenderFrame, since frames can have openers.
bool InitRenderView(RenderViewHost* render_view_host,
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
// doesn't require the pending render_frame_host_ pointer to be non-NULL,
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 595bdc1..bf7cc7d 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3876,7 +3876,7 @@ bool WebContentsImpl::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
- CrossProcessFrameConnector* frame_connector) {
+ bool for_main_frame) {
TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderViewForRenderManager");
// Can be NULL during tests.
RenderWidgetHostViewBase* rwh_view;
@@ -3884,10 +3884,9 @@ bool WebContentsImpl::CreateRenderViewForRenderManager(
// until RenderWidgetHost is attached to RenderFrameHost. We need to special
// 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.
- if (frame_connector) {
+ if (!for_main_frame) {
RenderWidgetHostViewChildFrame* rwh_view_child =
new RenderWidgetHostViewChildFrame(render_view_host);
- frame_connector->set_view(rwh_view_child);
rwh_view = rwh_view_child;
} else {
rwh_view = view_->CreateViewForWidget(render_view_host);
@@ -3942,7 +3941,7 @@ bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() {
return CreateRenderViewForRenderManager(GetRenderViewHost(),
MSG_ROUTING_NONE,
MSG_ROUTING_NONE,
- NULL);
+ true);
}
#elif defined(OS_MACOSX)
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 268749e..e11c3a0 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -517,7 +517,7 @@ class CONTENT_EXPORT WebContentsImpl
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
- CrossProcessFrameConnector* frame_connector) OVERRIDE;
+ bool for_main_frame) OVERRIDE;
virtual void BeforeUnloadFiredFromRenderManager(
bool proceed, const base::TimeTicks& proceed_time,
bool* proceed_to_fire_unload) OVERRIDE;
diff --git a/content/test/test_web_contents.cc b/content/test/test_web_contents.cc
index 755f79e..a9c239e2 100644
--- a/content/test/test_web_contents.cc
+++ b/content/test/test_web_contents.cc
@@ -100,7 +100,7 @@ bool TestWebContents::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
- CrossProcessFrameConnector* frame_connector) {
+ bool for_main_frame) {
UpdateMaxPageIDIfNecessary(render_view_host);
// This will go to a TestRenderViewHost.
static_cast<RenderViewHostImpl*>(
diff --git a/content/test/test_web_contents.h b/content/test/test_web_contents.h
index 2470767..e42abfe 100644
--- a/content/test/test_web_contents.h
+++ b/content/test/test_web_contents.h
@@ -60,7 +60,7 @@ class TestWebContents : public WebContentsImpl, public WebContentsTester {
RenderViewHost* render_view_host,
int opener_route_id,
int proxy_routing_id,
- CrossProcessFrameConnector* frame_connector) OVERRIDE;
+ bool for_main_frame) OVERRIDE;
virtual void UpdateRenderViewSizeForRenderManager() OVERRIDE {}
// Returns a clone of this TestWebContents. The returned object is also a