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..d967fc17b21f05aeb0872722f16f83b16bc21801 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" |
| @@ -240,6 +240,27 @@ PrerenderContents::Factory* PrerenderContents::CreateFactory() { |
| return new PrerenderContentsFactoryImpl(); |
| } |
| +void BroadcastPrerender(const GURL& url, bool is_add) { |
| + content::RenderProcessHost::iterator host_it = |
| + content::RenderProcessHost::AllHostsIterator(); |
| + while (!host_it.IsAtEnd()) { |
| + content::RenderProcessHost* host = host_it.GetCurrentValue(); |
| + host_it.Advance(); |
| + if (!host) |
| + continue; |
| + // TODO(cbentzel): Need to filter to the current profile only. |
|
dominich
2012/02/28 16:21:00
Should you also filter to the RPH that was the sou
cbentzel
2012/02/29 18:16:13
I am limiting to that now, per your comment as wel
|
| + IPC::Message* message = NULL; |
|
dominich
2012/02/28 16:21:00
IPC::Message* message = is_add ? new PrerenderMsg_
cbentzel
2012/02/29 18:16:13
This doesn't work because then the operands of the
|
| + if (is_add) { |
| + message = new PrerenderMsg_AddPrerenderURL(url); |
| + } else { |
| + message = new PrerenderMsg_RemovePrerenderURL(url); |
| + } |
| + // TODO(cbentzel): Make sure that sending a message doesn't |
| + // adjust the iterator. |
| + host->Send(message); |
| + } |
| +} |
| + |
| void PrerenderContents::StartPrerendering( |
| const RenderViewHost* source_render_view_host, |
| SessionStorageNamespace* session_storage_namespace) { |
| @@ -248,6 +269,8 @@ void PrerenderContents::StartPrerendering( |
| DCHECK(prerender_contents_.get() == NULL); |
| prerendering_has_started_ = true; |
| + BroadcastPrerender(prerender_url_, true); |
| + |
| WebContents* new_contents = WebContents::Create( |
| profile_, NULL, MSG_ROUTING_NONE, NULL, session_storage_namespace); |
| prerender_contents_.reset(new TabContentsWrapper(new_contents)); |
| @@ -418,7 +441,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 +566,7 @@ bool PrerenderContents::ShouldSuppressDialogs() { |
| } |
| void PrerenderContents::Destroy(FinalStatus final_status) { |
| + BroadcastPrerender(prerender_url_, false); |
| if (prerendering_has_been_cancelled_) |
| return; |