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

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

Issue 1896403002: Prerender: Remove MatchComplete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: re-enable PrerenderDeferredSynchronousXHR Created 4 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 "GET", 79 "GET",
80 "HEAD", 80 "HEAD",
81 "OPTIONS", 81 "OPTIONS",
82 "POST", 82 "POST",
83 "TRACE", 83 "TRACE",
84 }; 84 };
85 85
86 // Length of prerender history, for display in chrome://net-internals 86 // Length of prerender history, for display in chrome://net-internals
87 const int kHistoryLength = 100; 87 const int kHistoryLength = 100;
88 88
89 // Indicates whether a Prerender has been cancelled such that we need
90 // a dummy replacement for the purpose of recording the correct PPLT for
91 // the Match Complete case.
92 // Traditionally, "Match" means that a prerendered page was actually visited &
93 // the prerender was used. Our goal is to have "Match" cases line up in the
94 // control group & the experiment group, so that we can make meaningful
95 // comparisons of improvements. However, in the control group, since we don't
96 // actually perform prerenders, many of the cancellation reasons cannot be
97 // detected. Therefore, in the Prerender group, when we cancel for one of these
98 // reasons, we keep track of a dummy Prerender representing what we would
99 // have in the control group. If that dummy prerender in the prerender group
100 // would then be swapped in (but isn't actually b/c it's a dummy), we record
101 // this as a MatchComplete. This allows us to compare MatchComplete's
102 // across Prerender & Control group which ideally should be lining up.
103 // This ensures that there is no bias in terms of the page load times
104 // of the pages forming the difference between the two sets.
105
106 bool NeedMatchCompleteDummyForFinalStatus(FinalStatus final_status) {
107 return final_status != FINAL_STATUS_USED &&
108 final_status != FINAL_STATUS_TIMED_OUT &&
109 final_status != FINAL_STATUS_MANAGER_SHUTDOWN &&
110 final_status != FINAL_STATUS_PROFILE_DESTROYED &&
111 final_status != FINAL_STATUS_APP_TERMINATING &&
112 final_status != FINAL_STATUS_WINDOW_OPENER &&
113 final_status != FINAL_STATUS_CACHE_OR_HISTORY_CLEARED &&
114 final_status != FINAL_STATUS_CANCELLED &&
115 final_status != FINAL_STATUS_DEVTOOLS_ATTACHED &&
116 final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING &&
117 final_status != FINAL_STATUS_PAGE_BEING_CAPTURED &&
118 final_status != FINAL_STATUS_NAVIGATION_UNCOMMITTED &&
119 final_status != FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE;
120 }
121
122 } // namespace 89 } // namespace
123 90
124 class PrerenderManager::OnCloseWebContentsDeleter 91 class PrerenderManager::OnCloseWebContentsDeleter
125 : public content::WebContentsDelegate, 92 : public content::WebContentsDelegate,
126 public base::SupportsWeakPtr< 93 public base::SupportsWeakPtr<
127 PrerenderManager::OnCloseWebContentsDeleter> { 94 PrerenderManager::OnCloseWebContentsDeleter> {
128 public: 95 public:
129 OnCloseWebContentsDeleter(PrerenderManager* manager, 96 OnCloseWebContentsDeleter(PrerenderManager* manager,
130 WebContents* tab) 97 WebContents* tab)
131 : manager_(manager), 98 : manager_(manager),
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 510 }
544 511
545 void PrerenderManager::MoveEntryToPendingDelete(PrerenderContents* entry, 512 void PrerenderManager::MoveEntryToPendingDelete(PrerenderContents* entry,
546 FinalStatus final_status) { 513 FinalStatus final_status) {
547 DCHECK(CalledOnValidThread()); 514 DCHECK(CalledOnValidThread());
548 DCHECK(entry); 515 DCHECK(entry);
549 516
550 ScopedVector<PrerenderData>::iterator it = 517 ScopedVector<PrerenderData>::iterator it =
551 FindIteratorForPrerenderContents(entry); 518 FindIteratorForPrerenderContents(entry);
552 DCHECK(it != active_prerenders_.end()); 519 DCHECK(it != active_prerenders_.end());
553 520 to_delete_prerenders_.push_back(*it);
554 // If this PrerenderContents is being deleted due to a cancellation any time 521 active_prerenders_.weak_erase(it);
555 // after the prerender has started then we need to create a dummy replacement
556 // for PPLT accounting purposes for the Match Complete group. This is the case
557 // if the cancellation is for any reason that would not occur in the control
558 // group case.
559 if (entry->prerendering_has_started() &&
560 entry->match_complete_status() ==
561 PrerenderContents::MATCH_COMPLETE_DEFAULT &&
562 NeedMatchCompleteDummyForFinalStatus(final_status) &&
563 ActuallyPrerendering() &&
564 GetMode() == PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP) {
565 // TODO(tburkard): I'd like to DCHECK that we are actually prerendering.
566 // However, what if new conditions are added and
567 // NeedMatchCompleteDummyForFinalStatus is not being updated. Not sure
568 // what's the best thing to do here. For now, I will just check whether
569 // we are actually prerendering.
570 (*it)->MakeIntoMatchCompleteReplacement();
571 } else {
572 to_delete_prerenders_.push_back(*it);
573 active_prerenders_.weak_erase(it);
574 }
575
576 // Destroy the old WebContents relatively promptly to reduce resource usage. 522 // Destroy the old WebContents relatively promptly to reduce resource usage.
577 PostCleanupTask(); 523 PostCleanupTask();
578 } 524 }
579 525
580 void PrerenderManager::RecordPageLoadTimeNotSwappedIn( 526 void PrerenderManager::RecordPageLoadTimeNotSwappedIn(
581 Origin origin, 527 Origin origin,
582 base::TimeDelta page_load_time, 528 base::TimeDelta page_load_time,
583 const GURL& url) { 529 const GURL& url) {
584 DCHECK_CURRENTLY_ON(BrowserThread::UI); 530 DCHECK_CURRENTLY_ON(BrowserThread::UI);
585 histograms_->RecordPageLoadTimeNotSwappedIn(origin, page_load_time, url); 531 histograms_->RecordPageLoadTimeNotSwappedIn(origin, page_load_time, url);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 case PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP: 571 case PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP:
626 return "_Enabled"; 572 return "_Enabled";
627 case PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP: 573 case PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP:
628 return "_Control"; 574 return "_Control";
629 case PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP: 575 case PRERENDER_MODE_EXPERIMENT_MULTI_PRERENDER_GROUP:
630 return "_Multi"; 576 return "_Multi";
631 case PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP: 577 case PRERENDER_MODE_EXPERIMENT_15MIN_TTL_GROUP:
632 return "_15MinTTL"; 578 return "_15MinTTL";
633 case PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP: 579 case PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP:
634 return "_NoUse"; 580 return "_NoUse";
635 case PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP:
636 return "_MatchComplete";
637 case PRERENDER_MODE_MAX: 581 case PRERENDER_MODE_MAX:
638 default: 582 default:
639 NOTREACHED() << "Invalid PrerenderManager mode."; 583 NOTREACHED() << "Invalid PrerenderManager mode.";
640 break; 584 break;
641 } 585 }
642 return ""; 586 return "";
643 } 587 }
644 588
645 // static 589 // static
646 bool PrerenderManager::IsPrerenderingPossible() { 590 bool PrerenderManager::IsPrerenderingPossible() {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 : manager_(manager), 809 : manager_(manager),
866 contents_(contents), 810 contents_(contents),
867 handle_count_(0), 811 handle_count_(0),
868 expiry_time_(expiry_time) { 812 expiry_time_(expiry_time) {
869 DCHECK(contents_); 813 DCHECK(contents_);
870 } 814 }
871 815
872 PrerenderManager::PrerenderData::~PrerenderData() { 816 PrerenderManager::PrerenderData::~PrerenderData() {
873 } 817 }
874 818
875 void PrerenderManager::PrerenderData::MakeIntoMatchCompleteReplacement() {
876 DCHECK(contents_);
877 contents_->set_match_complete_status(
878 PrerenderContents::MATCH_COMPLETE_REPLACED);
879 PrerenderData* to_delete = new PrerenderData(manager_, contents_.release(),
880 expiry_time_);
881 contents_.reset(to_delete->contents_->CreateMatchCompleteReplacement());
882 manager_->to_delete_prerenders_.push_back(to_delete);
883 }
884
885 void PrerenderManager::PrerenderData::OnHandleCreated(PrerenderHandle* handle) { 819 void PrerenderManager::PrerenderData::OnHandleCreated(PrerenderHandle* handle) {
886 DCHECK(contents_); 820 DCHECK(contents_);
887 ++handle_count_; 821 ++handle_count_;
888 contents_->AddObserver(handle); 822 contents_->AddObserver(handle);
889 } 823 }
890 824
891 void PrerenderManager::PrerenderData::OnHandleNavigatedAway( 825 void PrerenderManager::PrerenderData::OnHandleNavigatedAway(
892 PrerenderHandle* handle) { 826 PrerenderHandle* handle) {
893 DCHECK_LT(0, handle_count_); 827 DCHECK_LT(0, handle_count_);
894 DCHECK(contents_); 828 DCHECK(contents_);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 } 1315 }
1382 1316
1383 void PrerenderManager::RenderProcessHostDestroyed( 1317 void PrerenderManager::RenderProcessHostDestroyed(
1384 content::RenderProcessHost* host) { 1318 content::RenderProcessHost* host) {
1385 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1319 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1386 size_t erased = prerender_process_hosts_.erase(host); 1320 size_t erased = prerender_process_hosts_.erase(host);
1387 DCHECK_EQ(1u, erased); 1321 DCHECK_EQ(1u, erased);
1388 } 1322 }
1389 1323
1390 } // namespace prerender 1324 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.h ('k') | chrome/browser/prerender/prerender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698