Index: chrome/common/page_load_metrics/page_tracker_predicate.h |
diff --git a/chrome/common/page_load_metrics/page_tracker_predicate.h b/chrome/common/page_load_metrics/page_tracker_predicate.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..77b11d7df6d43e4707150bb8dabda8f09d67a24d |
--- /dev/null |
+++ b/chrome/common/page_load_metrics/page_tracker_predicate.h |
@@ -0,0 +1,62 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_TRACKER_PREDICATE_H_ |
+#define CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_TRACKER_PREDICATE_H_ |
+ |
+#include "base/macros.h" |
+ |
+namespace page_load_metrics { |
+ |
+// PageTrackerPredicate is an interface used to determine whether metrics should |
+// be tracked for a given page. Consumers should call ShouldTrackPage() to |
+// determine if a page load should be tracked. Implementers should implement the |
+// pure virtual methods to provide information needed about the current page |
+// load to determine if it should be tracked. |
+class PageTrackerPredicate { |
Charlie Harrison
2016/09/13 17:51:04
Calling a class a predicate doesn't really sit wel
Bryan McQuade
2016/09/13 17:59:09
Yeah, I agree - it's not my favorite name either,
|
+ public: |
+ PageTrackerPredicate(); |
+ virtual ~PageTrackerPredicate(); |
+ |
+ // Whether metrics should be tracked for the current page. |
+ bool ShouldTrackPage(); |
+ |
+ // Whether the navigation for the current page has committed. |
+ virtual bool HasCommitted() = 0; |
+ |
+ // Whether the current page's URL is HTTP or HTTPS. Note that the page does |
+ // not need to have committed, nor does the URL or hostname of the URL need to |
+ // point at a valid web page or host, for this method to return true. |
+ virtual bool IsHTTPOrHTTPSUrl() = 0; |
+ |
+ // Whether the current page's URL is for a Chrome new tab page. Note that in |
+ // some cases the new tab page is served over the network via https. |
+ virtual bool IsNewTabPageUrl() = 0; |
+ |
+ // The methods below can only be called if HasCommitted() returns true. |
+ |
+ // Whether the current page is a Chrome-generated error page. Example error |
+ // pages include pages displayed after a network error that did not result in |
+ // receiving an HTTP/HTTPS response, such as the 'There is no Internet |
+ // connection' page, which is displayed when the user attempts to navigate |
+ // without an Internet connection. This method returns false for non-Chrome |
+ // generated error pages, such as pages with 4xx/5xx response codes. To |
+ // check whether the current page resulted in a 4xx/5xx error, use |
+ // IsNetworkErrorPage() instead. |
+ virtual bool IsChromeErrorPage() = 0; |
+ |
+ // Whether the current page is an HTTP(S) error page received over the |
+ // network, such as a page with a 4xx/5xx response code. |
+ virtual bool IsNetworkErrorPage() = 0; |
Bryan McQuade
2016/09/13 17:39:21
perhaps this should be called 'IsHTTPErrorPage'? I
Charlie Harrison
2016/09/13 17:51:04
Go with HTTP. You could even be more verbose: "IsH
|
+ |
+ // Whether the current page is an HTML or XHTML page. |
+ virtual bool IsHTMLOrXHTMLPage() = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(PageTrackerPredicate); |
+}; |
+ |
+} // namespace page_load_metrics |
+ |
+#endif // CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_TRACKER_PREDICATE_H_ |