OLD | NEW |
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // have in the control group. If that dummy prerender in the prerender group | 92 // have in the control group. If that dummy prerender in the prerender group |
93 // would then be swapped in (but isn't actually b/c it's a dummy), we record | 93 // would then be swapped in (but isn't actually b/c it's a dummy), we record |
94 // this as a MatchComplete. This allows us to compare MatchComplete's | 94 // this as a MatchComplete. This allows us to compare MatchComplete's |
95 // across Prerender & Control group which ideally should be lining up. | 95 // across Prerender & Control group which ideally should be lining up. |
96 // This ensures that there is no bias in terms of the page load times | 96 // This ensures that there is no bias in terms of the page load times |
97 // of the pages forming the difference between the two sets. | 97 // of the pages forming the difference between the two sets. |
98 | 98 |
99 bool NeedMatchCompleteDummyForFinalStatus(FinalStatus final_status) { | 99 bool NeedMatchCompleteDummyForFinalStatus(FinalStatus final_status) { |
100 return final_status != FINAL_STATUS_USED && | 100 return final_status != FINAL_STATUS_USED && |
101 final_status != FINAL_STATUS_TIMED_OUT && | 101 final_status != FINAL_STATUS_TIMED_OUT && |
102 final_status != FINAL_STATUS_EVICTED && | |
103 final_status != FINAL_STATUS_MANAGER_SHUTDOWN && | 102 final_status != FINAL_STATUS_MANAGER_SHUTDOWN && |
104 final_status != FINAL_STATUS_APP_TERMINATING && | 103 final_status != FINAL_STATUS_APP_TERMINATING && |
105 final_status != FINAL_STATUS_WINDOW_OPENER && | 104 final_status != FINAL_STATUS_WINDOW_OPENER && |
106 final_status != FINAL_STATUS_CACHE_OR_HISTORY_CLEARED && | 105 final_status != FINAL_STATUS_CACHE_OR_HISTORY_CLEARED && |
107 final_status != FINAL_STATUS_CANCELLED && | 106 final_status != FINAL_STATUS_CANCELLED && |
108 final_status != FINAL_STATUS_DEVTOOLS_ATTACHED && | 107 final_status != FINAL_STATUS_DEVTOOLS_ATTACHED && |
109 final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING; | 108 final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING; |
110 } | 109 } |
111 | 110 |
112 } // namespace | 111 } // namespace |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // Any other checks simply make sure that the PrerenderManager is accessed on | 201 // Any other checks simply make sure that the PrerenderManager is accessed on |
203 // the same thread that it was created on. | 202 // the same thread that it was created on. |
204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
205 | 204 |
206 if (IsLocalPredictorEnabled()) | 205 if (IsLocalPredictorEnabled()) |
207 local_predictor_.reset(new PrerenderLocalPredictor(this)); | 206 local_predictor_.reset(new PrerenderLocalPredictor(this)); |
208 | 207 |
209 // Certain experiments override our default config_ values. | 208 // Certain experiments override our default config_ values. |
210 switch (PrerenderManager::GetMode()) { | 209 switch (PrerenderManager::GetMode()) { |
211 case PrerenderManager::PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP: | 210 case PrerenderManager::PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP: |
212 config_.max_concurrency = 3; | 211 config_.max_concurrency = 4; |
| 212 config_.max_concurrency_per_launcher = 2; |
213 break; | 213 break; |
214 case PrerenderManager::PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP: | 214 case PrerenderManager::PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP: |
215 config_.time_to_live = base::TimeDelta::FromMinutes(15); | 215 config_.time_to_live = base::TimeDelta::FromMinutes(15); |
216 break; | 216 break; |
217 default: | 217 default: |
218 break; | 218 break; |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 PrerenderManager::~PrerenderManager() { | 222 PrerenderManager::~PrerenderManager() { |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 | 1039 |
1040 gfx::Size contents_size = | 1040 gfx::Size contents_size = |
1041 size.IsEmpty() ? config_.default_tab_bounds.size() : size; | 1041 size.IsEmpty() ? config_.default_tab_bounds.size() : size; |
1042 | 1042 |
1043 prerender_contents->StartPrerendering(process_id, contents_size, | 1043 prerender_contents->StartPrerendering(process_id, contents_size, |
1044 session_storage_namespace); | 1044 session_storage_namespace); |
1045 | 1045 |
1046 DCHECK(IsControlGroup(experiment) || | 1046 DCHECK(IsControlGroup(experiment) || |
1047 prerender_contents->prerendering_has_started()); | 1047 prerender_contents->prerendering_has_started()); |
1048 | 1048 |
1049 while (active_prerenders_.size() > config_.max_concurrency) { | |
1050 prerender_contents = active_prerenders_.front()->contents(); | |
1051 DCHECK(prerender_contents); | |
1052 prerender_contents->Destroy(FINAL_STATUS_EVICTED); | |
1053 } | |
1054 | |
1055 histograms_->RecordConcurrency(active_prerenders_.size(), | 1049 histograms_->RecordConcurrency(active_prerenders_.size(), |
1056 config_.max_concurrency); | 1050 config_.max_concurrency); |
1057 | 1051 |
1058 StartSchedulingPeriodicCleanups(); | 1052 StartSchedulingPeriodicCleanups(); |
1059 return prerender_handle; | 1053 return prerender_handle; |
1060 } | 1054 } |
1061 | 1055 |
1062 void PrerenderManager::StartSchedulingPeriodicCleanups() { | 1056 void PrerenderManager::StartSchedulingPeriodicCleanups() { |
1063 DCHECK(CalledOnValidThread()); | 1057 DCHECK(CalledOnValidThread()); |
1064 if (repeating_timer_.IsRunning()) | 1058 if (repeating_timer_.IsRunning()) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 return active_prerenders_.end(); | 1186 return active_prerenders_.end(); |
1193 } | 1187 } |
1194 | 1188 |
1195 bool PrerenderManager::DoesRateLimitAllowPrerender(Origin origin) const { | 1189 bool PrerenderManager::DoesRateLimitAllowPrerender(Origin origin) const { |
1196 DCHECK(CalledOnValidThread()); | 1190 DCHECK(CalledOnValidThread()); |
1197 base::TimeDelta elapsed_time = | 1191 base::TimeDelta elapsed_time = |
1198 GetCurrentTimeTicks() - last_prerender_start_time_; | 1192 GetCurrentTimeTicks() - last_prerender_start_time_; |
1199 histograms_->RecordTimeBetweenPrerenderRequests(origin, elapsed_time); | 1193 histograms_->RecordTimeBetweenPrerenderRequests(origin, elapsed_time); |
1200 if (!config_.rate_limit_enabled) | 1194 if (!config_.rate_limit_enabled) |
1201 return true; | 1195 return true; |
1202 return elapsed_time > | 1196 return elapsed_time >= |
1203 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs); | 1197 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs); |
1204 } | 1198 } |
1205 | 1199 |
1206 void PrerenderManager::DeleteOldWebContents() { | 1200 void PrerenderManager::DeleteOldWebContents() { |
1207 while (!old_web_contents_list_.empty()) { | 1201 while (!old_web_contents_list_.empty()) { |
1208 WebContents* web_contents = old_web_contents_list_.front(); | 1202 WebContents* web_contents = old_web_contents_list_.front(); |
1209 old_web_contents_list_.pop_front(); | 1203 old_web_contents_list_.pop_front(); |
1210 // TODO(dominich): should we use Instant Unload Handler here? | 1204 // TODO(dominich): should we use Instant Unload Handler here? |
1211 delete web_contents; | 1205 delete web_contents; |
1212 } | 1206 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 if (!render_process_host || !render_process_host->GetBrowserContext()) | 1310 if (!render_process_host || !render_process_host->GetBrowserContext()) |
1317 return NULL; | 1311 return NULL; |
1318 Profile* profile = Profile::FromBrowserContext( | 1312 Profile* profile = Profile::FromBrowserContext( |
1319 render_process_host->GetBrowserContext()); | 1313 render_process_host->GetBrowserContext()); |
1320 if (!profile) | 1314 if (!profile) |
1321 return NULL; | 1315 return NULL; |
1322 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); | 1316 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); |
1323 } | 1317 } |
1324 | 1318 |
1325 } // namespace prerender | 1319 } // namespace prerender |
OLD | NEW |