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

Side by Side Diff: chrome/common/page_load_metrics/page_load_metrics_struct_traits.cc

Issue 2823523003: [Page Load Metrics] PageLoadMetrics Mojofication. (Closed)
Patch Set: Addressed comments, remove unnecessary RunUntilIdle, call OnTimingUpdated directly in unit tests Created 3 years, 8 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 #include "chrome/common/page_load_metrics/page_load_metrics_struct_traits.h"
6
7 #include "ipc/ipc_message_utils.h"
8
9 namespace mojo {
10
11 // static
12 bool StructTraits<page_load_metrics::mojom::DocumentTimingDataView,
13 page_load_metrics::DocumentTiming>::
14 Read(page_load_metrics::mojom::DocumentTimingDataView data,
15 page_load_metrics::DocumentTiming* out) {
16 if (!data.ReadDomContentLoadedEventStart(
17 &out->dom_content_loaded_event_start) ||
18 !data.ReadLoadEventStart(&out->load_event_start) ||
19 !data.ReadFirstLayout(&out->first_layout)) {
20 return false;
21 }
22 return true;
23 }
24
25 // static
26 bool StructTraits<page_load_metrics::mojom::PaintTimingDataView,
27 page_load_metrics::PaintTiming>::
28 Read(page_load_metrics::mojom::PaintTimingDataView data,
29 page_load_metrics::PaintTiming* out) {
30 if (!data.ReadFirstPaint(&out->first_paint) ||
31 !data.ReadFirstTextPaint(&out->first_text_paint) ||
32 !data.ReadFirstImagePaint(&out->first_image_paint) ||
33 !data.ReadFirstContentfulPaint(&out->first_contentful_paint) ||
34 !data.ReadFirstMeaningfulPaint(&out->first_meaningful_paint)) {
35 return false;
36 }
37 return true;
38 }
39
40 // static
41 bool StructTraits<page_load_metrics::mojom::ParseTimingDataView,
42 page_load_metrics::ParseTiming>::
43 Read(page_load_metrics::mojom::ParseTimingDataView data,
44 page_load_metrics::ParseTiming* out) {
45 if (!data.ReadParseStart(&out->parse_start) ||
46 !data.ReadParseStop(&out->parse_stop) ||
47 !data.ReadParseBlockedOnScriptLoadDuration(
48 &out->parse_blocked_on_script_load_duration) ||
49 !data.ReadParseBlockedOnScriptLoadFromDocumentWriteDuration(
50 &out->parse_blocked_on_script_load_from_document_write_duration) ||
51 !data.ReadParseBlockedOnScriptExecutionDuration(
52 &out->parse_blocked_on_script_execution_duration) ||
53 !data.ReadParseBlockedOnScriptExecutionFromDocumentWriteDuration(
54 &out->parse_blocked_on_script_execution_from_document_write_duration)) {
55 return false;
56 }
57 return true;
58 }
59
60 // static
61 bool StructTraits<page_load_metrics::mojom::StyleSheetTimingDataView,
62 page_load_metrics::StyleSheetTiming>::
63 Read(page_load_metrics::mojom::StyleSheetTimingDataView data,
64 page_load_metrics::StyleSheetTiming* out) {
65 if (!data.ReadAuthorStyleSheetParseDurationBeforeFcp(
66 &out->author_style_sheet_parse_duration_before_fcp) ||
67 !data.ReadUpdateStyleDurationBeforeFcp(
68 &out->update_style_duration_before_fcp)) {
69 return false;
70 }
71 return true;
72 }
73
74 bool StructTraits<page_load_metrics::mojom::PageLoadTimingDataView,
75 page_load_metrics::PageLoadTiming>::
76 Read(page_load_metrics::mojom::PageLoadTimingDataView data,
77 page_load_metrics::PageLoadTiming* out) {
78 if (!data.ReadNavigationStart(&out->navigation_start) ||
79 !data.ReadResponseStart(&out->response_start)) {
80 return false;
81 }
82
83 if (!data.ReadDocumentTiming(&out->document_timing)) {
84 return false;
85 }
86
87 if (!data.ReadPaintTiming(&out->paint_timing)) {
88 return false;
89 }
90
91 if (!data.ReadParseTiming(&out->parse_timing)) {
92 return false;
93 }
94
95 if (!data.ReadStyleSheetTiming(&out->style_sheet_timing)) {
96 return false;
97 }
98
99 return true;
100 }
101
102 bool StructTraits<page_load_metrics::mojom::PageLoadMetadataDataView,
103 page_load_metrics::PageLoadMetadata>::
104 Read(page_load_metrics::mojom::PageLoadMetadataDataView data,
105 page_load_metrics::PageLoadMetadata* out) {
106 out->behavior_flags = data.behavior_flags();
107 return true;
108 }
109
110 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698