OLD | NEW |
---|---|
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_WEB_CONTENTS_OBSE RVER_H_ | 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ |
6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ | 6 #define COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_OBSE RVER_H_ |
7 | 7 |
8 #include "base/containers/scoped_ptr_map.h" | 8 #include "base/containers/scoped_ptr_map.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 namespace IPC { | 22 namespace IPC { |
23 class Message; | 23 class Message; |
24 } // namespace IPC | 24 } // namespace IPC |
25 | 25 |
26 namespace page_load_metrics { | 26 namespace page_load_metrics { |
27 | 27 |
28 // If you add elements from this enum, make sure you update the enum | 28 // If you add elements from this enum, make sure you update the enum |
29 // value in histograms.xml. Only add elements to the end to prevent | 29 // value in histograms.xml. Only add elements to the end to prevent |
30 // inconsistencies between versions. | 30 // inconsistencies between versions. |
31 enum PageLoadEvent { | 31 // |
32 PAGE_LOAD_STARTED, | 32 // ProvisionalLoadEvents count all main frame navigations before they commit. |
33 // The events in this enum are all disjoint, and summing them yields the total | |
34 // number of main frame provisional loads. | |
35 enum ProvisionalLoadEvent { | |
36 // This case occurs when the NavigationHandle finishes and reports | |
37 // !HasCommitted(), but reports no net::Error. This should not occur | |
38 // pre-PlzNavigate, but afterwards it should represent the navigation stopped | |
39 // by the user before it was ready to commit. | |
40 PROVISIONAL_LOAD_STOPPED, | |
33 | 41 |
34 // A provisional load is a load before it commits, i.e. before it receives the | 42 // An aborted provisional load has error net::ERR_ABORTED. Note that this can |
35 // first bytes of the response body or knows the encoding of the response | 43 // come from some non user-initiated errors, such as downloads, or 204 |
36 // body. A load failed before it was committed for any reason, e.g. from a | 44 // responses. See crbug.com/542369. |
37 // user abort or a network timeout. | 45 PROVISIONAL_LOAD_ERR_ABORTED, |
38 PAGE_LOAD_FAILED_BEFORE_COMMIT, | |
39 | 46 |
40 // A subset of PAGE_LOAD_FAILED_BEFORE_COMMIT, this counts the | 47 // This event captures all the other ways a provisional load can fail. |
41 // specific failures due to user aborts. | 48 PROVISIONAL_LOAD_ERR_FAILED_NON_ABORT, |
42 PAGE_LOAD_ABORTED_BEFORE_COMMIT, | 49 // Counts the number of successful commits. |
43 | 50 PROVISIONAL_LOAD_COMMITTED, |
44 // When a load is aborted anytime before the page's first layout, we increase | |
45 // these counts. This includes all failed provisional loads. | |
46 PAGE_LOAD_ABORTED_BEFORE_FIRST_LAYOUT, | |
47 | |
48 // We increase this count if a page load successfully has a layout. | |
49 // Differentiate between loads that were backgrounded before first layout. | |
50 // Note that a load that is backgrounded, then foregrounded before first | |
51 // layout will still end up in the backgrounded bucket. | |
52 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_FOREGROUND, | |
53 PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_BACKGROUND, | |
54 | 51 |
55 // Add values before this final count. | 52 // Add values before this final count. |
56 PAGE_LOAD_LAST_ENTRY | 53 PROVISIONAL_LOAD_LAST_ENTRY |
54 }; | |
55 | |
56 // If you add elements from this enum, make sure you update the enum | |
57 // value in histograms.xml. Only add elements to the end to prevent | |
58 // inconsistencies between versions. | |
59 // | |
60 // CommittedLoadEvents are events that occur on committed loads that we track. | |
61 // Note that we capture events only for committed loads that: | |
62 // - Are http/https. | |
63 // - Not same-page navigations. | |
64 // - Are not navigations to an error page. | |
65 // We only know these things about a navigation post-commit. | |
66 enum CommittedLoadEvent { | |
67 // Counts of how many loads commit. When segmented by | |
68 // background/foreground specifies whether the provisional load started | |
Randy Smith (Not in Mondays)
2015/10/15 18:39:09
nit, suggestion: "provisional" -> "eventually comm
| |
69 // in the background or foreground, not the actual commit event. This | |
70 // is because we don't have all the data to filter relevant page loads on | |
71 // provisional loads, and relevant loads started in foreground/background | |
72 // gives better data on user perception than when the load is committed. | |
73 COMMITTED_LOAD_STARTED, | |
74 | |
75 // These two events are disjoint. Sum them to find the total number of | |
76 // committed loads that we end up tracking. | |
77 COMMITTED_LOAD_FAILED_BEFORE_FIRST_LAYOUT, | |
78 COMMITTED_LOAD_SUCCESSFUL_FIRST_LAYOUT, | |
79 | |
80 // TODO(csharrison) once first paint metrics are in place, add new events. | |
81 | |
82 // Add values before this final count. | |
83 COMMITTED_LOAD_LAST_ENTRY | |
84 }; | |
85 | |
86 // These errors are internal to the page_load_metrics subsystem and do not | |
87 // reflect actual errors that occur during a page load. | |
88 enum InternalErrorLoadEvent { | |
89 // A timing IPC was sent from the renderer that did not line up with previous | |
90 // data we've received (i.e. navigation start is different or the timing | |
91 // struct is somehow invalid). This error can only occur once the IPC is | |
92 // vetted in other ways (see other errors). | |
93 ERR_BAD_TIMING_IPC, | |
94 | |
95 // The following IPCs are not mutually exclusive. | |
96 // | |
97 // We received an IPC when we weren't tracking a committed load. This will | |
98 // often happen if we get an IPC from a bad URL scheme (that is, the renderer | |
99 // sent us an IPC from a navigation we don't care about). | |
100 ERR_IPC_WITH_NO_COMMITTED_LOAD, | |
101 | |
102 // Received a notification from a frame that has been navigated away from. | |
103 ERR_IPC_FROM_WRONG_FRAME, | |
104 | |
105 // We received an IPC even through the last committed url from the browser | |
106 // was not http/s. This can happen with the renderer sending IPCs for the | |
107 // new tab page. This will often come paired with | |
108 // ERR_IPC_WITH_NO_COMMITTED_LOAD. | |
109 ERR_IPC_FROM_BAD_URL_SCHEME, | |
110 | |
111 // Add values before this final count. | |
112 ERR_LAST_ENTRY | |
57 }; | 113 }; |
58 | 114 |
59 class PageLoadTracker { | 115 class PageLoadTracker { |
60 public: | 116 public: |
61 explicit PageLoadTracker(bool in_foreground); | 117 explicit PageLoadTracker(bool in_foreground); |
62 ~PageLoadTracker(); | 118 ~PageLoadTracker(); |
63 void Commit(); | 119 void Commit(); |
64 void WebContentsHidden(); | 120 void WebContentsHidden(); |
121 void WebContentsShown(); | |
65 | 122 |
66 // Returns true if the timing was successfully updated. | 123 // Returns true if the timing was successfully updated. |
67 bool UpdateTiming(const PageLoadTiming& timing); | 124 bool UpdateTiming(const PageLoadTiming& timing); |
68 void RecordEvent(PageLoadEvent event); | 125 void RecordProvisionalEvent(ProvisionalLoadEvent event); |
126 void RecordCommittedEvent(CommittedLoadEvent event, bool backgrounded); | |
127 bool HasBackgrounded(); | |
69 | 128 |
70 private: | 129 private: |
71 void RecordTimingHistograms(); | 130 void RecordTimingHistograms(); |
72 | 131 |
73 bool has_commit_; | 132 bool has_commit_; |
74 | 133 |
75 // We record separate metrics for events that occur after a background, | 134 // We record separate metrics for events that occur after a background, |
76 // because metrics like layout/paint are delayed artificially | 135 // because metrics like layout/paint are delayed artificially |
77 // when they occur in the bacground. | 136 // when they occur in the bacground. |
78 base::TimeTicks background_time_; | 137 base::TimeTicks background_time_; |
138 base::TimeTicks foreground_time_; | |
79 bool started_in_foreground_; | 139 bool started_in_foreground_; |
80 | 140 |
81 PageLoadTiming timing_; | 141 PageLoadTiming timing_; |
82 | 142 |
83 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); | 143 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |
84 }; | 144 }; |
85 | 145 |
86 // MetricsWebContentsObserver logs page load UMA metrics based on | 146 // MetricsWebContentsObserver logs page load UMA metrics based on |
87 // IPC messages received from a MetricsRenderFrameObserver. | 147 // IPC messages received from a MetricsRenderFrameObserver. |
88 class MetricsWebContentsObserver | 148 class MetricsWebContentsObserver |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> | 183 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> |
124 provisional_loads_; | 184 provisional_loads_; |
125 scoped_ptr<PageLoadTracker> committed_load_; | 185 scoped_ptr<PageLoadTracker> committed_load_; |
126 | 186 |
127 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 187 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
128 }; | 188 }; |
129 | 189 |
130 } // namespace page_load_metrics | 190 } // namespace page_load_metrics |
131 | 191 |
132 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | 192 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ |
OLD | NEW |