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

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

Issue 2527363002: Delete obsolete prerender experiment code (Closed)
Patch Set: Created 4 years 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 last_recorded_profile_network_bytes_(0), 175 last_recorded_profile_network_bytes_(0),
176 clock_(new base::DefaultClock()), 176 clock_(new base::DefaultClock()),
177 tick_clock_(new base::DefaultTickClock()), 177 tick_clock_(new base::DefaultTickClock()),
178 weak_factory_(this) { 178 weak_factory_(this) {
179 DCHECK_CURRENTLY_ON(BrowserThread::UI); 179 DCHECK_CURRENTLY_ON(BrowserThread::UI);
180 180
181 last_prerender_start_time_ = 181 last_prerender_start_time_ =
182 GetCurrentTimeTicks() - 182 GetCurrentTimeTicks() -
183 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs); 183 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs);
184 184
185 // Certain experiments override our default config_ values.
186 switch (PrerenderManager::GetMode()) {
187 case PrerenderManager::PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP:
188 config_.max_link_concurrency = 4;
189 config_.max_link_concurrency_per_launcher = 2;
190 break;
191 case PrerenderManager::PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP:
192 config_.time_to_live = base::TimeDelta::FromMinutes(15);
193 break;
194 default:
195 break;
196 }
197
198 notification_registrar_.Add( 185 notification_registrar_.Add(
199 this, chrome::NOTIFICATION_PROFILE_DESTROYED, 186 this, chrome::NOTIFICATION_PROFILE_DESTROYED,
200 content::Source<Profile>(profile_)); 187 content::Source<Profile>(profile_));
201 188
202 MediaCaptureDevicesDispatcher::GetInstance()->AddObserver(this); 189 MediaCaptureDevicesDispatcher::GetInstance()->AddObserver(this);
203 } 190 }
204 191
205 PrerenderManager::~PrerenderManager() { 192 PrerenderManager::~PrerenderManager() {
206 MediaCaptureDevicesDispatcher::GetInstance()->RemoveObserver(this); 193 MediaCaptureDevicesDispatcher::GetInstance()->RemoveObserver(this);
207 194
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 void PrerenderManager::SetMode(PrerenderManagerMode mode) { 611 void PrerenderManager::SetMode(PrerenderManagerMode mode) {
625 mode_ = mode; 612 mode_ = mode;
626 } 613 }
627 614
628 // static 615 // static
629 bool PrerenderManager::IsPrerenderingPossible() { 616 bool PrerenderManager::IsPrerenderingPossible() {
630 return GetMode() != PRERENDER_MODE_DISABLED; 617 return GetMode() != PRERENDER_MODE_DISABLED;
631 } 618 }
632 619
633 // static 620 // static
634 bool PrerenderManager::ActuallyPrerendering() {
635 return IsPrerenderingPossible() && !IsControlGroup();
636 }
637
638 // static
639 bool PrerenderManager::IsControlGroup() {
640 return GetMode() == PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP;
641 }
642
643 // static
644 bool PrerenderManager::IsNoUseGroup() { 621 bool PrerenderManager::IsNoUseGroup() {
645 return GetMode() == PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP; 622 return GetMode() == PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP;
646 } 623 }
647 624
648 // static 625 // static
649 bool PrerenderManager::IsNoStatePrefetch() { 626 bool PrerenderManager::IsNoStatePrefetch() {
650 return GetMode() == PRERENDER_MODE_NOSTATE_PREFETCH; 627 return GetMode() == PRERENDER_MODE_NOSTATE_PREFETCH;
651 } 628 }
652 629
653 bool PrerenderManager::IsWebContentsPrerendering( 630 bool PrerenderManager::IsWebContentsPrerendering(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 GetPredictionStatus() == NetworkPredictionStatus::ENABLED); 766 GetPredictionStatus() == NetworkPredictionStatus::ENABLED);
790 std::string disabled_note; 767 std::string disabled_note;
791 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_ALWAYS) 768 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_ALWAYS)
792 disabled_note = "Disabled by user setting"; 769 disabled_note = "Disabled by user setting";
793 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK) 770 if (GetPredictionStatus() == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK)
794 disabled_note = "Disabled on cellular connection by default"; 771 disabled_note = "Disabled on cellular connection by default";
795 dict_value->SetString("disabled_note", disabled_note); 772 dict_value->SetString("disabled_note", disabled_note);
796 dict_value->SetBoolean("omnibox_enabled", IsOmniboxEnabled(profile_)); 773 dict_value->SetBoolean("omnibox_enabled", IsOmniboxEnabled(profile_));
797 // If prerender is disabled via a flag this method is not even called. 774 // If prerender is disabled via a flag this method is not even called.
798 std::string enabled_note; 775 std::string enabled_note;
799 if (IsControlGroup())
800 enabled_note += "(Control group: Not actually prerendering) ";
801 if (IsNoUseGroup()) 776 if (IsNoUseGroup())
802 enabled_note += "(No-use group: Not swapping in prerendered pages) "; 777 enabled_note += "(No-use group: Not swapping in prerendered pages) ";
803 if (GetMode() == PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP) {
804 enabled_note +=
805 "(15 min TTL group: Extended prerender eviction to 15 mins) ";
806 }
807 dict_value->SetString("enabled_note", enabled_note); 778 dict_value->SetString("enabled_note", enabled_note);
808 return dict_value; 779 return dict_value;
809 } 780 }
810 781
811 void PrerenderManager::ClearData(int clear_flags) { 782 void PrerenderManager::ClearData(int clear_flags) {
812 DCHECK_GE(clear_flags, 0); 783 DCHECK_GE(clear_flags, 0);
813 DCHECK_LT(clear_flags, CLEAR_MAX); 784 DCHECK_LT(clear_flags, CLEAR_MAX);
814 if (clear_flags & CLEAR_PRERENDER_CONTENTS) 785 if (clear_flags & CLEAR_PRERENDER_CONTENTS)
815 DestroyAllContents(FINAL_STATUS_CACHE_OR_HISTORY_CLEARED); 786 DestroyAllContents(FINAL_STATUS_CACHE_OR_HISTORY_CLEARED);
816 // This has to be second, since destroying prerenders can add to the history. 787 // This has to be second, since destroying prerenders can add to the history.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN) && 892 origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN) &&
922 IsGoogleSearchResultURL(referrer.url)) { 893 IsGoogleSearchResultURL(referrer.url)) {
923 origin = ORIGIN_GWS_PRERENDER; 894 origin = ORIGIN_GWS_PRERENDER;
924 } 895 }
925 896
926 if (IsPrerenderSilenceExperiment(origin)) 897 if (IsPrerenderSilenceExperiment(origin))
927 return nullptr; 898 return nullptr;
928 899
929 GURL url = url_arg; 900 GURL url = url_arg;
930 GURL alias_url; 901 GURL alias_url;
931 if (IsControlGroup() && MaybeGetQueryStringBasedAliasURL(url, &alias_url))
932 url = alias_url;
933 902
934 // From here on, we will record a FinalStatus so we need to register with the 903 // From here on, we will record a FinalStatus so we need to register with the
935 // histogram tracking. 904 // histogram tracking.
936 histograms_->RecordPrerender(origin, url_arg); 905 histograms_->RecordPrerender(origin, url_arg);
937 906
938 if (profile_->GetPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies) && 907 if (profile_->GetPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies) &&
939 origin != ORIGIN_OFFLINE) { 908 origin != ORIGIN_OFFLINE) {
940 RecordFinalStatusWithoutCreatingPrerenderContents( 909 RecordFinalStatusWithoutCreatingPrerenderContents(
941 url, origin, FINAL_STATUS_BLOCK_THIRD_PARTY_COOKIES); 910 url, origin, FINAL_STATUS_BLOCK_THIRD_PARTY_COOKIES);
942 return nullptr; 911 return nullptr;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 SortActivePrerenders(); 985 SortActivePrerenders();
1017 986
1018 last_prerender_start_time_ = GetCurrentTimeTicks(); 987 last_prerender_start_time_ = GetCurrentTimeTicks();
1019 988
1020 gfx::Rect contents_bounds = 989 gfx::Rect contents_bounds =
1021 bounds.IsEmpty() ? config_.default_tab_bounds : bounds; 990 bounds.IsEmpty() ? config_.default_tab_bounds : bounds;
1022 991
1023 prerender_contents_ptr->StartPrerendering(contents_bounds, 992 prerender_contents_ptr->StartPrerendering(contents_bounds,
1024 session_storage_namespace); 993 session_storage_namespace);
1025 994
1026 DCHECK(IsControlGroup() || 995 DCHECK(prerender_contents_ptr->prerendering_has_started());
1027 prerender_contents_ptr->prerendering_has_started());
1028
1029 if (GetMode() == PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP)
1030 histograms_->RecordConcurrency(active_prerenders_.size());
1031 996
1032 StartSchedulingPeriodicCleanups(); 997 StartSchedulingPeriodicCleanups();
1033 return prerender_handle; 998 return prerender_handle;
1034 } 999 }
1035 1000
1036 void PrerenderManager::StartSchedulingPeriodicCleanups() { 1001 void PrerenderManager::StartSchedulingPeriodicCleanups() {
1037 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1002 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1038 if (repeating_timer_.IsRunning()) 1003 if (repeating_timer_.IsRunning())
1039 return; 1004 return;
1040 repeating_timer_.Start(FROM_HERE, 1005 repeating_timer_.Start(FROM_HERE,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 PrerenderContents* prerender_contents = GetPrerenderContents(tab); 1247 PrerenderContents* prerender_contents = GetPrerenderContents(tab);
1283 if (!prerender_contents) 1248 if (!prerender_contents)
1284 return; 1249 return;
1285 1250
1286 prerender_contents->Destroy(FINAL_STATUS_CREATING_AUDIO_STREAM); 1251 prerender_contents->Destroy(FINAL_STATUS_CREATING_AUDIO_STREAM);
1287 } 1252 }
1288 1253
1289 void PrerenderManager::RecordNetworkBytes(Origin origin, 1254 void PrerenderManager::RecordNetworkBytes(Origin origin,
1290 bool used, 1255 bool used,
1291 int64_t prerender_bytes) { 1256 int64_t prerender_bytes) {
1292 if (!ActuallyPrerendering()) 1257 if (!IsPrerenderingPossible())
1293 return; 1258 return;
1294 int64_t recent_profile_bytes = 1259 int64_t recent_profile_bytes =
1295 profile_network_bytes_ - last_recorded_profile_network_bytes_; 1260 profile_network_bytes_ - last_recorded_profile_network_bytes_;
1296 last_recorded_profile_network_bytes_ = profile_network_bytes_; 1261 last_recorded_profile_network_bytes_ = profile_network_bytes_;
1297 DCHECK_GE(recent_profile_bytes, 0); 1262 DCHECK_GE(recent_profile_bytes, 0);
1298 histograms_->RecordNetworkBytes( 1263 histograms_->RecordNetworkBytes(
1299 origin, used, prerender_bytes, recent_profile_bytes); 1264 origin, used, prerender_bytes, recent_profile_bytes);
1300 } 1265 }
1301 1266
1302 bool PrerenderManager::IsPrerenderSilenceExperiment(Origin origin) const { 1267 bool PrerenderManager::IsPrerenderSilenceExperiment(Origin origin) const {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 if (origin == ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR && 1325 if (origin == ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR &&
1361 prediction_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK) { 1326 prediction_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK) {
1362 return NetworkPredictionStatus::ENABLED; 1327 return NetworkPredictionStatus::ENABLED;
1363 } 1328 }
1364 return prediction_status; 1329 return prediction_status;
1365 } 1330 }
1366 1331
1367 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64_t bytes) { 1332 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64_t bytes) {
1368 DCHECK_GE(bytes, 0); 1333 DCHECK_GE(bytes, 0);
1369 if (GetPredictionStatus() == NetworkPredictionStatus::ENABLED && 1334 if (GetPredictionStatus() == NetworkPredictionStatus::ENABLED &&
1370 ActuallyPrerendering()) 1335 IsPrerenderingPossible())
1371 profile_network_bytes_ += bytes; 1336 profile_network_bytes_ += bytes;
1372 } 1337 }
1373 1338
1374 void PrerenderManager::AddPrerenderProcessHost( 1339 void PrerenderManager::AddPrerenderProcessHost(
1375 content::RenderProcessHost* process_host) { 1340 content::RenderProcessHost* process_host) {
1376 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1341 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1377 DCHECK(prerender_process_hosts_.find(process_host) == 1342 DCHECK(prerender_process_hosts_.find(process_host) ==
1378 prerender_process_hosts_.end()); 1343 prerender_process_hosts_.end());
1379 prerender_process_hosts_.insert(process_host); 1344 prerender_process_hosts_.insert(process_host);
1380 process_host->AddObserver(this); 1345 process_host->AddObserver(this);
(...skipping 19 matching lines...) Expand all
1400 return weak_factory_.GetWeakPtr(); 1365 return weak_factory_.GetWeakPtr();
1401 } 1366 }
1402 1367
1403 void PrerenderManager::SetPrerenderContentsFactoryForTest( 1368 void PrerenderManager::SetPrerenderContentsFactoryForTest(
1404 PrerenderContents::Factory* prerender_contents_factory) { 1369 PrerenderContents::Factory* prerender_contents_factory) {
1405 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1370 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1406 prerender_contents_factory_.reset(prerender_contents_factory); 1371 prerender_contents_factory_.reset(prerender_contents_factory);
1407 } 1372 }
1408 1373
1409 } // namespace prerender 1374 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698