Index: chrome/common/page_load_metrics/page_load_metrics_struct_traits.cc |
diff --git a/chrome/common/page_load_metrics/page_load_metrics_struct_traits.cc b/chrome/common/page_load_metrics/page_load_metrics_struct_traits.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c3126de96ba2c0631d36449d356ec1b304a7217a |
--- /dev/null |
+++ b/chrome/common/page_load_metrics/page_load_metrics_struct_traits.cc |
@@ -0,0 +1,110 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/common/page_load_metrics/page_load_metrics_struct_traits.h" |
+ |
+#include "ipc/ipc_message_utils.h" |
+ |
+namespace mojo { |
+ |
+// static |
+bool StructTraits<page_load_metrics::mojom::DocumentTimingDataView, |
+ page_load_metrics::DocumentTiming>:: |
+ Read(page_load_metrics::mojom::DocumentTimingDataView data, |
+ page_load_metrics::DocumentTiming* out) { |
+ if (!data.ReadDomContentLoadedEventStart( |
+ &out->dom_content_loaded_event_start) || |
+ !data.ReadLoadEventStart(&out->load_event_start) || |
+ !data.ReadFirstLayout(&out->first_layout)) { |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+// static |
+bool StructTraits<page_load_metrics::mojom::PaintTimingDataView, |
+ page_load_metrics::PaintTiming>:: |
+ Read(page_load_metrics::mojom::PaintTimingDataView data, |
+ page_load_metrics::PaintTiming* out) { |
+ if (!data.ReadFirstPaint(&out->first_paint) || |
+ !data.ReadFirstTextPaint(&out->first_text_paint) || |
+ !data.ReadFirstImagePaint(&out->first_image_paint) || |
+ !data.ReadFirstContentfulPaint(&out->first_contentful_paint) || |
+ !data.ReadFirstMeaningfulPaint(&out->first_meaningful_paint)) { |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+// static |
+bool StructTraits<page_load_metrics::mojom::ParseTimingDataView, |
+ page_load_metrics::ParseTiming>:: |
+ Read(page_load_metrics::mojom::ParseTimingDataView data, |
+ page_load_metrics::ParseTiming* out) { |
+ if (!data.ReadParseStart(&out->parse_start) || |
+ !data.ReadParseStop(&out->parse_stop) || |
+ !data.ReadParseBlockedOnScriptLoadDuration( |
+ &out->parse_blocked_on_script_load_duration) || |
+ !data.ReadParseBlockedOnScriptLoadFromDocumentWriteDuration( |
+ &out->parse_blocked_on_script_load_from_document_write_duration) || |
+ !data.ReadParseBlockedOnScriptExecutionDuration( |
+ &out->parse_blocked_on_script_execution_duration) || |
+ !data.ReadParseBlockedOnScriptExecutionFromDocumentWriteDuration( |
+ &out->parse_blocked_on_script_execution_from_document_write_duration)) { |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+// static |
+bool StructTraits<page_load_metrics::mojom::StyleSheetTimingDataView, |
+ page_load_metrics::StyleSheetTiming>:: |
+ Read(page_load_metrics::mojom::StyleSheetTimingDataView data, |
+ page_load_metrics::StyleSheetTiming* out) { |
+ if (!data.ReadAuthorStyleSheetParseDurationBeforeFcp( |
+ &out->author_style_sheet_parse_duration_before_fcp) || |
+ !data.ReadUpdateStyleDurationBeforeFcp( |
+ &out->update_style_duration_before_fcp)) { |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+bool StructTraits<page_load_metrics::mojom::PageLoadTimingDataView, |
+ page_load_metrics::PageLoadTiming>:: |
+ Read(page_load_metrics::mojom::PageLoadTimingDataView data, |
+ page_load_metrics::PageLoadTiming* out) { |
+ if (!data.ReadNavigationStart(&out->navigation_start) || |
+ !data.ReadResponseStart(&out->response_start)) { |
+ return false; |
+ } |
+ |
+ if (!data.ReadDocumentTiming(&out->document_timing)) { |
+ return false; |
+ } |
+ |
+ if (!data.ReadPaintTiming(&out->paint_timing)) { |
+ return false; |
+ } |
+ |
+ if (!data.ReadParseTiming(&out->parse_timing)) { |
+ return false; |
+ } |
+ |
+ if (!data.ReadStyleSheetTiming(&out->style_sheet_timing)) { |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
+bool StructTraits<page_load_metrics::mojom::PageLoadMetadataDataView, |
+ page_load_metrics::PageLoadMetadata>:: |
+ Read(page_load_metrics::mojom::PageLoadMetadataDataView data, |
+ page_load_metrics::PageLoadMetadata* out) { |
+ out->behavior_flags = data.behavior_flags(); |
+ return true; |
+} |
+ |
+} // namespace mojo |