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

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

Issue 15021007: Do conservative prerendering based on the LocalPredictor in Dev/Canary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox( 373 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox(
374 const GURL& url, 374 const GURL& url,
375 SessionStorageNamespace* session_storage_namespace, 375 SessionStorageNamespace* session_storage_namespace,
376 const gfx::Size& size) { 376 const gfx::Size& size) {
377 if (!IsOmniboxEnabled(profile_)) 377 if (!IsOmniboxEnabled(profile_))
378 return NULL; 378 return NULL;
379 return AddPrerender(ORIGIN_OMNIBOX, -1, url, content::Referrer(), size, 379 return AddPrerender(ORIGIN_OMNIBOX, -1, url, content::Referrer(), size,
380 session_storage_namespace); 380 session_storage_namespace);
381 } 381 }
382 382
383 PrerenderHandle* PrerenderManager::AddPrerenderFromLocalPredictor(
384 const GURL& url,
385 SessionStorageNamespace* session_storage_namespace,
386 const gfx::Size& size) {
387 return AddPrerender(ORIGIN_LOCAL_PREDICTOR, -1, url, content::Referrer(),
388 size, session_storage_namespace);
389 }
390
383 void PrerenderManager::DestroyPrerenderForRenderView( 391 void PrerenderManager::DestroyPrerenderForRenderView(
384 int process_id, int view_id, FinalStatus final_status) { 392 int process_id, int view_id, FinalStatus final_status) {
385 DCHECK(CalledOnValidThread()); 393 DCHECK(CalledOnValidThread());
386 if (PrerenderData* prerender_data = 394 if (PrerenderData* prerender_data =
387 FindPrerenderDataForChildAndRoute(process_id, view_id)) { 395 FindPrerenderDataForChildAndRoute(process_id, view_id)) {
388 prerender_data->contents()->Destroy(final_status); 396 prerender_data->contents()->Destroy(final_status);
389 } 397 }
390 } 398 }
391 399
392 void PrerenderManager::CancelAllPrerenders() { 400 void PrerenderManager::CancelAllPrerenders() {
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 // by a navigation and is unlikely to be the same site. 1126 // by a navigation and is unlikely to be the same site.
1119 RecordFinalStatus(origin, experiment, FINAL_STATUS_RATE_LIMIT_EXCEEDED); 1127 RecordFinalStatus(origin, experiment, FINAL_STATUS_RATE_LIMIT_EXCEEDED);
1120 return NULL; 1128 return NULL;
1121 } 1129 }
1122 1130
1123 PrerenderContents* prerender_contents = CreatePrerenderContents( 1131 PrerenderContents* prerender_contents = CreatePrerenderContents(
1124 url, referrer, origin, experiment); 1132 url, referrer, origin, experiment);
1125 DCHECK(prerender_contents); 1133 DCHECK(prerender_contents);
1126 active_prerenders_.push_back( 1134 active_prerenders_.push_back(
1127 new PrerenderData(this, prerender_contents, 1135 new PrerenderData(this, prerender_contents,
1128 GetExpiryTimeForNewPrerender())); 1136 GetExpiryTimeForNewPrerender(origin)));
1129 if (!prerender_contents->Init()) { 1137 if (!prerender_contents->Init()) {
1130 DCHECK(active_prerenders_.end() == 1138 DCHECK(active_prerenders_.end() ==
1131 FindIteratorForPrerenderContents(prerender_contents)); 1139 FindIteratorForPrerenderContents(prerender_contents));
1132 return NULL; 1140 return NULL;
1133 } 1141 }
1134 1142
1135 histograms_->RecordPrerenderStarted(origin); 1143 histograms_->RecordPrerenderStarted(origin);
1136 DCHECK(!prerender_contents->prerendering_has_started()); 1144 DCHECK(!prerender_contents->prerendering_has_started());
1137 1145
1138 PrerenderHandle* prerender_handle = 1146 PrerenderHandle* prerender_handle =
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 to_delete_prerenders_.clear(); 1203 to_delete_prerenders_.clear();
1196 } 1204 }
1197 1205
1198 void PrerenderManager::PostCleanupTask() { 1206 void PrerenderManager::PostCleanupTask() {
1199 DCHECK(CalledOnValidThread()); 1207 DCHECK(CalledOnValidThread());
1200 MessageLoop::current()->PostTask( 1208 MessageLoop::current()->PostTask(
1201 FROM_HERE, 1209 FROM_HERE,
1202 base::Bind(&PrerenderManager::PeriodicCleanup, AsWeakPtr())); 1210 base::Bind(&PrerenderManager::PeriodicCleanup, AsWeakPtr()));
1203 } 1211 }
1204 1212
1205 base::TimeTicks PrerenderManager::GetExpiryTimeForNewPrerender() const { 1213 base::TimeTicks PrerenderManager::GetExpiryTimeForNewPrerender(
1206 return GetCurrentTimeTicks() + config_.time_to_live; 1214 Origin origin) const {
1215 base::TimeDelta ttl = config_.time_to_live;
1216 if (origin == ORIGIN_LOCAL_PREDICTOR)
1217 ttl = base::TimeDelta::FromSeconds(180);
1218 return GetCurrentTimeTicks() + ttl;
1207 } 1219 }
1208 1220
1209 base::TimeTicks PrerenderManager::GetExpiryTimeForNavigatedAwayPrerender() 1221 base::TimeTicks PrerenderManager::GetExpiryTimeForNavigatedAwayPrerender()
1210 const { 1222 const {
1211 return GetCurrentTimeTicks() + config_.abandon_time_to_live; 1223 return GetCurrentTimeTicks() + config_.abandon_time_to_live;
1212 } 1224 }
1213 1225
1214 void PrerenderManager::DeleteOldEntries() { 1226 void PrerenderManager::DeleteOldEntries() {
1215 DCHECK(CalledOnValidThread()); 1227 DCHECK(CalledOnValidThread());
1216 while (!active_prerenders_.empty()) { 1228 while (!active_prerenders_.empty()) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 logged_in_state_->erase(domain_key); 1537 logged_in_state_->erase(domain_key);
1526 } 1538 }
1527 1539
1528 void PrerenderManager::LoggedInPredictorDataReceived( 1540 void PrerenderManager::LoggedInPredictorDataReceived(
1529 scoped_ptr<LoggedInStateMap> new_map) { 1541 scoped_ptr<LoggedInStateMap> new_map) {
1530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1542 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1531 logged_in_state_.swap(new_map); 1543 logged_in_state_.swap(new_map);
1532 } 1544 }
1533 1545
1534 } // namespace prerender 1546 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698