Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: components/page_load_metrics/browser/page_load_metrics_observer.h

Issue 1913693002: Histogram the amount of time spent on HTTP(S) page loads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Equality operations are hard, let's go trybotting Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "components/page_load_metrics/common/page_load_timing.h" 9 #include "components/page_load_metrics/common/page_load_timing.h"
10 #include "content/public/browser/navigation_handle.h" 10 #include "content/public/browser/navigation_handle.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 // The page load started, with the given navigation handle. Note that OnStart 99 // The page load started, with the given navigation handle. Note that OnStart
100 // is called for same-page navigations. Implementers of OnStart that only want 100 // is called for same-page navigations. Implementers of OnStart that only want
101 // to process non-same-page navigations should also check to see that the page 101 // to process non-same-page navigations should also check to see that the page
102 // load committed via OnCommit or committed_url in 102 // load committed via OnCommit or committed_url in
103 // PageLoadExtraInfo. currently_committed_url contains the URL of the 103 // PageLoadExtraInfo. currently_committed_url contains the URL of the
104 // committed page load at the time the navigation for navigation_handle was 104 // committed page load at the time the navigation for navigation_handle was
105 // initiated, or the empty URL if there was no committed page load at the time 105 // initiated, or the empty URL if there was no committed page load at the time
106 // the navigation was initiated. 106 // the navigation was initiated.
107 virtual void OnStart(content::NavigationHandle* navigation_handle, 107 virtual void OnStart(content::NavigationHandle* navigation_handle,
108 const GURL& currently_committed_url) {} 108 const GURL& currently_committed_url,
109 bool started_in_foreground) {}
109 110
110 // OnRedirect is triggered when a page load redirects to another URL. 111 // OnRedirect is triggered when a page load redirects to another URL.
111 // The navigation handle holds relevant data for the navigation, but will 112 // The navigation handle holds relevant data for the navigation, but will
112 // be destroyed soon after this call. Don't hold a reference to it. This can 113 // be destroyed soon after this call. Don't hold a reference to it. This can
113 // be called multiple times. 114 // be called multiple times.
114 virtual void OnRedirect(content::NavigationHandle* navigation_handle) {} 115 virtual void OnRedirect(content::NavigationHandle* navigation_handle) {}
115 116
116 // OnCommit is triggered when a page load commits, i.e. when we receive the 117 // OnCommit is triggered when a page load commits, i.e. when we receive the
117 // first data for the request. The navigation handle holds relevant data for 118 // first data for the request. The navigation handle holds relevant data for
118 // the navigation, but will be destroyed soon after this call. Don't hold a 119 // the navigation, but will be destroyed soon after this call. Don't hold a
119 // reference to it. 120 // reference to it.
120 // Note that this does not get called for same page navigations. 121 // Note that this does not get called for same page navigations.
121 virtual void OnCommit(content::NavigationHandle* navigation_handle) {} 122 virtual void OnCommit(content::NavigationHandle* navigation_handle) {}
122 123
123 // OnFailedProvisionalLoad is triggered when a provisional load failed and did 124 // OnFailedProvisionalLoad is triggered when a provisional load failed and did
124 // not commit. Note that provisional loads that result in downloads or 204s 125 // not commit. Note that provisional loads that result in downloads or 204s
125 // are aborted by the system, and thus considered failed provisional loads. 126 // are aborted by the system, and thus considered failed provisional loads.
126 virtual void OnFailedProvisionalLoad( 127 virtual void OnFailedProvisionalLoad(
127 content::NavigationHandle* navigation_handle) {} 128 content::NavigationHandle* navigation_handle) {}
128 129
129 // OnTimingUpdate is triggered when an updated PageLoadTiming is 130 // OnTimingUpdate is triggered when an updated PageLoadTiming is
130 // available. This method may be called multiple times over the course of the 131 // available. This method may be called multiple times over the course of the
131 // page load. Note that this is currently an experimental API which may be 132 // page load. Note that this is currently an experimental API which may be
132 // removed in the future. Please email loading-dev@chromium.org if you intend 133 // removed in the future. Please email loading-dev@chromium.org if you intend
133 // to override this method. 134 // to override this method.
134 virtual void OnTimingUpdate(const PageLoadTiming& timing, 135 virtual void OnTimingUpdate(const PageLoadTiming& timing,
135 const PageLoadExtraInfo& extra_info) {} 136 const PageLoadExtraInfo& extra_info) {}
136 137
138 // OnHidden is triggered when a page leaves the foreground. It does not fire
139 // when a foreground page is permanently closed; for that, listen to
140 // OnComplete instead.
141 virtual void OnHidden() {}
142
143 // OnShown is triggered when a page is brought to the foreground. It does not
144 // fire when the page first loads; for that, listen for OnStart instead.
145 virtual void OnShown() {}
146
137 // OnComplete is triggered when we are ready to record metrics for this page 147 // OnComplete is triggered when we are ready to record metrics for this page
138 // load. This will happen some time after commit. The PageLoadTiming struct 148 // load. This will happen some time after commit. The PageLoadTiming struct
139 // contains timing data and the PageLoadExtraInfo struct contains other useful 149 // contains timing data and the PageLoadExtraInfo struct contains other useful
140 // data collected over the course of the page load. If the load did not 150 // data collected over the course of the page load. If the load did not
141 // receive any timing information, |timing.IsEmpty()| will be true. 151 // receive any timing information, |timing.IsEmpty()| will be true.
142 // After this call, the object will be deleted. 152 // After this call, the object will be deleted.
143 virtual void OnComplete(const PageLoadTiming& timing, 153 virtual void OnComplete(const PageLoadTiming& timing,
144 const PageLoadExtraInfo& extra_info) {} 154 const PageLoadExtraInfo& extra_info) {}
145 155
146 // The following methods are invoked at most once, when the timing for the 156 // The following methods are invoked at most once, when the timing for the
(...skipping 15 matching lines...) Expand all
162 const PageLoadExtraInfo& extra_info) {} 172 const PageLoadExtraInfo& extra_info) {}
163 virtual void OnParseStart(const PageLoadTiming& timing, 173 virtual void OnParseStart(const PageLoadTiming& timing,
164 const PageLoadExtraInfo& extra_info) {} 174 const PageLoadExtraInfo& extra_info) {}
165 virtual void OnParseStop(const PageLoadTiming& timing, 175 virtual void OnParseStop(const PageLoadTiming& timing,
166 const PageLoadExtraInfo& extra_info) {} 176 const PageLoadExtraInfo& extra_info) {}
167 }; 177 };
168 178
169 } // namespace page_load_metrics 179 } // namespace page_load_metrics
170 180
171 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_ 181 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698