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 | 33 // The events in this enum are all disjoint, and summing them yields the total |
34 // A provisional load is a load before it commits, i.e. before it receives the | 34 // number of main frame provisional loads. |
35 // first bytes of the response body or knows the encoding of the response | 35 enum ProvisionalLoadEvent { |
Bryan McQuade
2015/10/09 14:24:35
general question here: do we want to track all pro
Charlie Harrison
2015/10/09 22:30:41
Talked about this offline: we can't know if it mee
| |
36 // body. A load failed before it was committed for any reason, e.g. from a | 36 // An aborted provisional load has error net::ERR_ABORTED. |
37 // user abort or a network timeout. | 37 PROVISIONAL_LOAD_ABORTED, |
38 PAGE_LOAD_FAILED_BEFORE_COMMIT, | 38 // This event captures all the other ways a provisional load can fail. |
39 | 39 PROVISIONAL_LOAD_FAILED_NON_ABORT, |
Bryan McQuade
2015/10/09 14:24:35
i noticed in cries's message that some provisional
Charlie Harrison
2015/10/09 22:30:41
Will look into this.
Bryan McQuade
2015/10/12 16:39:22
Thanks! Just want to get clarity on this one befor
| |
40 // A subset of PAGE_LOAD_FAILED_BEFORE_COMMIT, this counts the | 40 // Counts the number of successful commits. |
41 // specific failures due to user aborts. | 41 PROVISIONAL_LOAD_COMMITTED, |
42 PAGE_LOAD_ABORTED_BEFORE_COMMIT, | |
43 | |
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 | 42 |
55 // Add values before this final count. | 43 // Add values before this final count. |
56 PAGE_LOAD_LAST_ENTRY | 44 PROVISIONAL_LOAD_LAST_ENTRY |
45 }; | |
46 | |
47 // If you add elements from this enum, make sure you update the enum | |
48 // value in histograms.xml. Only add elements to the end to prevent | |
49 // inconsistencies between versions. | |
Randy Smith (Not in Mondays)
2015/10/08 19:07:11
Should this comment be before the above enum and r
Charlie Harrison
2015/10/08 21:27:02
It's duplicated as is, and I think that's the clea
Randy Smith (Not in Mondays)
2015/10/12 15:45:22
Whoops, I'm sorry, missed the duplication. Please
| |
50 // | |
51 // CommittedLoadEvents are events that occur on committed loads that we track. | |
52 // Note that we capture events only for committed loads that: | |
53 // - Are http/https. | |
54 // - Not same-page navigations. | |
55 // - Are not navigations to an error page. | |
56 // We only know these things about a navigation post-commit. | |
57 enum CommittedLoadEvent { | |
Bryan McQuade
2015/10/09 14:24:35
do we want to track all committed loads, or just t
Charlie Harrison
2015/10/09 22:30:41
I think we should only track the ones we care abou
| |
58 // Counts of how many loads commit. | |
59 COMMITTED_LOAD_STARTED, | |
60 | |
61 // These two events are disjoint. Sum them to find the total number of | |
62 // committed loads that we end up tracking. | |
63 COMMITTED_LOAD_ABORTED_BEFORE_FIRST_LAYOUT, | |
64 COMMITTED_LOAD_SUCCESSFUL_FIRST_LAYOUT, | |
Randy Smith (Not in Mondays)
2015/10/08 19:07:11
I'm slightly confused about these enums. Is it tr
Charlie Harrison
2015/10/08 21:27:02
#(loads that failed but weren't aborted before fir
Bryan McQuade
2015/10/09 14:24:35
Given ksakamoto's work on time to first text and t
Charlie Harrison
2015/10/09 22:30:41
adding a TODO to add them to the code once we have
Randy Smith (Not in Mondays)
2015/10/12 15:45:22
So I take that to mean that there's no way that a
Charlie Harrison
2015/10/12 18:39:50
We were treating all failures post commit as abort
| |
65 | |
66 // A timing IPC was sent from the renderer that did not line up with previous | |
67 // data we've received (i.e. navigation start is different or the timing | |
68 // struct is somehow invalid). | |
69 COMMITTED_LOAD_BAD_IPC, | |
Bryan McQuade
2015/10/09 14:24:35
wondering if perhaps we should move errors to thei
Charlie Harrison
2015/10/09 22:30:41
Done, but with a caveat that histograms can't be t
| |
70 | |
71 // Add values before this final count. | |
72 COMMITTED_LOAD_LAST_ENTRY | |
57 }; | 73 }; |
58 | 74 |
59 class PageLoadTracker { | 75 class PageLoadTracker { |
60 public: | 76 public: |
61 explicit PageLoadTracker(bool in_foreground); | 77 explicit PageLoadTracker(bool in_foreground); |
62 ~PageLoadTracker(); | 78 ~PageLoadTracker(); |
63 void Commit(); | 79 void Commit(); |
64 void WebContentsHidden(); | 80 void WebContentsHidden(); |
81 void WebContentsShown(); | |
65 | 82 |
66 // Returns true if the timing was successfully updated. | 83 // Returns true if the timing was successfully updated. |
67 bool UpdateTiming(const PageLoadTiming& timing); | 84 bool UpdateTiming(const PageLoadTiming& timing); |
68 void RecordEvent(PageLoadEvent event); | 85 void RecordProvisionalEvent(ProvisionalLoadEvent event); |
86 void RecordCommittedEvent(CommittedLoadEvent event, bool backgrounded); | |
69 | 87 |
70 private: | 88 private: |
89 bool HasBackgrounded(); | |
71 void RecordTimingHistograms(); | 90 void RecordTimingHistograms(); |
72 | 91 |
73 bool has_commit_; | 92 bool has_commit_; |
74 | 93 |
75 // We record separate metrics for events that occur after a background, | 94 // We record separate metrics for events that occur after a background, |
76 // because metrics like layout/paint are delayed artificially | 95 // because metrics like layout/paint are delayed artificially |
77 // when they occur in the bacground. | 96 // when they occur in the bacground. |
78 base::TimeTicks background_time_; | 97 base::TimeTicks background_time_; |
98 base::TimeTicks foreground_time_; | |
79 bool started_in_foreground_; | 99 bool started_in_foreground_; |
80 | 100 |
81 PageLoadTiming timing_; | 101 PageLoadTiming timing_; |
82 | 102 |
83 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); | 103 DISALLOW_COPY_AND_ASSIGN(PageLoadTracker); |
84 }; | 104 }; |
85 | 105 |
86 // MetricsWebContentsObserver logs page load UMA metrics based on | 106 // MetricsWebContentsObserver logs page load UMA metrics based on |
87 // IPC messages received from a MetricsRenderFrameObserver. | 107 // IPC messages received from a MetricsRenderFrameObserver. |
88 class MetricsWebContentsObserver | 108 class MetricsWebContentsObserver |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> | 143 base::ScopedPtrMap<content::NavigationHandle*, scoped_ptr<PageLoadTracker>> |
124 provisional_loads_; | 144 provisional_loads_; |
125 scoped_ptr<PageLoadTracker> committed_load_; | 145 scoped_ptr<PageLoadTracker> committed_load_; |
126 | 146 |
127 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); | 147 DISALLOW_COPY_AND_ASSIGN(MetricsWebContentsObserver); |
128 }; | 148 }; |
129 | 149 |
130 } // namespace page_load_metrics | 150 } // namespace page_load_metrics |
131 | 151 |
132 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ | 152 #endif // COMPONENTS_PAGE_LOAD_METRICS_BROWSER_PAGE_LOAD_METRICS_WEB_CONTENTS_O BSERVER_H_ |
OLD | NEW |