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

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

Issue 10198040: New link rel=prerender api, using WebKit::WebPrerenderingPlatform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the urls_to_id_map_, and follow consequences through. Created 8 years, 8 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
diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc
index 098a67a74cb737c1920b8e06b86768543ec1dc75..5aab1c38b83ba3fb5d48eb9acc44612f3b23bef4 100644
--- a/chrome/browser/prerender/prerender_contents.cc
+++ b/chrome/browser/prerender/prerender_contents.cc
@@ -96,15 +96,6 @@ class PrerenderContentsFactoryImpl : public PrerenderContents::Factory {
}
};
-PrerenderContents::PendingPrerenderData::PendingPrerenderData(
- Origin origin,
- const GURL& url,
- const content::Referrer& referrer)
- : origin(origin),
- url(url),
- referrer(referrer) {
-}
-
// TabContentsDelegateImpl -----------------------------------------------------
class PrerenderContents::TabContentsDelegateImpl
@@ -197,11 +188,10 @@ class PrerenderContents::TabContentsDelegateImpl
PrerenderContents* prerender_contents_;
};
-void PrerenderContents::AddPendingPrerender(Origin origin,
- const GURL& url,
+void PrerenderContents::AddPendingPrerender(const GURL& url,
dominich 2012/04/29 18:52:55 I was worried about the loss of Origin here, but i
gavinp 2012/04/30 11:43:16 I'll ping Timo, who's writing the history navigato
dominich 2012/04/30 15:52:05 None that are in active development, and it would
const content::Referrer& referrer) {
pending_prerender_list_.push_back(
dominich 2012/04/29 18:52:55 nit: this line should be merged with the one below
gavinp 2012/04/30 11:43:16 Done.
- PendingPrerenderData(origin, url, referrer));
+ PendingPrerenderData(url, referrer));
}
bool PrerenderContents::IsPendingEntry(const GURL& url) const {
@@ -209,7 +199,7 @@ bool PrerenderContents::IsPendingEntry(const GURL& url) const {
pending_prerender_list_.begin();
it != pending_prerender_list_.end();
++it) {
- if (it->url == url)
+ if (it->first == url)
return true;
}
return false;
@@ -221,11 +211,11 @@ void PrerenderContents::StartPendingPrerenders() {
for (PendingPrerenderList::iterator it = pending_prerender_list.begin();
it != pending_prerender_list.end();
++it) {
- prerender_manager_->AddPrerender(it->origin,
- std::make_pair(child_id_, route_id_),
- it->url,
- it->referrer,
- NULL);
+ RenderViewHost* render_view_host = RenderViewHost::FromID(child_id_,
+ route_id_);
+ prerender_manager_->AddPrerenderFromLinkRelPrerender(
dominich 2012/04/29 18:52:55 as above, this assumption makes me nervous.
gavinp 2012/04/30 11:43:16 I think it's easy enough to add back if we need to
+ child_id_, route_id_, it->first, it->second, size_,
dominich 2012/04/29 18:52:55 is it possible that the WebView size has changed s
gavinp 2012/04/30 11:43:16 I believe that the prerender can't change size whi
dominich 2012/04/30 15:52:05 It sounds like we already have an issue that we mi
mmenke 2012/04/30 18:35:22 It's currently not possible for a hidden WebView t
+ render_view_host->GetSessionStorageNamespace());
}
}
@@ -267,17 +257,20 @@ PrerenderContents::Factory* PrerenderContents::CreateFactory() {
}
void PrerenderContents::StartPrerendering(
- const RenderViewHost* source_render_view_host,
+ int creator_child_id,
+ const gfx::Size& size,
content::SessionStorageNamespace* session_storage_namespace) {
DCHECK(profile_ != NULL);
DCHECK(!prerendering_has_started_);
DCHECK(prerender_contents_.get() == NULL);
+ DCHECK_EQ(-1, creator_child_id_);
+ DCHECK(size_.IsEmpty());
+
+ creator_child_id_ = creator_child_id;
+ size_ = size;
prerendering_has_started_ = true;
- DCHECK(creator_child_id_ == -1);
- DCHECK(alias_urls_.size() == 1);
- if (source_render_view_host)
- creator_child_id_ = source_render_view_host->GetProcess()->GetID();
+ DCHECK_EQ(1U, alias_urls_.size());
InformRenderProcessAboutPrerender(prerender_url_, true,
creator_child_id_);
@@ -285,16 +278,8 @@ void PrerenderContents::StartPrerendering(
prerender_contents_.reset(new TabContentsWrapper(new_contents));
content::WebContentsObserver::Observe(new_contents);
- gfx::Rect tab_bounds = prerender_manager_->config().default_tab_bounds;
- if (source_render_view_host) {
- DCHECK(source_render_view_host->GetView() != NULL);
- WebContents* source_wc =
- source_render_view_host->GetDelegate()->GetAsWebContents();
- if (source_wc) {
- // Set the size of the new TC to that of the old TC.
- source_wc->GetView()->GetContainerBounds(&tab_bounds);
- }
- } else {
+ if (size_.IsEmpty()) {
dominich 2012/04/29 18:52:55 will this ever happen now the size is coming from
gavinp 2012/04/30 11:43:16 Yes. Omnibox prerendering is probably the biggest
+ size_ = prerender_manager_->config().default_tab_bounds.size();
#if !defined(OS_ANDROID)
// Try to get the active tab of the active browser and use that for tab
// bounds. If the browser has never been active, we will fail to get a size
@@ -303,12 +288,14 @@ void PrerenderContents::StartPrerendering(
// This code is unneeded on Android as we do not have a Browser object so we
// can't get the size, and |default_tab_bounds| will be set to the right
// value.
- Browser* active_browser = BrowserList::GetLastActiveWithProfile(profile_);
- if (active_browser) {
+ if (Browser* active_browser =
+ BrowserList::GetLastActiveWithProfile(profile_)) {
WebContents* active_web_contents = active_browser->GetWebContentsAt(
active_browser->active_index());
+ gfx::Rect container_bounds;
if (active_web_contents)
- active_web_contents->GetView()->GetContainerBounds(&tab_bounds);
+ active_web_contents->GetView()->GetContainerBounds(&container_bounds);
+ size_ = container_bounds.size();
}
#endif // !defined(OS_ANDROID)
}
@@ -317,8 +304,7 @@ void PrerenderContents::StartPrerendering(
new_contents->SetDelegate(tab_contents_delegate_.get());
// Set the size of the prerender WebContents.
- prerender_contents_->web_contents()->GetView()->SizeContents(
- tab_bounds.size());
+ prerender_contents_->web_contents()->GetView()->SizeContents(size_);
// Register as an observer of the RenderViewHost so we get messages.
render_view_host_observer_.reset(

Powered by Google App Engine
This is Rietveld 408576698