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_metrics_struct_traits.h

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: Addressed comments, remove unnecessary RunUntilIdle, call OnTimingUpdated directly in unit tests 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_STRUCT_TRAITS_H_
6 #define CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_STRUCT_TRAITS_H_
7
8 #include "base/time/time.h"
9 #include "chrome/common/page_load_metrics/page_load_metrics.mojom.h"
10 #include "chrome/common/page_load_metrics/page_load_timing.h"
11 #include "mojo/common/common_custom_types_struct_traits.h"
12 #include "mojo/public/cpp/bindings/struct_traits.h"
13
14 namespace mojo {
15
16 template <>
17 struct StructTraits<page_load_metrics::mojom::DocumentTimingDataView,
18 page_load_metrics::DocumentTiming> {
19 static base::Optional<base::TimeDelta> dom_content_loaded_event_start(
20 const page_load_metrics::DocumentTiming& document_timing) {
21 return document_timing.dom_content_loaded_event_start;
22 }
23
24 static base::Optional<base::TimeDelta> load_event_start(
25 const page_load_metrics::DocumentTiming& document_timing) {
26 return document_timing.load_event_start;
27 }
28
29 static base::Optional<base::TimeDelta> first_layout(
30 const page_load_metrics::DocumentTiming& document_timing) {
31 return document_timing.first_layout;
32 }
33
34 static bool Read(page_load_metrics::mojom::DocumentTimingDataView data,
35 page_load_metrics::DocumentTiming* out);
36 };
37
38 template <>
39 struct StructTraits<page_load_metrics::mojom::PaintTimingDataView,
40 page_load_metrics::PaintTiming> {
41 static base::Optional<base::TimeDelta> first_paint(
42 const page_load_metrics::PaintTiming& paint_timing) {
43 return paint_timing.first_paint;
44 }
45
46 static base::Optional<base::TimeDelta> first_text_paint(
47 const page_load_metrics::PaintTiming& paint_timing) {
48 return paint_timing.first_text_paint;
49 }
50
51 static base::Optional<base::TimeDelta> first_image_paint(
52 const page_load_metrics::PaintTiming& paint_timing) {
53 return paint_timing.first_image_paint;
54 }
55
56 static base::Optional<base::TimeDelta> first_contentful_paint(
57 const page_load_metrics::PaintTiming& paint_timing) {
58 return paint_timing.first_contentful_paint;
59 }
60
61 static base::Optional<base::TimeDelta> first_meaningful_paint(
62 const page_load_metrics::PaintTiming& paint_timing) {
63 return paint_timing.first_meaningful_paint;
64 }
65
66 static bool Read(page_load_metrics::mojom::PaintTimingDataView data,
67 page_load_metrics::PaintTiming* out);
68 };
69
70 template <>
71 struct StructTraits<page_load_metrics::mojom::ParseTimingDataView,
72 page_load_metrics::ParseTiming> {
73 static base::Optional<base::TimeDelta> parse_start(
74 const page_load_metrics::ParseTiming& parse_timing) {
75 return parse_timing.parse_start;
76 }
77
78 static base::Optional<base::TimeDelta> parse_stop(
79 const page_load_metrics::ParseTiming& parse_timing) {
80 return parse_timing.parse_stop;
81 }
82
83 static base::Optional<base::TimeDelta> parse_blocked_on_script_load_duration(
84 const page_load_metrics::ParseTiming& parse_timing) {
85 return parse_timing.parse_blocked_on_script_load_duration;
86 }
87
88 static base::Optional<base::TimeDelta>
89 parse_blocked_on_script_load_from_document_write_duration(
90 const page_load_metrics::ParseTiming& parse_timing) {
91 return parse_timing
92 .parse_blocked_on_script_load_from_document_write_duration;
93 }
94
95 static base::Optional<base::TimeDelta>
96 parse_blocked_on_script_execution_duration(
97 const page_load_metrics::ParseTiming& parse_timing) {
98 return parse_timing.parse_blocked_on_script_execution_duration;
99 }
100
101 static base::Optional<base::TimeDelta>
102 parse_blocked_on_script_execution_from_document_write_duration(
103 const page_load_metrics::ParseTiming& parse_timing) {
104 return parse_timing
105 .parse_blocked_on_script_execution_from_document_write_duration;
106 }
107
108 static bool Read(page_load_metrics::mojom::ParseTimingDataView data,
109 page_load_metrics::ParseTiming* out);
110 };
111
112 template <>
113 struct StructTraits<page_load_metrics::mojom::StyleSheetTimingDataView,
114 page_load_metrics::StyleSheetTiming> {
115 static base::Optional<base::TimeDelta>
116 author_style_sheet_parse_duration_before_fcp(
117 const page_load_metrics::StyleSheetTiming& style_sheet_timing) {
118 return style_sheet_timing.author_style_sheet_parse_duration_before_fcp;
119 }
120
121 static base::Optional<base::TimeDelta> update_style_duration_before_fcp(
122 const page_load_metrics::StyleSheetTiming& style_sheet_timing) {
123 return style_sheet_timing.update_style_duration_before_fcp;
124 }
125
126 static bool Read(page_load_metrics::mojom::StyleSheetTimingDataView data,
127 page_load_metrics::StyleSheetTiming* out);
128 };
129
130 template <>
131 struct StructTraits<page_load_metrics::mojom::PageLoadTimingDataView,
132 page_load_metrics::PageLoadTiming> {
133 static base::Time navigation_start(
134 const page_load_metrics::PageLoadTiming& page_load_timing) {
135 return page_load_timing.navigation_start;
136 }
137
138 static base::Optional<base::TimeDelta> response_start(
139 const page_load_metrics::PageLoadTiming& page_load_timing) {
140 return page_load_timing.response_start;
141 }
142
143 static page_load_metrics::DocumentTiming document_timing(
144 const page_load_metrics::PageLoadTiming& page_load_timing) {
145 return page_load_timing.document_timing;
146 }
147
148 static page_load_metrics::PaintTiming paint_timing(
149 const page_load_metrics::PageLoadTiming& page_load_timing) {
150 return page_load_timing.paint_timing;
151 }
152
153 static page_load_metrics::ParseTiming parse_timing(
154 const page_load_metrics::PageLoadTiming& page_load_timing) {
155 return page_load_timing.parse_timing;
156 }
157
158 static page_load_metrics::StyleSheetTiming style_sheet_timing(
159 const page_load_metrics::PageLoadTiming& page_load_timing) {
160 return page_load_timing.style_sheet_timing;
161 }
162
163 static bool Read(page_load_metrics::mojom::PageLoadTimingDataView data,
164 page_load_metrics::PageLoadTiming* out);
165 };
166
167 template <>
168 struct StructTraits<page_load_metrics::mojom::PageLoadMetadataDataView,
169 page_load_metrics::PageLoadMetadata> {
170 static int behavior_flags(
171 const page_load_metrics::PageLoadMetadata& page_load_metadata) {
172 return page_load_metadata.behavior_flags;
173 }
174
175 static bool Read(page_load_metrics::mojom::PageLoadMetadataDataView data,
176 page_load_metrics::PageLoadMetadata* out);
177 };
178
179 } // namespace mojo
180
181 #endif // CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698