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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/page_load_metrics/page_load_metrics_struct_traits.h
diff --git a/chrome/common/page_load_metrics/page_load_metrics_struct_traits.h b/chrome/common/page_load_metrics/page_load_metrics_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..48f431353e7307f9eaaabbaf76a041d5e789d660
--- /dev/null
+++ b/chrome/common/page_load_metrics/page_load_metrics_struct_traits.h
@@ -0,0 +1,181 @@
+// 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.
+
+#ifndef CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_STRUCT_TRAITS_H_
+#define CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_STRUCT_TRAITS_H_
+
+#include "base/time/time.h"
+#include "chrome/common/page_load_metrics/page_load_metrics.mojom.h"
+#include "chrome/common/page_load_metrics/page_load_timing.h"
+#include "mojo/common/common_custom_types_struct_traits.h"
+#include "mojo/public/cpp/bindings/struct_traits.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<page_load_metrics::mojom::DocumentTimingDataView,
+ page_load_metrics::DocumentTiming> {
+ static base::Optional<base::TimeDelta> dom_content_loaded_event_start(
+ const page_load_metrics::DocumentTiming& document_timing) {
+ return document_timing.dom_content_loaded_event_start;
+ }
+
+ static base::Optional<base::TimeDelta> load_event_start(
+ const page_load_metrics::DocumentTiming& document_timing) {
+ return document_timing.load_event_start;
+ }
+
+ static base::Optional<base::TimeDelta> first_layout(
+ const page_load_metrics::DocumentTiming& document_timing) {
+ return document_timing.first_layout;
+ }
+
+ static bool Read(page_load_metrics::mojom::DocumentTimingDataView data,
+ page_load_metrics::DocumentTiming* out);
+};
+
+template <>
+struct StructTraits<page_load_metrics::mojom::PaintTimingDataView,
+ page_load_metrics::PaintTiming> {
+ static base::Optional<base::TimeDelta> first_paint(
+ const page_load_metrics::PaintTiming& paint_timing) {
+ return paint_timing.first_paint;
+ }
+
+ static base::Optional<base::TimeDelta> first_text_paint(
+ const page_load_metrics::PaintTiming& paint_timing) {
+ return paint_timing.first_text_paint;
+ }
+
+ static base::Optional<base::TimeDelta> first_image_paint(
+ const page_load_metrics::PaintTiming& paint_timing) {
+ return paint_timing.first_image_paint;
+ }
+
+ static base::Optional<base::TimeDelta> first_contentful_paint(
+ const page_load_metrics::PaintTiming& paint_timing) {
+ return paint_timing.first_contentful_paint;
+ }
+
+ static base::Optional<base::TimeDelta> first_meaningful_paint(
+ const page_load_metrics::PaintTiming& paint_timing) {
+ return paint_timing.first_meaningful_paint;
+ }
+
+ static bool Read(page_load_metrics::mojom::PaintTimingDataView data,
+ page_load_metrics::PaintTiming* out);
+};
+
+template <>
+struct StructTraits<page_load_metrics::mojom::ParseTimingDataView,
+ page_load_metrics::ParseTiming> {
+ static base::Optional<base::TimeDelta> parse_start(
+ const page_load_metrics::ParseTiming& parse_timing) {
+ return parse_timing.parse_start;
+ }
+
+ static base::Optional<base::TimeDelta> parse_stop(
+ const page_load_metrics::ParseTiming& parse_timing) {
+ return parse_timing.parse_stop;
+ }
+
+ static base::Optional<base::TimeDelta> parse_blocked_on_script_load_duration(
+ const page_load_metrics::ParseTiming& parse_timing) {
+ return parse_timing.parse_blocked_on_script_load_duration;
+ }
+
+ static base::Optional<base::TimeDelta>
+ parse_blocked_on_script_load_from_document_write_duration(
+ const page_load_metrics::ParseTiming& parse_timing) {
+ return parse_timing
+ .parse_blocked_on_script_load_from_document_write_duration;
+ }
+
+ static base::Optional<base::TimeDelta>
+ parse_blocked_on_script_execution_duration(
+ const page_load_metrics::ParseTiming& parse_timing) {
+ return parse_timing.parse_blocked_on_script_execution_duration;
+ }
+
+ static base::Optional<base::TimeDelta>
+ parse_blocked_on_script_execution_from_document_write_duration(
+ const page_load_metrics::ParseTiming& parse_timing) {
+ return parse_timing
+ .parse_blocked_on_script_execution_from_document_write_duration;
+ }
+
+ static bool Read(page_load_metrics::mojom::ParseTimingDataView data,
+ page_load_metrics::ParseTiming* out);
+};
+
+template <>
+struct StructTraits<page_load_metrics::mojom::StyleSheetTimingDataView,
+ page_load_metrics::StyleSheetTiming> {
+ static base::Optional<base::TimeDelta>
+ author_style_sheet_parse_duration_before_fcp(
+ const page_load_metrics::StyleSheetTiming& style_sheet_timing) {
+ return style_sheet_timing.author_style_sheet_parse_duration_before_fcp;
+ }
+
+ static base::Optional<base::TimeDelta> update_style_duration_before_fcp(
+ const page_load_metrics::StyleSheetTiming& style_sheet_timing) {
+ return style_sheet_timing.update_style_duration_before_fcp;
+ }
+
+ static bool Read(page_load_metrics::mojom::StyleSheetTimingDataView data,
+ page_load_metrics::StyleSheetTiming* out);
+};
+
+template <>
+struct StructTraits<page_load_metrics::mojom::PageLoadTimingDataView,
+ page_load_metrics::PageLoadTiming> {
+ static base::Time navigation_start(
+ const page_load_metrics::PageLoadTiming& page_load_timing) {
+ return page_load_timing.navigation_start;
+ }
+
+ static base::Optional<base::TimeDelta> response_start(
+ const page_load_metrics::PageLoadTiming& page_load_timing) {
+ return page_load_timing.response_start;
+ }
+
+ static page_load_metrics::DocumentTiming document_timing(
+ const page_load_metrics::PageLoadTiming& page_load_timing) {
+ return page_load_timing.document_timing;
+ }
+
+ static page_load_metrics::PaintTiming paint_timing(
+ const page_load_metrics::PageLoadTiming& page_load_timing) {
+ return page_load_timing.paint_timing;
+ }
+
+ static page_load_metrics::ParseTiming parse_timing(
+ const page_load_metrics::PageLoadTiming& page_load_timing) {
+ return page_load_timing.parse_timing;
+ }
+
+ static page_load_metrics::StyleSheetTiming style_sheet_timing(
+ const page_load_metrics::PageLoadTiming& page_load_timing) {
+ return page_load_timing.style_sheet_timing;
+ }
+
+ static bool Read(page_load_metrics::mojom::PageLoadTimingDataView data,
+ page_load_metrics::PageLoadTiming* out);
+};
+
+template <>
+struct StructTraits<page_load_metrics::mojom::PageLoadMetadataDataView,
+ page_load_metrics::PageLoadMetadata> {
+ static int behavior_flags(
+ const page_load_metrics::PageLoadMetadata& page_load_metadata) {
+ return page_load_metadata.behavior_flags;
+ }
+
+ static bool Read(page_load_metrics::mojom::PageLoadMetadataDataView data,
+ page_load_metrics::PageLoadMetadata* out);
+};
+
+} // namespace mojo
+
+#endif // CHROME_COMMON_PAGE_LOAD_METRICS_PAGE_LOAD_METRICS_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698