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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/optional.h" | 9 #include "base/optional.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 11 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
12 #include "chrome/common/features.h" | |
13 #include "chrome/common/page_load_metrics/page_load_timing.h" | 12 #include "chrome/common/page_load_metrics/page_load_timing.h" |
14 #include "content/public/browser/navigation_handle.h" | 13 #include "content/public/browser/navigation_handle.h" |
15 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
16 | 15 |
17 #if BUILDFLAG(ANDROID_JAVA_UI) | 16 #if defined(OS_ANDROID) |
18 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" | 17 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
19 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 18 #endif // defined(OS_ANDROID) |
20 | 19 |
21 namespace previews { | 20 namespace previews { |
22 | 21 |
23 namespace internal { | 22 namespace internal { |
24 | 23 |
25 const char kHistogramOfflinePreviewsDOMContentLoadedEventFired[] = | 24 const char kHistogramOfflinePreviewsDOMContentLoadedEventFired[] = |
26 "PageLoad.Clients.Previews.OfflinePages.DocumentTiming." | 25 "PageLoad.Clients.Previews.OfflinePages.DocumentTiming." |
27 "NavigationToDOMContentLoadedEventFired"; | 26 "NavigationToDOMContentLoadedEventFired"; |
28 const char kHistogramOfflinePreviewsFirstLayout[] = | 27 const char kHistogramOfflinePreviewsFirstLayout[] = |
29 "PageLoad.Clients.Previews.OfflinePages.DocumentTiming." | 28 "PageLoad.Clients.Previews.OfflinePages.DocumentTiming." |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (!WasStartedInForegroundOptionalEventInForeground( | 101 if (!WasStartedInForegroundOptionalEventInForeground( |
103 timing.dom_content_loaded_event_start, info)) { | 102 timing.dom_content_loaded_event_start, info)) { |
104 return; | 103 return; |
105 } | 104 } |
106 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsParseStart, | 105 PAGE_LOAD_HISTOGRAM(internal::kHistogramOfflinePreviewsParseStart, |
107 timing.parse_start.value()); | 106 timing.parse_start.value()); |
108 } | 107 } |
109 | 108 |
110 bool PreviewsPageLoadMetricsObserver::IsOfflinePreview( | 109 bool PreviewsPageLoadMetricsObserver::IsOfflinePreview( |
111 content::WebContents* web_contents) const { | 110 content::WebContents* web_contents) const { |
112 #if BUILDFLAG(ANDROID_JAVA_UI) | 111 #if defined(OS_ANDROID) |
113 offline_pages::OfflinePageTabHelper* tab_helper = | 112 offline_pages::OfflinePageTabHelper* tab_helper = |
114 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents); | 113 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents); |
115 return tab_helper && tab_helper->IsShowingOfflinePreview(); | 114 return tab_helper && tab_helper->IsShowingOfflinePreview(); |
116 #else | 115 #else |
117 return false; | 116 return false; |
118 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 117 #endif // defined(OS_ANDROID) |
119 } | 118 } |
120 | 119 |
121 } // namespace previews | 120 } // namespace previews |
OLD | NEW |