summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 20:39:39 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 20:39:39 +0000
commite64648531fc7386c139dffadefa746996264b90f (patch)
tree8e2a30eed93431b1f8c80f9af8ce58bce0f1aede
parent827467f6dbf1b31ac76e68f76765bdf8549a08fe (diff)
downloadchromium_src-e64648531fc7386c139dffadefa746996264b90f.zip
chromium_src-e64648531fc7386c139dffadefa746996264b90f.tar.gz
chromium_src-e64648531fc7386c139dffadefa746996264b90f.tar.bz2
PrerenderBrowserTest.PrerenderHTTPS was failing for some reason.
Revert 85021 - Hide a TabContents's RenderViewHost while prerendering. Should prevent offscreen drawing before display, except in cases of WebGL, Canvas2D, and the like. BUG=none Test=PrerenderBrowserTest.* Review URL: http://codereview.chromium.org/6975004 TBR=mmenke@chromium.org Review URL: http://codereview.chromium.org/7015005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85037 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc51
-rw-r--r--chrome/browser/prerender/prerender_contents.cc26
-rw-r--r--chrome/browser/prerender/prerender_contents.h8
-rw-r--r--chrome/browser/prerender/prerender_manager.cc3
4 files changed, 8 insertions, 80 deletions
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 2a11291..a8b274f 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -20,7 +20,6 @@
#include "chrome/test/ui_test_utils.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/common/notification_service.h"
#include "grit/generated_resources.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
@@ -63,28 +62,17 @@ class TestPrerenderContents : public PrerenderContents {
: PrerenderContents(prerender_manager, profile, url, referrer),
number_of_loads_(0),
expected_number_of_loads_(number_of_loads),
- expected_final_status_(expected_final_status),
- was_hidden_(false),
- was_shown_(false) {
+ expected_final_status_(expected_final_status) {
}
virtual ~TestPrerenderContents() {
EXPECT_EQ(expected_final_status_, final_status()) <<
" when testing URL " << prerender_url().path();
- // Prerendering RenderViewHosts should be hidden before the first
- // navigation, so this should be happen for every PrerenderContents that's
- // created, regardless of whether or not it's used.
- EXPECT_TRUE(was_hidden_);
-
// A used PrerenderContents will only be destroyed when we swap out
// TabContents, at the end of a navigation caused by a call to
// NavigateToURLImpl().
- if (final_status() == FINAL_STATUS_USED) {
- EXPECT_TRUE(was_shown_);
+ if (final_status() == FINAL_STATUS_USED)
MessageLoopForUI::current()->Quit();
- } else {
- EXPECT_FALSE(was_shown_);
- }
}
virtual void OnRenderViewGone(int status, int exit_code) OVERRIDE {
@@ -120,44 +108,9 @@ class TestPrerenderContents : public PrerenderContents {
}
private:
- virtual void OnRenderViewHostCreated(
- RenderViewHost* new_render_view_host) OVERRIDE {
- // Used to make sure the RenderViewHost is hidden and, if used,
- // subsequently shown.
- notification_registrar().Add(
- this,
- NotificationType::RENDER_WIDGET_VISIBILITY_CHANGED,
- Source<RenderWidgetHost>(new_render_view_host));
- PrerenderContents::OnRenderViewHostCreated(new_render_view_host);
- }
-
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) OVERRIDE {
- if (type.value ==
- NotificationType::RENDER_WIDGET_VISIBILITY_CHANGED) {
- bool is_visible = *Details<bool>(details).ptr();
- if (!is_visible) {
- was_hidden_ = true;
- } else if (is_visible && was_hidden_) {
- // Once hidden, a prerendered RenderViewHost should only be shown after
- // being removed from the PrerenderContents for display.
- EXPECT_FALSE(render_view_host());
- was_shown_ = true;
- }
- return;
- }
- PrerenderContents::Observe(type, source, details);
- }
-
int number_of_loads_;
int expected_number_of_loads_;
FinalStatus expected_final_status_;
- // Set to true when the prerendering RenderWidget is hidden.
- bool was_hidden_;
- // Set to true when the prerendering RenderWidget is shown, after having been
- // hidden.
- bool was_shown_;
};
// PrerenderManager that uses TestPrerenderContents.
diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc
index 2f2ebd0..4a989bc 100644
--- a/chrome/browser/prerender/prerender_contents.cc
+++ b/chrome/browser/prerender/prerender_contents.cc
@@ -129,8 +129,6 @@ void PrerenderContents::StartPrerenderingOld(
// Create the RenderView, so it can receive messages.
render_view_host_->CreateRenderView(string16());
- OnRenderViewHostCreated(render_view_host_);
-
// Give the RVH a PrerenderRenderWidgetHostView, both so its size can be set
// and so that the prerender can be cancelled under certain circumstances.
PrerenderRenderWidgetHostView* view =
@@ -475,29 +473,19 @@ void PrerenderContents::Observe(NotificationType type,
}
case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: {
+ // When a new RenderView is created for a prerendering TabContents,
+ // tell the new RenderView it's being used for prerendering before any
+ // navigations occur. Note that this is always triggered before the
+ // first navigation, so there's no need to send the message just after the
+ // TabContents is created.
if (prerender_contents_.get()) {
DCHECK_EQ(Source<TabContents>(source).ptr(),
prerender_contents_->tab_contents());
Details<RenderViewHost> new_render_view_host(details);
- OnRenderViewHostCreated(new_render_view_host.ptr());
-
- // When a new RenderView is created for a prerendering TabContents,
- // tell the new RenderView it's being used for prerendering before any
- // navigations occur. Note that this is always triggered before the
- // first navigation, so there's no need to send the message just after
- // the TabContents is created.
new_render_view_host->Send(
new ViewMsg_SetIsPrerendering(new_render_view_host->routing_id(),
true));
-
- // Set the new TabContents and its RenderViewHost as hidden, to reduce
- // resource usage. This can only be done after the first call to
- // LoadURL, so there's an actual RenderViewHost with a
- // RenderWidgetHostView to hide.
- //
- // Done here to prevent a race with loading the page.
- prerender_contents_->tab_contents()->HideContents();
}
break;
}
@@ -598,10 +586,6 @@ void PrerenderContents::ShowCreatedFullscreenWidget(int route_id) {
NOTIMPLEMENTED();
}
-void PrerenderContents::OnRenderViewHostCreated(
- RenderViewHost* new_render_view_host) {
-}
-
void PrerenderContents::OnDidStartProvisionalLoadForFrame(int64 frame_id,
bool is_main_frame,
const GURL& url) {
diff --git a/chrome/browser/prerender/prerender_contents.h b/chrome/browser/prerender/prerender_contents.h
index a77c8cf..b4b8736 100644
--- a/chrome/browser/prerender/prerender_contents.h
+++ b/chrome/browser/prerender/prerender_contents.h
@@ -256,14 +256,6 @@ class PrerenderContents : public RenderViewHostDelegate,
const GURL& prerender_url() const { return prerender_url_; }
- NotificationRegistrar& notification_registrar() {
- return notification_registrar_;
- }
-
- // Called whenever a RenderViewHost is created for prerendering. Only called
- // once the RenderViewHost has a RenderView and RenderWidgetHostView.
- virtual void OnRenderViewHostCreated(RenderViewHost* new_render_view_host);
-
private:
// Needs to be able to call the constructor.
friend class PrerenderContentsFactoryImpl;
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index c8f38b6..e17cc27 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -441,11 +441,10 @@ bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents,
RenderViewHost* render_view_host =
prerender_contents->render_view_host_mutable();
- prerender_contents->set_render_view_host(NULL);
-
// RenderViewHosts in PrerenderContents start out hidden.
// Since we are actually using it now, restore it.
render_view_host->WasRestored();
+ prerender_contents->set_render_view_host(NULL);
render_view_host->Send(
new ViewMsg_SetIsPrerendering(render_view_host->routing_id(), false));
tab_contents->SwapInRenderViewHost(render_view_host);