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

Unified Diff: chrome/browser/prerender/prerender_contents.cc

Issue 7693029: Deflake PrerenderExcessiveMemory, fix race (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Oops Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_contents.cc
===================================================================
--- chrome/browser/prerender/prerender_contents.cc (revision 98422)
+++ chrome/browser/prerender/prerender_contents.cc (working copy)
@@ -172,7 +172,6 @@
prerender_contents_.reset(new TabContentsWrapper(new_contents));
TabContentsObserver::Observe(new_contents);
- gfx::Rect tab_bounds;
if (source_render_view_host) {
DCHECK(source_render_view_host->view() != NULL);
TabContents* source_tc =
@@ -183,7 +182,7 @@
starting_page_id_ = source_tc->GetMaxPageID();
// Set the size of the new TC to that of the old TC.
- source_tc->view()->GetContainerBounds(&tab_bounds);
+ source_tc->view()->GetContainerBounds(&tab_bounds_);
}
} else {
int max_page_id = -1;
@@ -209,7 +208,7 @@
if (active_browser) {
TabContents* active_tab_contents = active_browser->GetTabContentsAt(
active_browser->active_index());
- active_tab_contents->view()->GetContainerBounds(&tab_bounds);
+ active_tab_contents->view()->GetContainerBounds(&tab_bounds_);
}
}
@@ -223,9 +222,6 @@
tab_contents_delegate_.reset(new TabContentsDelegateImpl(this));
new_contents->set_delegate(tab_contents_delegate_.get());
- // Set the size of the prerender TabContents.
- prerender_contents_->view()->SizeContents(tab_bounds.size());
-
// Register as an observer of the RenderViewHost so we get messages.
render_view_host_observer_.reset(
new PrerenderRenderViewHostObserver(this, render_view_host_mutable()));
@@ -258,12 +254,6 @@
this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
Source<TabContents>(new_contents));
- // Register to be told when the RenderView is ready, so we can hide it.
- // It will automatically be set to visible when we resize it, otherwise.
- notification_registrar_.Add(this,
- content::NOTIFICATION_TAB_CONTENTS_CONNECTED,
- Source<TabContents>(new_contents));
-
// Register for redirect notifications sourced from |this|.
notification_registrar_.Add(
this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
@@ -381,20 +371,17 @@
new ChromeViewMsg_SetIsPrerendering(
new_render_view_host->routing_id(),
true));
- }
- break;
- }
- case content::NOTIFICATION_TAB_CONTENTS_CONNECTED: {
- if (prerender_contents_.get()) {
- DCHECK_EQ(Source<TabContents>(source).ptr(),
- prerender_contents_->tab_contents());
- // Set the new TabContents and its RenderViewHost as hidden, to reduce
- // resource usage. This can only be done after the size has been sent
- // to the RenderView, which is why it's done here.
+ // Set the size of the prerender TabContents. This must be done after
+ // the RenderView has been created so that the RenderView will be
+ // informated promptly of the size change.
cbentzel 2011/08/29 12:26:18 Nit: informed
+ prerender_contents_->view()->SizeContents(tab_bounds_.size());
cbentzel 2011/08/29 12:26:18 Is the RenderWidgetHostView hidden at this point?
mmenke 2011/08/29 12:30:35 RenderWidgetHostViews start out as visible. This
+
+ // Hide the tab contents. Must be done after setting the size, as
+ // resizing currently forces the RenderView to set itself as visible.
prerender_contents_->tab_contents()->HideContents();
}
- return;
+ break;
}
case content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED: {

Powered by Google App Engine
This is Rietveld 408576698