Index: chrome/browser/prerender/prerender_manager.cc |
=================================================================== |
--- chrome/browser/prerender/prerender_manager.cc (revision 265252) |
+++ chrome/browser/prerender/prerender_manager.cc (working copy) |
@@ -58,6 +58,7 @@ |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/session_storage_namespace.h" |
+#include "content/public/browser/storage_partition.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_delegate.h" |
#include "content/public/browser/web_contents_view.h" |
@@ -246,7 +247,8 @@ |
prerender_history_(new PrerenderHistory(kHistoryLength)), |
histograms_(new PrerenderHistograms()), |
profile_network_bytes_(0), |
- last_recorded_profile_network_bytes_(0) { |
+ last_recorded_profile_network_bytes_(0), |
+ cookie_store_loaded_(false) { |
// There are some assumptions that the PrerenderManager is on the UI thread. |
// Any other checks simply make sure that the PrerenderManager is accessed on |
// the same thread that it was created on. |
@@ -578,6 +580,8 @@ |
} |
// At this point, we've determined that we will use the prerender. |
+ prerender_tracker()->OnPrerenderSwapped( |
+ prerender_data->contents()->GetRenderViewHost()->GetProcess()); |
if (!prerender_data->contents()->load_start_time().is_null()) { |
histograms_->RecordTimeUntilUsed( |
prerender_data->contents()->origin(), |
@@ -1218,6 +1222,12 @@ |
SortActivePrerenders(); |
} |
+net::URLRequestContextGetter* PrerenderManager::GetURLRequestContext() { |
+ return content::BrowserContext::GetDefaultStoragePartition(profile_)-> |
+ GetURLRequestContext(); |
+} |
+ |
+ |
// private |
PrerenderHandle* PrerenderManager::AddPrerender( |
Origin origin, |
@@ -1282,6 +1292,13 @@ |
return NULL; |
} |
+ if (!cookie_store_loaded()) { |
+ // Only prerender if the cookie store for this profile has been loaded. |
+ // This is required by PrerenderCookieMonster. |
+ RecordFinalStatus(origin, experiment, FINAL_STATUS_COOKIE_STORE_NOT_LOADED); |
+ return NULL; |
+ } |
+ |
PrerenderContents* prerender_contents = CreatePrerenderContents( |
url, referrer, origin, experiment); |
DCHECK(prerender_contents); |
@@ -1306,11 +1323,16 @@ |
gfx::Size contents_size = |
size.IsEmpty() ? config_.default_tab_bounds.size() : size; |
+ net::URLRequestContextGetter* request_context = GetURLRequestContext(); |
+ |
prerender_contents->StartPrerendering(process_id, contents_size, |
- session_storage_namespace); |
+ session_storage_namespace, |
+ request_context); |
DCHECK(IsControlGroup(experiment) || |
- prerender_contents->prerendering_has_started()); |
+ prerender_contents->prerendering_has_started() || |
+ (origin == ORIGIN_LOCAL_PREDICTOR && |
+ IsLocalPredictorPrerenderAlwaysControlEnabled())); |
if (GetMode() == PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP) |
histograms_->RecordConcurrency(active_prerenders_.size()); |
@@ -1828,4 +1850,10 @@ |
profile_network_bytes_ += bytes; |
} |
+void PrerenderManager::OnCookieStoreLoaded() { |
+ cookie_store_loaded_ = true; |
+ if (!on_cookie_store_loaded_cb_.is_null()) |
+ on_cookie_store_loaded_cb_.Run(); |
+} |
+ |
} // namespace prerender |