OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/page_load_metrics/observers/resource_prefetch_predictor
_page_load_metrics_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/resource_prefetch_predictor
_page_load_metrics_observer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 10 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 bool started_in_foreground) { | 57 bool started_in_foreground) { |
58 record_histograms_ = | 58 record_histograms_ = |
59 started_in_foreground && | 59 started_in_foreground && |
60 predictor_->IsUrlPrefetchable(navigation_handle->GetURL()); | 60 predictor_->IsUrlPrefetchable(navigation_handle->GetURL()); |
61 | 61 |
62 return CONTINUE_OBSERVING; | 62 return CONTINUE_OBSERVING; |
63 } | 63 } |
64 | 64 |
65 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 65 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
66 ResourcePrefetchPredictorPageLoadMetricsObserver::OnHidden( | 66 ResourcePrefetchPredictorPageLoadMetricsObserver::OnHidden( |
67 const page_load_metrics::PageLoadTiming& timing, | 67 const page_load_metrics::mojom::PageLoadTiming& timing, |
68 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 68 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
69 record_histograms_ = false; | 69 record_histograms_ = false; |
70 return CONTINUE_OBSERVING; | 70 return CONTINUE_OBSERVING; |
71 } | 71 } |
72 | 72 |
73 void ResourcePrefetchPredictorPageLoadMetricsObserver:: | 73 void ResourcePrefetchPredictorPageLoadMetricsObserver:: |
74 OnFirstContentfulPaintInPage( | 74 OnFirstContentfulPaintInPage( |
75 const page_load_metrics::PageLoadTiming& timing, | 75 const page_load_metrics::mojom::PageLoadTiming& timing, |
76 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 76 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
77 predictors::NavigationID navigation_id(web_contents_); | 77 predictors::NavigationID navigation_id(web_contents_); |
78 | 78 |
79 predictor_->RecordFirstContentfulPaint( | 79 predictor_->RecordFirstContentfulPaint( |
80 navigation_id, extra_info.navigation_start + | 80 navigation_id, extra_info.navigation_start + |
81 timing.paint_timing.first_contentful_paint.value()); | 81 timing.paint_timing->first_contentful_paint.value()); |
82 if (record_histograms_) { | 82 if (record_histograms_) { |
83 PAGE_LOAD_HISTOGRAM( | 83 PAGE_LOAD_HISTOGRAM( |
84 internal::kHistogramResourcePrefetchPredictorFirstContentfulPaint, | 84 internal::kHistogramResourcePrefetchPredictorFirstContentfulPaint, |
85 timing.paint_timing.first_contentful_paint.value()); | 85 timing.paint_timing->first_contentful_paint.value()); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 void ResourcePrefetchPredictorPageLoadMetricsObserver:: | 89 void ResourcePrefetchPredictorPageLoadMetricsObserver:: |
90 OnFirstMeaningfulPaintInMainFrameDocument( | 90 OnFirstMeaningfulPaintInMainFrameDocument( |
91 const page_load_metrics::PageLoadTiming& timing, | 91 const page_load_metrics::mojom::PageLoadTiming& timing, |
92 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 92 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
93 if (record_histograms_) { | 93 if (record_histograms_) { |
94 PAGE_LOAD_HISTOGRAM( | 94 PAGE_LOAD_HISTOGRAM( |
95 internal::kHistogramResourcePrefetchPredictorFirstMeaningfulPaint, | 95 internal::kHistogramResourcePrefetchPredictorFirstMeaningfulPaint, |
96 timing.paint_timing.first_meaningful_paint.value()); | 96 timing.paint_timing->first_meaningful_paint.value()); |
97 } | 97 } |
98 } | 98 } |
OLD | NEW |