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

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

Issue 10918189: Add PrerenderStatusEvent on Prerenders (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase to trunk, remove some unrelated fixes... Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/prerender/prerender_contents.h ('k') | chrome/browser/prerender/prerender_link_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_contents.cc
diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc
index 1fa00d98233a91841de4f7ebbb4398439743ea21..02ab5bd396e8855c283f58d27d6ab7e7a9f9ec46 100644
--- a/chrome/browser/prerender/prerender_contents.cc
+++ b/chrome/browser/prerender/prerender_contents.cc
@@ -36,6 +36,7 @@
using content::DownloadItem;
using content::OpenURLParams;
+using content::RenderProcessHost;
using content::RenderViewHost;
using content::ResourceRedirectDetails;
using content::SessionStorageNamespace;
@@ -43,33 +44,6 @@ using content::WebContents;
namespace prerender {
-namespace {
-
-// 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 the user
-// clicks on a link for a prerendered URL in a different page, the prerender
-// will not be swapped in.
-void InformRenderProcessAboutPrerender(const GURL& url,
- 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)
- message = new PrerenderMsg_AddPrerenderURL(url);
- else
- message = new PrerenderMsg_RemovePrerenderURL(url);
- render_process_host->Send(message);
-}
-
-} // namespace
-
class PrerenderContentsFactoryImpl : public PrerenderContents::Factory {
public:
virtual PrerenderContents* CreatePrerenderContents(
@@ -276,6 +250,7 @@ PrerenderContents::Factory* PrerenderContents::CreateFactory() {
void PrerenderContents::StartPrerendering(
int creator_child_id,
+ int prerender_id,
const gfx::Size& size,
SessionStorageNamespace* session_storage_namespace,
bool is_control_group) {
@@ -288,11 +263,12 @@ void PrerenderContents::StartPrerendering(
DCHECK_EQ(1U, alias_urls_.size());
creator_child_id_ = creator_child_id;
+ prerender_id_ = prerender_id;
session_storage_namespace_id_ = session_storage_namespace->id();
size_ = size;
- InformRenderProcessAboutPrerender(prerender_url_, true,
- creator_child_id_);
+ if (RenderProcessHost* host = RenderProcessHost::FromID(creator_child_id_))
+ host->Send(new PrerenderMsg_StartedPrerender(prerender_id_));
DCHECK(load_start_time_.is_null());
load_start_time_ = base::TimeTicks::Now();
@@ -391,24 +367,18 @@ void PrerenderContents::set_final_status(FinalStatus final_status) {
}
PrerenderContents::~PrerenderContents() {
- DCHECK(final_status_ != FINAL_STATUS_MAX);
- DCHECK(prerendering_has_been_cancelled_ ||
- final_status_ == FINAL_STATUS_USED);
- DCHECK(origin_ != ORIGIN_MAX);
+ DCHECK_NE(FINAL_STATUS_MAX, final_status_);
+ DCHECK(
+ prerendering_has_been_cancelled_ || final_status_ == FINAL_STATUS_USED);
+ DCHECK_NE(ORIGIN_MAX, origin_);
prerender_manager_->RecordFinalStatusWithMatchCompleteStatus(
- origin_,
- experiment_id_,
- match_complete_status_,
- final_status_);
+ origin_, experiment_id_, match_complete_status_, final_status_);
if (child_id_ != -1 && route_id_ != -1) {
prerender_tracker_->OnPrerenderingFinished(child_id_, route_id_);
- for (std::vector<GURL>::const_iterator it = alias_urls_.begin();
- it != alias_urls_.end();
- ++it) {
- InformRenderProcessAboutPrerender(*it, false, creator_child_id_);
- }
+ if (RenderProcessHost* host = RenderProcessHost::FromID(creator_child_id_))
+ host->Send(new PrerenderMsg_StoppedPrerender(prerender_id_));
}
// If we still have a WebContents, clean up anything we need to and then
@@ -531,7 +501,8 @@ bool PrerenderContents::AddAliasURL(const GURL& url) {
}
alias_urls_.push_back(url);
- InformRenderProcessAboutPrerender(url, true, creator_child_id_);
+ if (RenderProcessHost* host = RenderProcessHost::FromID(creator_child_id_))
+ host->Send(new PrerenderMsg_AddAliasToPrerender(prerender_id_, url));
return true;
}
« no previous file with comments | « chrome/browser/prerender/prerender_contents.h ('k') | chrome/browser/prerender/prerender_link_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698