| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 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_observer.h" | 11 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" |
| 12 #include "chrome/common/page_load_metrics/page_load_metrics_util.h" |
| 12 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" | 13 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" |
| 13 | 14 |
| 14 // Up to 10 minutes, with 100 buckets. | 15 // Up to 10 minutes, with 100 buckets. |
| 15 #define PAGE_LOAD_HISTOGRAM(name, sample) \ | 16 #define PAGE_LOAD_HISTOGRAM(name, sample) \ |
| 16 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \ | 17 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \ |
| 17 base::TimeDelta::FromMilliseconds(10), \ | 18 base::TimeDelta::FromMilliseconds(10), \ |
| 18 base::TimeDelta::FromMinutes(10), 100) | 19 base::TimeDelta::FromMinutes(10), 100) |
| 19 | 20 |
| 20 // Up to 1 hour, with 100 buckets. | 21 // Up to 1 hour, with 100 buckets. |
| 21 #define PAGE_LOAD_LONG_HISTOGRAM(name, sample) \ | 22 #define PAGE_LOAD_LONG_HISTOGRAM(name, sample) \ |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // * the load of the main resource fails | 112 // * the load of the main resource fails |
| 112 // * the page load is stopped | 113 // * the page load is stopped |
| 113 // * the tab hosting the page is closed | 114 // * the tab hosting the page is closed |
| 114 // * the render process hosting the page goes away | 115 // * the render process hosting the page goes away |
| 115 // * a new navigation which later commits is initiated in the same tab | 116 // * a new navigation which later commits is initiated in the same tab |
| 116 // * the tab hosting the page is backgrounded | 117 // * the tab hosting the page is backgrounded |
| 117 base::Optional<base::TimeDelta> GetInitialForegroundDuration( | 118 base::Optional<base::TimeDelta> GetInitialForegroundDuration( |
| 118 const PageLoadExtraInfo& info, | 119 const PageLoadExtraInfo& info, |
| 119 base::TimeTicks app_background_time); | 120 base::TimeTicks app_background_time); |
| 120 | 121 |
| 121 // Returns the minimum value of the optional TimeDeltas, if both values are | |
| 122 // set. Otherwise, if one value is set, returns that value. Otherwise, returns | |
| 123 // an unset value. | |
| 124 base::Optional<base::TimeDelta> OptionalMin( | |
| 125 const base::Optional<base::TimeDelta>& a, | |
| 126 const base::Optional<base::TimeDelta>& b); | |
| 127 | |
| 128 // Whether the given loading behavior was observed in any frame (either the main | 122 // Whether the given loading behavior was observed in any frame (either the main |
| 129 // frame or a subframe). | 123 // frame or a subframe). |
| 130 bool DidObserveLoadingBehaviorInAnyFrame( | 124 bool DidObserveLoadingBehaviorInAnyFrame( |
| 131 const page_load_metrics::PageLoadExtraInfo& info, | 125 const page_load_metrics::PageLoadExtraInfo& info, |
| 132 blink::WebLoadingBehaviorFlag behavior); | 126 blink::WebLoadingBehaviorFlag behavior); |
| 133 | 127 |
| 134 // Whether the given url has a google hostname. | |
| 135 bool IsGoogleHostname(const GURL& url); | |
| 136 | |
| 137 // If the given hostname is a google hostname, returns the portion of the | |
| 138 // hostname before the google hostname. Otherwise, returns an unset optional | |
| 139 // value. | |
| 140 // | |
| 141 // For example: | |
| 142 // https://example.com/foo => returns an unset optional value | |
| 143 // https://google.com/foo => returns '' | |
| 144 // https://www.google.com/foo => returns 'www' | |
| 145 // https://news.google.com/foo => returns 'news' | |
| 146 // https://a.b.c.google.com/foo => returns 'a.b.c' | |
| 147 base::Optional<std::string> GetGoogleHostnamePrefix(const GURL& url); | |
| 148 | |
| 149 } // namespace page_load_metrics | 128 } // namespace page_load_metrics |
| 150 | 129 |
| 151 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ | 130 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ |
| OLD | NEW |