OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_TRACK_DECIDER_H_ |
| 6 #define CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_TRACK_DECIDER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 |
| 10 namespace page_load_metrics { |
| 11 |
| 12 // PageTrackDecider is an interface used to determine whether metrics should be |
| 13 // tracked for a given page. This class is used by the core page load metrics |
| 14 // tracking infrastructure in both the browser and render processes so policy |
| 15 // decisions about which page loads to track are consistent across processes. |
| 16 class PageTrackDecider { |
| 17 public: |
| 18 PageTrackDecider(); |
| 19 virtual ~PageTrackDecider(); |
| 20 |
| 21 // Whether metrics should be tracked for the current page. This method invokes |
| 22 // the pure virtual methods below to decide whether metrics should be tracked. |
| 23 bool ShouldTrack(); |
| 24 |
| 25 // Whether the navigation for the current page has committed. |
| 26 virtual bool HasCommitted() = 0; |
| 27 |
| 28 // Whether the current page's URL is HTTP or HTTPS. Note that the page does |
| 29 // not need to have committed, nor does the URL or hostname of the URL need to |
| 30 // point at a valid web page or host, for this method to return true. |
| 31 virtual bool IsHttpOrHttpsUrl() = 0; |
| 32 |
| 33 // Whether the current page's URL is for a Chrome new tab page. Note that in |
| 34 // some cases the new tab page is served over the network via https. |
| 35 virtual bool IsNewTabPageUrl() = 0; |
| 36 |
| 37 // The methods below can only be called if HasCommitted() returns true. |
| 38 |
| 39 // Whether the current page is a Chrome-generated error page. Example error |
| 40 // pages include pages displayed after a network error that did not result in |
| 41 // receiving an HTTP/HTTPS response, such as the 'There is no Internet |
| 42 // connection' page, which is displayed when the user attempts to navigate |
| 43 // without an Internet connection. This method returns false for non-Chrome |
| 44 // generated error pages, such as pages with 4xx/5xx response codes. To |
| 45 // check whether the current page resulted in a 4xx/5xx error, use |
| 46 // IsHTTPErrorPage() instead. |
| 47 virtual bool IsChromeErrorPage() = 0; |
| 48 |
| 49 // Returns the HTTP status code for the current page, or -1 if no status code |
| 50 // is available. |
| 51 virtual int GetHttpStatusCode() = 0; |
| 52 |
| 53 // Whether the current page is an HTML or XHTML page. |
| 54 virtual bool IsHtmlOrXhtmlPage() = 0; |
| 55 |
| 56 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(PageTrackDecider); |
| 58 }; |
| 59 |
| 60 } // namespace page_load_metrics |
| 61 |
| 62 #endif // CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_TRACK_DECIDER_H_ |
OLD | NEW |