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

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

Issue 2699933003: Generalize abort tracking to page end state tracking (Closed)
Patch Set: fix comment Created 3 years, 10 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 CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_
7 7
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/optional.h" 9 #include "base/optional.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h"
11 12
12 #define PAGE_LOAD_HISTOGRAM(name, sample) \ 13 #define PAGE_LOAD_HISTOGRAM(name, sample) \
13 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \ 14 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \
14 base::TimeDelta::FromMilliseconds(10), \ 15 base::TimeDelta::FromMilliseconds(10), \
15 base::TimeDelta::FromMinutes(10), 100) 16 base::TimeDelta::FromMinutes(10), 100)
16 17
17 // Records |bytes| to |histogram_name| in kilobytes (i.e., bytes / 1024). 18 // Records |bytes| to |histogram_name| in kilobytes (i.e., bytes / 1024).
18 #define PAGE_BYTES_HISTOGRAM(histogram_name, bytes) \ 19 #define PAGE_BYTES_HISTOGRAM(histogram_name, bytes) \
19 UMA_HISTOGRAM_CUSTOM_COUNTS( \ 20 UMA_HISTOGRAM_CUSTOM_COUNTS( \
20 histogram_name, static_cast<int>((bytes) / 1024), 1, 500 * 1024, 50) 21 histogram_name, static_cast<int>((bytes) / 1024), 1, 500 * 1024, 50)
21 22
22 #define PAGE_RESOURCE_COUNT_HISTOGRAM UMA_HISTOGRAM_COUNTS_10000 23 #define PAGE_RESOURCE_COUNT_HISTOGRAM UMA_HISTOGRAM_COUNTS_10000
23 24
24 namespace page_load_metrics { 25 namespace page_load_metrics {
25 26
26 struct PageLoadExtraInfo; 27 struct PageLoadExtraInfo;
27 28
29 // Reasons a page load can be aborted.
30 enum PageAbortReason {
31 // Represents no abort.
32 ABORT_NONE,
33
34 // The page was reloaded, possibly by the user.
35 ABORT_RELOAD,
36
37 // The page was navigated away from, via a back or forward navigation.
38 ABORT_FORWARD_BACK,
39
40 // If the page load is replaced by a new navigation. This includes link
41 // clicks, typing in the omnibox (not a reload), and form submissions.
42 ABORT_NEW_NAVIGATION,
43
44 // The page load was stopped (e.g. the user presses the stop X button).
45 ABORT_STOP,
46
47 // Page load ended due to closing the tab or browser.
48 ABORT_CLOSE,
49
50 // The page load was backgrounded, e.g. the browser was minimized or the user
51 // switched tabs. Note that the same page may be foregrounded in the future,
52 // so this is not a 'terminal' abort type.
53 ABORT_BACKGROUND,
54
55 // We don't know why the page load ended. This is the value we assign to a
56 // terminated provisional load if the only signal we get is the load finished
57 // without committing, either without error or with net::ERR_ABORTED.
58 ABORT_OTHER
59 };
60
61 // Information related to a page load abort.
62 struct PageAbortInfo {
63 PageAbortInfo()
64 : reason(ABORT_NONE),
65 user_initiated_info(UserInitiatedInfo::NotUserInitiated()) {}
66 PageAbortInfo(PageAbortReason reason,
67 UserInitiatedInfo user_initiated_info,
68 base::TimeDelta time_to_abort)
69 : reason(reason),
70 user_initiated_info(user_initiated_info),
71 time_to_abort(time_to_abort) {}
72
73 // The reason / cause for the abort.
74 const PageAbortReason reason;
75
76 // The fields below are only valid if reason != ABORT_NONE.
77
78 // Information about whether the abort was initiated by a user.
79 const UserInitiatedInfo user_initiated_info;
80
81 // The time from navigation start to the time the page load was aborted.
82 const base::TimeDelta time_to_abort;
83 };
84
28 // Returns true if: 85 // Returns true if:
29 // - We have timing information for the event. 86 // - We have timing information for the event.
30 // - The page load started while the page was in the foreground. 87 // - The page load started while the page was in the foreground.
31 // - The event occurred prior to the page being moved to the background. 88 // - The event occurred prior to the page being moved to the background.
32 // When a page is backgrounded, some events (e.g. paint) are delayed. Since 89 // When a page is backgrounded, some events (e.g. paint) are delayed. Since
33 // these data points can skew the mean, they should not be mixed with timing 90 // these data points can skew the mean, they should not be mixed with timing
34 // events that occurred in the foreground. 91 // events that occurred in the foreground.
35 // If the event time delta and background time delta are equal, we still 92 // If the event time delta and background time delta are equal, we still
36 // consider the event to be logged in the foreground histogram since any 93 // consider the event to be logged in the foreground histogram since any
37 // background specific handling would not yet have been applied to that event. 94 // background specific handling would not yet have been applied to that event.
38 bool WasStartedInForegroundOptionalEventInForeground( 95 bool WasStartedInForegroundOptionalEventInForeground(
39 const base::Optional<base::TimeDelta>& event, 96 const base::Optional<base::TimeDelta>& event,
40 const PageLoadExtraInfo& info); 97 const PageLoadExtraInfo& info);
41 98
99 PageAbortInfo GetPageAbortInfo(const PageLoadExtraInfo& info);
100
42 } // namespace page_load_metrics 101 } // namespace page_load_metrics
43 102
44 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_ 103 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698