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

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 286433002: Add to the prerender history when no PrerenderContents is created. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 MaybeGetQueryStringBasedAliasURL(url, &alias_url)) { 1265 MaybeGetQueryStringBasedAliasURL(url, &alias_url)) {
1266 url = alias_url; 1266 url = alias_url;
1267 } 1267 }
1268 1268
1269 // From here on, we will record a FinalStatus so we need to register with the 1269 // From here on, we will record a FinalStatus so we need to register with the
1270 // histogram tracking. 1270 // histogram tracking.
1271 histograms_->RecordPrerender(origin, url_arg); 1271 histograms_->RecordPrerender(origin, url_arg);
1272 1272
1273 if (PrerenderData* preexisting_prerender_data = 1273 if (PrerenderData* preexisting_prerender_data =
1274 FindPrerenderData(url, session_storage_namespace)) { 1274 FindPrerenderData(url, session_storage_namespace)) {
1275 RecordFinalStatus(origin, experiment, FINAL_STATUS_DUPLICATE); 1275 RecordFinalStatusWithoutCreatingPrerenderContents(
1276 url, origin, experiment, FINAL_STATUS_DUPLICATE);
1276 return new PrerenderHandle(preexisting_prerender_data); 1277 return new PrerenderHandle(preexisting_prerender_data);
1277 } 1278 }
1278 1279
1279 // Do not prerender if there are too many render processes, and we would 1280 // Do not prerender if there are too many render processes, and we would
1280 // have to use an existing one. We do not want prerendering to happen in 1281 // have to use an existing one. We do not want prerendering to happen in
1281 // a shared process, so that we can always reliably lower the CPU 1282 // a shared process, so that we can always reliably lower the CPU
1282 // priority for prerendering. 1283 // priority for prerendering.
1283 // In single-process mode, ShouldTryToUseExistingProcessHost() always returns 1284 // In single-process mode, ShouldTryToUseExistingProcessHost() always returns
1284 // true, so that case needs to be explicitly checked for. 1285 // true, so that case needs to be explicitly checked for.
1285 // TODO(tburkard): Figure out how to cancel prerendering in the opposite 1286 // TODO(tburkard): Figure out how to cancel prerendering in the opposite
1286 // case, when a new tab is added to a process used for prerendering. 1287 // case, when a new tab is added to a process used for prerendering.
1287 // TODO(ppi): Check whether there are usually enough render processes 1288 // TODO(ppi): Check whether there are usually enough render processes
1288 // available on Android. If not, kill an existing renderers so that we can 1289 // available on Android. If not, kill an existing renderers so that we can
1289 // create a new one. 1290 // create a new one.
1290 if (content::RenderProcessHost::ShouldTryToUseExistingProcessHost( 1291 if (content::RenderProcessHost::ShouldTryToUseExistingProcessHost(
1291 profile_, url) && 1292 profile_, url) &&
1292 !content::RenderProcessHost::run_renderer_in_process()) { 1293 !content::RenderProcessHost::run_renderer_in_process()) {
1293 RecordFinalStatus(origin, experiment, FINAL_STATUS_TOO_MANY_PROCESSES); 1294 RecordFinalStatusWithoutCreatingPrerenderContents(
1295 url, origin, experiment, FINAL_STATUS_TOO_MANY_PROCESSES);
1294 return NULL; 1296 return NULL;
1295 } 1297 }
1296 1298
1297 // Check if enough time has passed since the last prerender. 1299 // Check if enough time has passed since the last prerender.
1298 if (!DoesRateLimitAllowPrerender(origin)) { 1300 if (!DoesRateLimitAllowPrerender(origin)) {
1299 // Cancel the prerender. We could add it to the pending prerender list but 1301 // Cancel the prerender. We could add it to the pending prerender list but
1300 // this doesn't make sense as the next prerender request will be triggered 1302 // this doesn't make sense as the next prerender request will be triggered
1301 // by a navigation and is unlikely to be the same site. 1303 // by a navigation and is unlikely to be the same site.
1302 RecordFinalStatus(origin, experiment, FINAL_STATUS_RATE_LIMIT_EXCEEDED); 1304 RecordFinalStatusWithoutCreatingPrerenderContents(
1305 url, origin, experiment, FINAL_STATUS_RATE_LIMIT_EXCEEDED);
1303 return NULL; 1306 return NULL;
1304 } 1307 }
1305 1308
1306 if (!cookie_store_loaded()) { 1309 if (!cookie_store_loaded()) {
1307 // Only prerender if the cookie store for this profile has been loaded. 1310 // Only prerender if the cookie store for this profile has been loaded.
1308 // This is required by PrerenderCookieMonster. 1311 // This is required by PrerenderCookieMonster.
1309 RecordFinalStatus(origin, experiment, FINAL_STATUS_COOKIE_STORE_NOT_LOADED); 1312 RecordFinalStatus(origin, experiment, FINAL_STATUS_COOKIE_STORE_NOT_LOADED);
1310 return NULL; 1313 return NULL;
1311 } 1314 }
1312 1315
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 FinalStatus final_status) { 1594 FinalStatus final_status) {
1592 prerender_contents->set_match_complete_status( 1595 prerender_contents->set_match_complete_status(
1593 PrerenderContents::MATCH_COMPLETE_REPLACED); 1596 PrerenderContents::MATCH_COMPLETE_REPLACED);
1594 histograms_->RecordFinalStatus(prerender_contents->origin(), 1597 histograms_->RecordFinalStatus(prerender_contents->origin(),
1595 prerender_contents->experiment_id(), 1598 prerender_contents->experiment_id(),
1596 PrerenderContents::MATCH_COMPLETE_REPLACEMENT, 1599 PrerenderContents::MATCH_COMPLETE_REPLACEMENT,
1597 FINAL_STATUS_WOULD_HAVE_BEEN_USED); 1600 FINAL_STATUS_WOULD_HAVE_BEEN_USED);
1598 prerender_contents->Destroy(final_status); 1601 prerender_contents->Destroy(final_status);
1599 } 1602 }
1600 1603
1601 void PrerenderManager::RecordFinalStatus(Origin origin, 1604 void PrerenderManager::RecordFinalStatusWithoutCreatingPrerenderContents(
1602 uint8 experiment_id, 1605 const GURL& url, Origin origin, uint8 experiment_id,
1603 FinalStatus final_status) const { 1606 FinalStatus final_status) const {
1607 PrerenderHistory::Entry entry(url, final_status, origin, base::Time::Now());
1608 prerender_history_->AddEntry(entry);
1604 RecordFinalStatusWithMatchCompleteStatus( 1609 RecordFinalStatusWithMatchCompleteStatus(
1605 origin, experiment_id, 1610 origin, experiment_id,
1606 PrerenderContents::MATCH_COMPLETE_DEFAULT, 1611 PrerenderContents::MATCH_COMPLETE_DEFAULT,
1607 final_status); 1612 final_status);
1608 } 1613 }
1609 1614
1610 bool PrerenderManager::IsEnabled() const { 1615 bool PrerenderManager::IsEnabled() const {
1611 DCHECK(CalledOnValidThread()); 1616 DCHECK(CalledOnValidThread());
1612 if (!enabled_) 1617 if (!enabled_)
1613 return false; 1618 return false;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 content::RenderProcessHost* host) { 1892 content::RenderProcessHost* host) {
1888 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1893 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1889 prerender_process_hosts_.erase(host); 1894 prerender_process_hosts_.erase(host);
1890 BrowserThread::PostTask( 1895 BrowserThread::PostTask(
1891 BrowserThread::IO, FROM_HERE, 1896 BrowserThread::IO, FROM_HERE,
1892 base::Bind(&PrerenderTracker::RemovePrerenderCookieStoreOnIOThread, 1897 base::Bind(&PrerenderTracker::RemovePrerenderCookieStoreOnIOThread,
1893 base::Unretained(prerender_tracker()), host->GetID(), false)); 1898 base::Unretained(prerender_tracker()), host->GetID(), false));
1894 } 1899 }
1895 1900
1896 } // namespace prerender 1901 } // namespace prerender
OLDNEW
« chrome/browser/prerender/prerender_manager.h ('K') | « chrome/browser/prerender/prerender_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698