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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 bool is_no_store, | 593 bool is_no_store, |
594 bool was_hidden, | 594 bool was_hidden, |
595 base::TimeTicks first_contentful_paint) { | 595 base::TimeTicks first_contentful_paint) { |
596 DCHECK(!first_contentful_paint.is_null()); | 596 DCHECK(!first_contentful_paint.is_null()); |
597 | 597 |
598 PrerenderTabHelper* tab_helper = | 598 PrerenderTabHelper* tab_helper = |
599 PrerenderTabHelper::FromWebContents(web_contents); | 599 PrerenderTabHelper::FromWebContents(web_contents); |
600 DCHECK(tab_helper); | 600 DCHECK(tab_helper); |
601 | 601 |
602 base::TimeDelta prefetch_age; | 602 base::TimeDelta prefetch_age; |
603 // The origin at prefetch is superceeded by the tab_helper origin for the | 603 Origin origin; |
604 // histogram recording, below. | 604 // The tab_helper origin is arguably more accurate, but in order to be |
605 GetPrefetchInformation(url, &prefetch_age, nullptr); | 605 // consistent with other prefetch TTFCP histograms, the origin from |
606 // GetPrefetchInformation is used instead. | |
607 GetPrefetchInformation(url, &prefetch_age, &origin); | |
606 OnPrefetchUsed(url); | 608 OnPrefetchUsed(url); |
607 | 609 |
608 base::TimeTicks swap_ticks = tab_helper->swap_ticks(); | 610 base::TimeTicks swap_ticks = tab_helper->swap_ticks(); |
609 bool fcp_recorded = false; | 611 bool fcp_recorded = false; |
610 if (!swap_ticks.is_null() && !first_contentful_paint.is_null()) { | 612 if (!swap_ticks.is_null() && !first_contentful_paint.is_null()) { |
pasko
2017/03/24 16:10:30
this is only recorded when swap happened (!swap_ti
mattcary
2017/03/27 07:52:05
Or, it could perhaps be that my logic on the clien
pasko
2017/03/27 17:32:57
Sorry, I misread. We are recording "Reference" wit
| |
611 histograms_->RecordPrefetchFirstContentfulPaintTime( | 613 histograms_->RecordPrefetchFirstContentfulPaintTime( |
612 tab_helper->origin(), is_no_store, was_hidden, | 614 origin, is_no_store, was_hidden, first_contentful_paint - swap_ticks, |
613 first_contentful_paint - swap_ticks, prefetch_age); | 615 prefetch_age); |
614 fcp_recorded = true; | 616 fcp_recorded = true; |
615 } | 617 } |
616 histograms_->RecordPerceivedFirstContentfulPaintStatus( | 618 histograms_->RecordPerceivedFirstContentfulPaintStatus(origin, fcp_recorded, |
617 tab_helper->origin(), fcp_recorded, was_hidden); | 619 was_hidden); |
618 | 620 |
619 for (auto& observer : observers_) { | 621 for (auto& observer : observers_) { |
620 observer->OnFirstContentfulPaint(); | 622 observer->OnFirstContentfulPaint(); |
621 } | 623 } |
622 } | 624 } |
623 | 625 |
624 // static | 626 // static |
625 PrerenderManager::PrerenderManagerMode PrerenderManager::GetMode( | 627 PrerenderManager::PrerenderManagerMode PrerenderManager::GetMode( |
626 Origin origin) { | 628 Origin origin) { |
627 switch (origin) { | 629 switch (origin) { |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1463 return weak_factory_.GetWeakPtr(); | 1465 return weak_factory_.GetWeakPtr(); |
1464 } | 1466 } |
1465 | 1467 |
1466 void PrerenderManager::SetPrerenderContentsFactoryForTest( | 1468 void PrerenderManager::SetPrerenderContentsFactoryForTest( |
1467 PrerenderContents::Factory* prerender_contents_factory) { | 1469 PrerenderContents::Factory* prerender_contents_factory) { |
1468 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1470 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1469 prerender_contents_factory_.reset(prerender_contents_factory); | 1471 prerender_contents_factory_.reset(prerender_contents_factory); |
1470 } | 1472 } |
1471 | 1473 |
1472 } // namespace prerender | 1474 } // namespace prerender |
OLD | NEW |