| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 8 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
| 9 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 9 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 10 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" | 10 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 page_load_metrics::PageLoadMetricsObserver::ObservePolicy | 62 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
| 63 ResourcePrefetchPredictorPageLoadMetricsObserver::OnHidden( | 63 ResourcePrefetchPredictorPageLoadMetricsObserver::OnHidden( |
| 64 const page_load_metrics::PageLoadTiming& timing, | 64 const page_load_metrics::PageLoadTiming& timing, |
| 65 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 65 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
| 66 record_histograms_ = false; | 66 record_histograms_ = false; |
| 67 return CONTINUE_OBSERVING; | 67 return CONTINUE_OBSERVING; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ResourcePrefetchPredictorPageLoadMetricsObserver::OnFirstContentfulPaint( | 70 void ResourcePrefetchPredictorPageLoadMetricsObserver:: |
| 71 const page_load_metrics::PageLoadTiming& timing, | 71 OnFirstContentfulPaintInPage( |
| 72 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 72 const page_load_metrics::PageLoadTiming& timing, |
| 73 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
| 73 predictors::NavigationID navigation_id(web_contents_); | 74 predictors::NavigationID navigation_id(web_contents_); |
| 74 | 75 |
| 75 predictor_->RecordFirstContentfulPaint( | 76 predictor_->RecordFirstContentfulPaint( |
| 76 navigation_id, extra_info.navigation_start + | 77 navigation_id, extra_info.navigation_start + |
| 77 timing.paint_timing.first_contentful_paint.value()); | 78 timing.paint_timing.first_contentful_paint.value()); |
| 78 if (record_histograms_) { | 79 if (record_histograms_) { |
| 79 PAGE_LOAD_HISTOGRAM( | 80 PAGE_LOAD_HISTOGRAM( |
| 80 internal::kHistogramResourcePrefetchPredictorFirstContentfulPaint, | 81 internal::kHistogramResourcePrefetchPredictorFirstContentfulPaint, |
| 81 timing.paint_timing.first_contentful_paint.value()); | 82 timing.paint_timing.first_contentful_paint.value()); |
| 82 } | 83 } |
| 83 } | 84 } |
| 84 | 85 |
| 85 void ResourcePrefetchPredictorPageLoadMetricsObserver::OnFirstMeaningfulPaint( | 86 void ResourcePrefetchPredictorPageLoadMetricsObserver:: |
| 86 const page_load_metrics::PageLoadTiming& timing, | 87 OnFirstMeaningfulPaintInMainFrameDocument( |
| 87 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 88 const page_load_metrics::PageLoadTiming& timing, |
| 89 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
| 88 if (record_histograms_) { | 90 if (record_histograms_) { |
| 89 PAGE_LOAD_HISTOGRAM( | 91 PAGE_LOAD_HISTOGRAM( |
| 90 internal::kHistogramResourcePrefetchPredictorFirstMeaningfulPaint, | 92 internal::kHistogramResourcePrefetchPredictorFirstMeaningfulPaint, |
| 91 timing.paint_timing.first_meaningful_paint.value()); | 93 timing.paint_timing.first_meaningful_paint.value()); |
| 92 } | 94 } |
| 93 } | 95 } |
| OLD | NEW |