Chromium Code Reviews| Index: chrome/browser/prerender/prerender_contents.cc |
| diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc |
| index c6355229ebc06cfa4a38c2a4832df6aaccfb9e32..82ca15b52b42c3a42f5e60b4efc9635348015bee 100644 |
| --- a/chrome/browser/prerender/prerender_contents.cc |
| +++ b/chrome/browser/prerender/prerender_contents.cc |
| @@ -21,7 +21,7 @@ |
| #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/icon_messages.h" |
| -#include "chrome/common/render_messages.h" |
| +#include "chrome/common/prerender_messages.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/browser/in_process_webkit/session_storage_namespace.h" |
| #include "content/browser/renderer_host/render_view_host.h" |
| @@ -62,6 +62,30 @@ struct PrerenderURLPredicate { |
| GURL url_; |
| }; |
| +// Tells the render process at |child_id| whether |url| is a new prerendered |
| +// page, or whether |url| is being removed as a prerendered page. Currently |
| +// this will only inform the render process that created the prerendered page |
| +// with <link rel="prerender"> tags about it. This means that if a prerender |
| +// is created from the omnibox or from another page, clicking on the a link |
| +// for the same URL in another page will not swap in the prerender. |
|
dominich
2012/02/29 18:32:01
This isn't a problem for Omnibox as we cancel the
cbentzel
2012/02/29 19:22:36
Done.
|
| +void InformRenderProcessAboutPrerender(const GURL& url, |
|
dominich
2012/02/29 18:32:01
Given this is only called from methods in this cla
cbentzel
2012/02/29 19:22:36
I like it here, because it means that if it change
dominich
2012/02/29 19:44:35
Not modifying a header is a poor reason to base AP
cbentzel
2012/02/29 19:50:10
Huh? It's a pretty stateless function, and does no
|
| + bool is_add, |
| + int child_id) { |
| + if (child_id < 0) |
| + return; |
| + content::RenderProcessHost* render_process_host = |
| + content::RenderProcessHost::FromID(child_id); |
| + if (!render_process_host) |
| + return; |
| + IPC::Message* message = NULL; |
| + if (is_add) { |
|
dominich
2012/02/29 18:32:01
nit: {} not required
cbentzel
2012/02/29 19:22:36
Done.
|
| + message = new PrerenderMsg_AddPrerenderURL(url); |
| + } else { |
| + message = new PrerenderMsg_RemovePrerenderURL(url); |
| + } |
| + render_process_host->Send(message); |
| +} |
| + |
| } // end namespace |
| class PrerenderContentsFactoryImpl : public PrerenderContents::Factory { |
| @@ -227,7 +251,8 @@ PrerenderContents::PrerenderContents( |
| child_id_(-1), |
| route_id_(-1), |
| origin_(origin), |
| - experiment_id_(experiment_id) { |
| + experiment_id_(experiment_id), |
| + creator_child_id_(-1) { |
| DCHECK(prerender_manager != NULL); |
| } |
| @@ -248,6 +273,12 @@ void PrerenderContents::StartPrerendering( |
| DCHECK(prerender_contents_.get() == NULL); |
| prerendering_has_started_ = true; |
| + DCHECK(creator_child_id_ == -1); |
| + if (source_render_view_host) |
| + creator_child_id_ = source_render_view_host->process()->GetID(); |
| + InformRenderProcessAboutPrerender(prerender_url_, true, |
| + creator_child_id_); |
| + |
| WebContents* new_contents = WebContents::Create( |
| profile_, NULL, MSG_ROUTING_NONE, NULL, session_storage_namespace); |
| prerender_contents_.reset(new TabContentsWrapper(new_contents)); |
| @@ -418,7 +449,7 @@ void PrerenderContents::Observe(int type, |
| // first navigation, so there's no need to send the message just after |
| // the TabContents is created. |
| new_render_view_host->Send( |
| - new ChromeViewMsg_SetIsPrerendering( |
| + new PrerenderMsg_SetIsPrerendering( |
| new_render_view_host->routing_id(), |
| true)); |
| @@ -543,6 +574,7 @@ bool PrerenderContents::ShouldSuppressDialogs() { |
| } |
| void PrerenderContents::Destroy(FinalStatus final_status) { |
| + InformRenderProcessAboutPrerender(prerender_url_, false, creator_child_id_); |
| if (prerendering_has_been_cancelled_) |
| return; |