| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/previews_page_load_metrics_
observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/previews_page_load_metrics_
observer.h" |
| 6 | 6 |
| 7 #include "base/optional.h" | 7 #include "base/optional.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 9 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
| 10 #include "chrome/common/page_load_metrics/page_load_timing.h" | 10 #include "chrome/common/page_load_metrics/page_load_timing.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // On top of base-supported types, support MHTML. Offline previews are served | 54 // On top of base-supported types, support MHTML. Offline previews are served |
| 55 // as MHTML (multipart/related). | 55 // as MHTML (multipart/related). |
| 56 return PageLoadMetricsObserver::ShouldObserveMimeType(mime_type) == | 56 return PageLoadMetricsObserver::ShouldObserveMimeType(mime_type) == |
| 57 CONTINUE_OBSERVING || | 57 CONTINUE_OBSERVING || |
| 58 mime_type == "multipart/related" | 58 mime_type == "multipart/related" |
| 59 ? CONTINUE_OBSERVING | 59 ? CONTINUE_OBSERVING |
| 60 : STOP_OBSERVING; | 60 : STOP_OBSERVING; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void PreviewsPageLoadMetricsObserver::OnDomContentLoadedEventStart( | 63 void PreviewsPageLoadMetricsObserver::OnDomContentLoadedEventStart( |
| 64 const page_load_metrics::PageLoadTiming& timing, | 64 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 65 const page_load_metrics::PageLoadExtraInfo& info) { | 65 const page_load_metrics::PageLoadExtraInfo& info) { |
| 66 if (!WasStartedInForegroundOptionalEventInForeground( | 66 if (!WasStartedInForegroundOptionalEventInForeground( |
| 67 timing.document_timing.dom_content_loaded_event_start, info)) { | 67 timing.document_timing->dom_content_loaded_event_start, info)) { |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 PAGE_LOAD_HISTOGRAM( | 70 PAGE_LOAD_HISTOGRAM( |
| 71 internal::kHistogramOfflinePreviewsDOMContentLoadedEventFired, | 71 internal::kHistogramOfflinePreviewsDOMContentLoadedEventFired, |
| 72 timing.document_timing.dom_content_loaded_event_start.value()); | 72 timing.document_timing->dom_content_loaded_event_start.value()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void PreviewsPageLoadMetricsObserver::OnLoadEventStart( | 75 void PreviewsPageLoadMetricsObserver::OnLoadEventStart( |
| 76 const page_load_metrics::PageLoadTiming& timing, | 76 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 77 const page_load_metrics::PageLoadExtraInfo& info) { | 77 const page_load_metrics::PageLoadExtraInfo& info) { |
| 78 if (!WasStartedInForegroundOptionalEventInForeground( | 78 if (!WasStartedInForegroundOptionalEventInForeground( |
| 79 timing.document_timing.load_event_start, info)) { | 79 timing.document_timing->load_event_start, info)) { |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsLoadEventFired, | 82 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsLoadEventFired, |
| 83 timing.document_timing.load_event_start.value()); | 83 timing.document_timing->load_event_start.value()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void PreviewsPageLoadMetricsObserver::OnFirstLayout( | 86 void PreviewsPageLoadMetricsObserver::OnFirstLayout( |
| 87 const page_load_metrics::PageLoadTiming& timing, | 87 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 88 const page_load_metrics::PageLoadExtraInfo& info) { | 88 const page_load_metrics::PageLoadExtraInfo& info) { |
| 89 if (!WasStartedInForegroundOptionalEventInForeground( | 89 if (!WasStartedInForegroundOptionalEventInForeground( |
| 90 timing.document_timing.first_layout, info)) { | 90 timing.document_timing->first_layout, info)) { |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsFirstLayout, | 93 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsFirstLayout, |
| 94 timing.document_timing.first_layout.value()); | 94 timing.document_timing->first_layout.value()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void PreviewsPageLoadMetricsObserver::OnFirstContentfulPaintInPage( | 97 void PreviewsPageLoadMetricsObserver::OnFirstContentfulPaintInPage( |
| 98 const page_load_metrics::PageLoadTiming& timing, | 98 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 99 const page_load_metrics::PageLoadExtraInfo& info) { | 99 const page_load_metrics::PageLoadExtraInfo& info) { |
| 100 if (!WasStartedInForegroundOptionalEventInForeground( | 100 if (!WasStartedInForegroundOptionalEventInForeground( |
| 101 timing.paint_timing.first_contentful_paint, info)) { | 101 timing.paint_timing->first_contentful_paint, info)) { |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsFirstContentfulPaint, | 104 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsFirstContentfulPaint, |
| 105 timing.paint_timing.first_contentful_paint.value()); | 105 timing.paint_timing->first_contentful_paint.value()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void PreviewsPageLoadMetricsObserver::OnParseStart( | 108 void PreviewsPageLoadMetricsObserver::OnParseStart( |
| 109 const page_load_metrics::PageLoadTiming& timing, | 109 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 110 const page_load_metrics::PageLoadExtraInfo& info) { | 110 const page_load_metrics::PageLoadExtraInfo& info) { |
| 111 if (!WasStartedInForegroundOptionalEventInForeground( | 111 if (!WasStartedInForegroundOptionalEventInForeground( |
| 112 timing.parse_timing.parse_start, info)) { | 112 timing.parse_timing->parse_start, info)) { |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsParseStart, | 115 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsParseStart, |
| 116 timing.parse_timing.parse_start.value()); | 116 timing.parse_timing->parse_start.value()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool PreviewsPageLoadMetricsObserver::IsOfflinePreview( | 119 bool PreviewsPageLoadMetricsObserver::IsOfflinePreview( |
| 120 content::WebContents* web_contents) const { | 120 content::WebContents* web_contents) const { |
| 121 #if defined(OS_ANDROID) | 121 #if defined(OS_ANDROID) |
| 122 offline_pages::OfflinePageTabHelper* tab_helper = | 122 offline_pages::OfflinePageTabHelper* tab_helper = |
| 123 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents); | 123 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents); |
| 124 return tab_helper && tab_helper->IsShowingOfflinePreview(); | 124 return tab_helper && tab_helper->IsShowingOfflinePreview(); |
| 125 #else | 125 #else |
| 126 return false; | 126 return false; |
| 127 #endif // defined(OS_ANDROID) | 127 #endif // defined(OS_ANDROID) |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace previews | 130 } // namespace previews |
| OLD | NEW |