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

Side by Side Diff: chrome/browser/page_load_metrics/page_load_tracker.h

Issue 2624283004: Associate a main resource request with its PageLoadTracker. (Closed)
Patch Set: comment cleanup Created 3 years, 11 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 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 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/optional.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" 14 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
14 #include "chrome/browser/page_load_metrics/user_input_tracker.h" 15 #include "chrome/browser/page_load_metrics/user_input_tracker.h"
15 #include "chrome/common/page_load_metrics/page_load_timing.h" 16 #include "chrome/common/page_load_metrics/page_load_timing.h"
17 #include "content/public/browser/global_request_id.h"
16 #include "ui/base/page_transition_types.h" 18 #include "ui/base/page_transition_types.h"
17 19
18 class GURL; 20 class GURL;
19 21
20 namespace blink { 22 namespace blink {
21 class WebInputEvent; 23 class WebInputEvent;
22 } // namespace blink 24 } // namespace blink
23 25
24 namespace content { 26 namespace content {
25 class NavigationHandle; 27 class NavigationHandle;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // the constructor. 128 // the constructor.
127 PageLoadTracker(bool in_foreground, 129 PageLoadTracker(bool in_foreground,
128 PageLoadMetricsEmbedderInterface* embedder_interface, 130 PageLoadMetricsEmbedderInterface* embedder_interface,
129 const GURL& currently_committed_url, 131 const GURL& currently_committed_url,
130 content::NavigationHandle* navigation_handle, 132 content::NavigationHandle* navigation_handle,
131 UserInitiatedInfo user_initiated_info, 133 UserInitiatedInfo user_initiated_info,
132 int aborted_chain_size, 134 int aborted_chain_size,
133 int aborted_chain_size_same_url); 135 int aborted_chain_size_same_url);
134 ~PageLoadTracker(); 136 ~PageLoadTracker();
135 void Redirect(content::NavigationHandle* navigation_handle); 137 void Redirect(content::NavigationHandle* navigation_handle);
138 void ReadyToCommit(content::NavigationHandle* navigation_handle);
136 void Commit(content::NavigationHandle* navigation_handle); 139 void Commit(content::NavigationHandle* navigation_handle);
137 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle); 140 void FailedProvisionalLoad(content::NavigationHandle* navigation_handle);
138 void WebContentsHidden(); 141 void WebContentsHidden();
139 void WebContentsShown(); 142 void WebContentsShown();
140 143
141 void OnInputEvent(const blink::WebInputEvent& event); 144 void OnInputEvent(const blink::WebInputEvent& event);
142 145
143 // Flush any buffered metrics, as part of the metrics subsystem persisting 146 // Flush any buffered metrics, as part of the metrics subsystem persisting
144 // metrics as the application goes into the background. The application may be 147 // metrics as the application goes into the background. The application may be
145 // killed at any time after this method is invoked without further 148 // killed at any time after this method is invoked without further
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 base::TimeTicks navigation_start() const { return navigation_start_; } 206 base::TimeTicks navigation_start() const { return navigation_start_; }
204 207
205 PageLoadExtraInfo ComputePageLoadExtraInfo(); 208 PageLoadExtraInfo ComputePageLoadExtraInfo();
206 209
207 ui::PageTransition page_transition() const { return page_transition_; } 210 ui::PageTransition page_transition() const { return page_transition_; }
208 211
209 UserInitiatedInfo user_initiated_info() const { return user_initiated_info_; } 212 UserInitiatedInfo user_initiated_info() const { return user_initiated_info_; }
210 213
211 UserInputTracker* input_tracker() { return &input_tracker_; } 214 UserInputTracker* input_tracker() { return &input_tracker_; }
212 215
216 // Whether this PageLoadTracker has a navigation GlobalRequestID that matches
217 // the given request_id. This method will return false before ReadyToCommit
218 // has been invoked, as PageLoadTracker doesn't know its GlobalRequestID until
219 // ReadyToCommit has been invoked.
220 bool HasMatchingNavigationRequestID(
221 const content::GlobalRequestID& request_id) const;
222
213 private: 223 private:
214 // This function converts a TimeTicks value taken in the browser process 224 // This function converts a TimeTicks value taken in the browser process
215 // to navigation_start_ if: 225 // to navigation_start_ if:
216 // - base::TimeTicks is not comparable across processes because the clock 226 // - base::TimeTicks is not comparable across processes because the clock
217 // is not system wide monotonic. 227 // is not system wide monotonic.
218 // - *event_time < navigation_start_ 228 // - *event_time < navigation_start_
219 void ClampBrowserTimestampIfInterProcessTimeTickSkew( 229 void ClampBrowserTimestampIfInterProcessTimeTickSkew(
220 base::TimeTicks* event_time); 230 base::TimeTicks* event_time);
221 231
222 void UpdateAbortInternal(UserAbortType abort_type, 232 void UpdateAbortInternal(UserAbortType abort_type,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // when they occur in the background. 282 // when they occur in the background.
273 base::TimeTicks background_time_; 283 base::TimeTicks background_time_;
274 base::TimeTicks foreground_time_; 284 base::TimeTicks foreground_time_;
275 bool started_in_foreground_; 285 bool started_in_foreground_;
276 286
277 PageLoadTiming timing_; 287 PageLoadTiming timing_;
278 PageLoadMetadata metadata_; 288 PageLoadMetadata metadata_;
279 289
280 ui::PageTransition page_transition_; 290 ui::PageTransition page_transition_;
281 291
292 base::Optional<content::GlobalRequestID> navigation_request_id_;
293
282 // Whether this page load was user initiated. 294 // Whether this page load was user initiated.
283 UserInitiatedInfo user_initiated_info_; 295 UserInitiatedInfo user_initiated_info_;
284 296
285 // This is a subtle member. If a provisional load A gets aborted by 297 // This is a subtle member. If a provisional load A gets aborted by
286 // provisional load B, which gets aborted by C that eventually commits, then 298 // provisional load B, which gets aborted by C that eventually commits, then
287 // there exists an abort chain of length 2, starting at A's navigation_start. 299 // there exists an abort chain of length 2, starting at A's navigation_start.
288 // This is useful because it allows histograming abort chain lengths based on 300 // This is useful because it allows histograming abort chain lengths based on
289 // what the last load's transition type is. i.e. holding down F-5 to spam 301 // what the last load's transition type is. i.e. holding down F-5 to spam
290 // reload will produce a long chain with the RELOAD transition. 302 // reload will produce a long chain with the RELOAD transition.
291 const int aborted_chain_size_; 303 const int aborted_chain_size_;
292 304
293 // This member counts consecutive provisional aborts that share a url. It will 305 // This member counts consecutive provisional aborts that share a url. It will
294 // always be less than or equal to |aborted_chain_size_|. 306 // always be less than or equal to |aborted_chain_size_|.
295 const int aborted_chain_size_same_url_; 307 const int aborted_chain_size_same_url_;
296 308
297 // Interface to chrome features. Must outlive the class. 309 // Interface to chrome features. Must outlive the class.
298 PageLoadMetricsEmbedderInterface* const embedder_interface_; 310 PageLoadMetricsEmbedderInterface* const embedder_interface_;
299 311
300 std::vector<std::unique_ptr<PageLoadMetricsObserver>> observers_; 312 std::vector<std::unique_ptr<PageLoadMetricsObserver>> observers_;
301 313
302 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); 314 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker);
303 }; 315 };
304 316
305 } // namespace page_load_metrics 317 } // namespace page_load_metrics
306 318
307 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_ 319 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698