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

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

Issue 2223453003: Thread user gesture through page_load_metrics abort pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer); 175 void AddObserver(std::unique_ptr<PageLoadMetricsObserver> observer);
176 176
177 // If the user performs some abort-like action while we are tracking this page 177 // If the user performs some abort-like action while we are tracking this page
178 // load, notify the tracker. Note that we may not classify this as an abort if 178 // load, notify the tracker. Note that we may not classify this as an abort if
179 // we've already performed a first paint. 179 // we've already performed a first paint.
180 // is_certainly_browser_timestamp signifies if the timestamp passed is taken 180 // is_certainly_browser_timestamp signifies if the timestamp passed is taken
181 // in the 181 // in the
182 // browser process or not. We need this to possibly clamp browser timestamp on 182 // browser process or not. We need this to possibly clamp browser timestamp on
183 // a machine with inter process time tick skew. 183 // a machine with inter process time tick skew.
184 void NotifyAbort(UserAbortType abort_type, 184 void NotifyAbort(UserAbortType abort_type,
185 bool user_initiated,
185 base::TimeTicks timestamp, 186 base::TimeTicks timestamp,
186 bool is_certainly_browser_timestamp); 187 bool is_certainly_browser_timestamp);
187 void UpdateAbort(UserAbortType abort_type, 188 void UpdateAbort(UserAbortType abort_type,
189 bool user_initiated,
188 base::TimeTicks timestamp, 190 base::TimeTicks timestamp,
189 bool is_certainly_browser_timestamp); 191 bool is_certainly_browser_timestamp);
190 192
191 // This method returns true if this page load has been aborted with type of 193 // This method returns true if this page load has been aborted with type of
192 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close 194 // ABORT_OTHER, and the |abort_cause_time| is within a sufficiently close
193 // delta to when it was aborted. Note that only provisional loads can be 195 // delta to when it was aborted. Note that only provisional loads can be
194 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better 196 // aborted with ABORT_OTHER. While this heuristic is coarse, it works better
195 // and is simpler than other feasible methods. See https://goo.gl/WKRG98. 197 // and is simpler than other feasible methods. See https://goo.gl/WKRG98.
196 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time) const; 198 bool IsLikelyProvisionalAbort(base::TimeTicks abort_cause_time) const;
197 199
(...skipping 14 matching lines...) Expand all
212 private: 214 private:
213 // This function converts a TimeTicks value taken in the browser process 215 // This function converts a TimeTicks value taken in the browser process
214 // to navigation_start_ if: 216 // to navigation_start_ if:
215 // - base::TimeTicks is not comparable across processes because the clock 217 // - base::TimeTicks is not comparable across processes because the clock
216 // is not system wide monotonic. 218 // is not system wide monotonic.
217 // - *event_time < navigation_start_ 219 // - *event_time < navigation_start_
218 void ClampBrowserTimestampIfInterProcessTimeTickSkew( 220 void ClampBrowserTimestampIfInterProcessTimeTickSkew(
219 base::TimeTicks* event_time); 221 base::TimeTicks* event_time);
220 222
221 void UpdateAbortInternal(UserAbortType abort_type, 223 void UpdateAbortInternal(UserAbortType abort_type,
224 bool user_initiated,
222 base::TimeTicks timestamp, 225 base::TimeTicks timestamp,
223 bool is_certainly_browser_timestamp); 226 bool is_certainly_browser_timestamp);
224 227
225 // If |final_navigation| is null, then this is an "unparented" abort chain, 228 // If |final_navigation| is null, then this is an "unparented" abort chain,
226 // and represents a sequence of provisional aborts that never ends with a 229 // and represents a sequence of provisional aborts that never ends with a
227 // committed load. 230 // committed load.
228 void LogAbortChainHistograms(content::NavigationHandle* final_navigation); 231 void LogAbortChainHistograms(content::NavigationHandle* final_navigation);
229 232
230 // Whether we stopped tracking this navigation after it was initiated. We may 233 // Whether we stopped tracking this navigation after it was initiated. We may
231 // stop tracking a navigation if it doesn't meet the criteria for tracking 234 // stop tracking a navigation if it doesn't meet the criteria for tracking
(...skipping 13 matching lines...) Expand all
245 248
246 // The URL of this page load. This is the provisional url before commit 249 // The URL of this page load. This is the provisional url before commit
247 // (before redirects), and the committed url after commit. 250 // (before redirects), and the committed url after commit.
248 GURL url_; 251 GURL url_;
249 252
250 std::unique_ptr<FailedProvisionalLoadInfo> failed_provisional_load_info_; 253 std::unique_ptr<FailedProvisionalLoadInfo> failed_provisional_load_info_;
251 254
252 // Will be ABORT_NONE if we have not aborted this load yet. Otherwise will 255 // Will be ABORT_NONE if we have not aborted this load yet. Otherwise will
253 // be the first abort action the user performed. 256 // be the first abort action the user performed.
254 UserAbortType abort_type_; 257 UserAbortType abort_type_;
258
259 // This boolean is only an approximation. As the aborts pipeline is updated,
260 // more abort types will have this set to true. Currently, this is only set
261 // for navigations aborting navigations.
262 bool abort_user_initiated_;
263
255 base::TimeTicks abort_time_; 264 base::TimeTicks abort_time_;
256 265
257 // We record separate metrics for events that occur after a background, 266 // We record separate metrics for events that occur after a background,
258 // because metrics like layout/paint are delayed artificially 267 // because metrics like layout/paint are delayed artificially
259 // when they occur in the background. 268 // when they occur in the background.
260 base::TimeTicks background_time_; 269 base::TimeTicks background_time_;
261 base::TimeTicks foreground_time_; 270 base::TimeTicks foreground_time_;
262 bool started_in_foreground_; 271 bool started_in_foreground_;
263 272
264 PageLoadTiming timing_; 273 PageLoadTiming timing_;
265 PageLoadMetadata metadata_; 274 PageLoadMetadata metadata_;
266 275
267 ui::PageTransition page_transition_; 276 ui::PageTransition page_transition_;
268 277
269 // Note: these are only approximations, based on WebContents attribution from 278 // Note: these are only approximations, based on WebContents attribution from
270 // ResourceRequestInfo objects while this is the currently committed load in 279 // ResourceRequestInfo objects while this is the currently committed load in
271 // the WebContents. 280 // the WebContents.
272 int num_cache_requests_; 281 int num_cache_requests_;
273 int num_network_requests_; 282 int num_network_requests_;
274 283
284 // This is derived from the user gesture bit in the renderer. For browser
285 // initiated navigations this will always be true.
286 bool user_gesture_;
287
275 // This is a subtle member. If a provisional load A gets aborted by 288 // This is a subtle member. If a provisional load A gets aborted by
276 // provisional load B, which gets aborted by C that eventually commits, then 289 // provisional load B, which gets aborted by C that eventually commits, then
277 // there exists an abort chain of length 2, starting at A's navigation_start. 290 // there exists an abort chain of length 2, starting at A's navigation_start.
278 // This is useful because it allows histograming abort chain lengths based on 291 // This is useful because it allows histograming abort chain lengths based on
279 // what the last load's transition type is. i.e. holding down F-5 to spam 292 // what the last load's transition type is. i.e. holding down F-5 to spam
280 // reload will produce a long chain with the RELOAD transition. 293 // reload will produce a long chain with the RELOAD transition.
281 const int aborted_chain_size_; 294 const int aborted_chain_size_;
282 295
283 // This member counts consecutive provisional aborts that share a url. It will 296 // This member counts consecutive provisional aborts that share a url. It will
284 // always be less than or equal to |aborted_chain_size_|. 297 // always be less than or equal to |aborted_chain_size_|.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 void HandleFailedNavigationForTrackedLoad( 360 void HandleFailedNavigationForTrackedLoad(
348 content::NavigationHandle* navigation_handle, 361 content::NavigationHandle* navigation_handle,
349 std::unique_ptr<PageLoadTracker> tracker); 362 std::unique_ptr<PageLoadTracker> tracker);
350 363
351 void HandleCommittedNavigationForTrackedLoad( 364 void HandleCommittedNavigationForTrackedLoad(
352 content::NavigationHandle* navigation_handle, 365 content::NavigationHandle* navigation_handle,
353 std::unique_ptr<PageLoadTracker> tracker); 366 std::unique_ptr<PageLoadTracker> tracker);
354 367
355 // Notify all loads, provisional and committed, that we performed an action 368 // Notify all loads, provisional and committed, that we performed an action
356 // that might abort them. 369 // that might abort them.
357 void NotifyAbortAllLoads(UserAbortType abort_type); 370 void NotifyAbortAllLoads(UserAbortType abort_type, bool user_initiated);
358 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type, 371 void NotifyAbortAllLoadsWithTimestamp(UserAbortType abort_type,
372 bool user_initiated,
359 base::TimeTicks timestamp, 373 base::TimeTicks timestamp,
360 bool is_certainly_browser_timestamp); 374 bool is_certainly_browser_timestamp);
361 375
362 // Register / Unregister input event callback to given RenderViewHost 376 // Register / Unregister input event callback to given RenderViewHost
363 void RegisterInputEventObserver(content::RenderViewHost* host); 377 void RegisterInputEventObserver(content::RenderViewHost* host);
364 void UnregisterInputEventObserver(content::RenderViewHost* host); 378 void UnregisterInputEventObserver(content::RenderViewHost* host);
365 379
366 // Notify aborted provisional loads that a new navigation occurred. This is 380 // Notify aborted provisional loads that a new navigation occurred. This is
367 // used for more consistent attribution tracking for aborted provisional 381 // used for more consistent attribution tracking for aborted provisional
368 // loads. This method returns the provisional load that was likely aborted 382 // loads. This method returns the provisional load that was likely aborted
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 416
403 // Has the MWCO observed at least one navigation? 417 // Has the MWCO observed at least one navigation?
404 bool has_navigated_; 418 bool has_navigated_;
405 419
406 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); 420 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver);
407 }; 421 };
408 422
409 } // namespace page_load_metrics 423 } // namespace page_load_metrics
410 424
411 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_ 425 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_METRICS_WEB_CONTENTS_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698