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

Side by Side Diff: chrome/common/page_load_metrics/page_load_timing.h

Issue 2874663005: [Page Load Metrics] Add mojom file to page load metrics. (Closed)
Patch Set: Remove unnecessary variable Created 3 years, 7 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_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_TIMING_H_ 5 #ifndef CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_TIMING_H_
6 #define CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_TIMING_H_ 6 #define CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_TIMING_H_
7 7
8 #include "base/optional.h" 8 #include "base/optional.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h"
10 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" 11 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h"
11 12
12 namespace page_load_metrics { 13 namespace page_load_metrics {
13 14
14 struct DocumentTiming { 15 // Initialize an empty PageLoadTiming with initialized empty sub-members.
15 DocumentTiming(); 16 mojom::PageLoadTimingPtr CreatePageLoadTiming();
16 DocumentTiming(const DocumentTiming& other);
17 ~DocumentTiming();
18 17
19 bool operator==(const DocumentTiming& other) const; 18 bool IsEmpty(const mojom::DocumentTiming& timing);
20 bool operator!=(const DocumentTiming& other) const { 19 bool IsEmpty(const mojom::PaintTiming& timing);
21 return !(*this == other); 20 bool IsEmpty(const mojom::ParseTiming& timing);
22 } 21 bool IsEmpty(const mojom::StyleSheetTiming& timing);
22 bool IsEmpty(const mojom::PageLoadTiming& timing);
23 23
24 bool IsEmpty() const; 24 void InitPageLoadTimingForTest(mojom::PageLoadTiming* timing);
25
26 // TimeDeltas below relative to navigation start:
27
28 // Time immediately before the DOMContentLoaded event is fired.
29 base::Optional<base::TimeDelta> dom_content_loaded_event_start;
30 // Time immediately before the load event is fired.
31 base::Optional<base::TimeDelta> load_event_start;
32 // Time when the first layout is completed.
33 base::Optional<base::TimeDelta> first_layout;
34 };
35
36 struct PaintTiming {
37 PaintTiming();
38 PaintTiming(const PaintTiming& other);
39 ~PaintTiming();
40
41 bool operator==(const PaintTiming& other) const;
42 bool operator!=(const PaintTiming& other) const { return !(*this == other); }
43
44 bool IsEmpty() const;
45
46 // TimeDeltas below relative to navigation start:
47
48 // Time when the first paint is performed.
49 base::Optional<base::TimeDelta> first_paint;
50 // Time when the first non-blank text is painted.
51 base::Optional<base::TimeDelta> first_text_paint;
52 // Time when the first image is painted.
53 base::Optional<base::TimeDelta> first_image_paint;
54 // Time when the first contentful thing (image, text, etc.) is painted.
55 base::Optional<base::TimeDelta> first_contentful_paint;
56 // (Experimental) Time when the page's primary content is painted.
57 base::Optional<base::TimeDelta> first_meaningful_paint;
58 };
59
60 struct ParseTiming {
61 ParseTiming();
62 ParseTiming(const ParseTiming& other);
63 ~ParseTiming();
64
65 bool operator==(const ParseTiming& other) const;
66 bool operator!=(const ParseTiming& other) const { return !(*this == other); }
67
68 bool IsEmpty() const;
69
70 // TimeDeltas below represent durations of time during the page load:
71
72 // Time that the document's parser started and stopped parsing main resource
73 // content.
74 base::Optional<base::TimeDelta> parse_start;
75 base::Optional<base::TimeDelta> parse_stop;
76
77 // Sum of times when the parser is blocked waiting on the load of a script.
78 // This duration takes place between parser_start and parser_stop, and thus
79 // must be less than or equal to parser_stop - parser_start. Note that this
80 // value may be updated multiple times during the period between parse_start
81 // and parse_stop.
82 base::Optional<base::TimeDelta> parse_blocked_on_script_load_duration;
83
84 // Sum of times when the parser is blocked waiting on the load of a script
85 // that was inserted from document.write. This duration must be less than or
86 // equal to parse_blocked_on_script_load_duration. Note that this value may be
87 // updated multiple times during the period between parse_start and
88 // parse_stop. Note that some uncommon cases where scripts are loaded via
89 // document.write are not currently covered by this field. See crbug/600711
90 // for details.
91 base::Optional<base::TimeDelta>
92 parse_blocked_on_script_load_from_document_write_duration;
93
94 // Sum of times when the parser is executing a script. This duration takes
95 // place between parser_start and parser_stop, and thus must be less than or
96 // equal to parser_stop - parser_start. Note that this value may be updated
97 // multiple times during the period between parse_start and parse_stop.
98 base::Optional<base::TimeDelta> parse_blocked_on_script_execution_duration;
99
100 // Sum of times when the parser is executing a script that was inserted from
101 // document.write. This duration must be less than or equal to
102 // parse_blocked_on_script_load_duration. Note that this value may be updated
103 // multiple times during the period between parse_start and parse_stop. Note
104 // that some uncommon cases where scripts are loaded via document.write are
105 // not currently covered by this field. See crbug/600711 for details.
106 base::Optional<base::TimeDelta>
107 parse_blocked_on_script_execution_from_document_write_duration;
108 };
109
110 struct StyleSheetTiming {
111 StyleSheetTiming();
112 StyleSheetTiming(const StyleSheetTiming& other);
113 ~StyleSheetTiming();
114
115 bool operator==(const StyleSheetTiming& other) const;
116 bool operator!=(const StyleSheetTiming& other) const {
117 return !(*this == other);
118 }
119
120 bool IsEmpty() const;
121
122 // Total time spent parsing author style sheets, before the first contentful
123 // paint.
124 base::Optional<base::TimeDelta> author_style_sheet_parse_duration_before_fcp;
125
126 // Time spent in Document::updateStyle before FCP.
127 base::Optional<base::TimeDelta> update_style_duration_before_fcp;
128 };
129
130 // PageLoadTiming contains timing metrics associated with a page load. Many of
131 // the metrics here are based on the Navigation Timing spec:
132 // http://www.w3.org/TR/navigation-timing/.
133 struct PageLoadTiming {
134 public:
135 PageLoadTiming();
136 PageLoadTiming(const PageLoadTiming& other);
137 ~PageLoadTiming();
138
139 bool operator==(const PageLoadTiming& other) const;
140 bool operator!=(const PageLoadTiming& other) const {
141 return !(*this == other);
142 }
143
144 bool IsEmpty() const;
145
146 // Time that the navigation for the associated page was initiated. Note that
147 // this field is only used for internal tracking purposes and should not be
148 // used by PageLoadMetricsObservers. This field will likely be removed in the
149 // future.
150 base::Time navigation_start;
151
152 // Time relative to navigation_start that the first byte of the response is
153 // received.
154 base::Optional<base::TimeDelta> response_start;
155
156 DocumentTiming document_timing;
157 PaintTiming paint_timing;
158 ParseTiming parse_timing;
159 StyleSheetTiming style_sheet_timing;
160
161 // If you add additional members, also be sure to update operator==,
162 // page_load_metrics_messages.h, and IsEmpty().
163 };
164
165 struct PageLoadMetadata {
166 PageLoadMetadata();
167 bool operator==(const PageLoadMetadata& other) const;
168 // These are packed blink::WebLoadingBehaviorFlag enums.
169 int behavior_flags = blink::kWebLoadingBehaviorNone;
170 };
171 25
172 } // namespace page_load_metrics 26 } // namespace page_load_metrics
173 27
174 #endif // CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_TIMING_H_ 28 #endif // CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_TIMING_H_
OLDNEW
« no previous file with comments | « chrome/common/page_load_metrics/page_load_metrics_param_traits.cc ('k') | chrome/common/page_load_metrics/page_load_timing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698