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

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

Issue 2874663005: [Page Load Metrics] Add mojom file to page load metrics. (Closed)
Patch Set: rebase 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 #include "chrome/common/page_load_metrics/page_load_timing.h" 5 #include "chrome/common/page_load_metrics/page_load_timing.h"
6 6
7 namespace page_load_metrics { 7 namespace page_load_metrics {
8 8
9 DocumentTiming::DocumentTiming() {} 9 mojo::StructPtr<mojom::PageLoadTiming> CreatePageLoadTiming() {
10 10 return mojom::PageLoadTiming::New(
11 DocumentTiming::DocumentTiming(const DocumentTiming& other) = default; 11 base::Time(), base::Optional<base::TimeDelta>(),
12 12 mojom::DocumentTiming::New(), mojom::PaintTiming::New(),
13 DocumentTiming::~DocumentTiming() {} 13 mojom::ParseTiming::New(), mojom::StyleSheetTiming::New());
14
15 bool DocumentTiming::operator==(const DocumentTiming& other) const {
16 return dom_content_loaded_event_start ==
17 other.dom_content_loaded_event_start &&
18 load_event_start == other.load_event_start &&
19 first_layout == other.first_layout;
20 } 14 }
21 15
22 bool DocumentTiming::IsEmpty() const { 16 bool IsEmpty(const page_load_metrics::mojom::DocumentTiming& timing) {
23 return !dom_content_loaded_event_start && !load_event_start && !first_layout; 17 return !timing.dom_content_loaded_event_start && !timing.load_event_start &&
18 !timing.first_layout;
24 } 19 }
25 20
26 PaintTiming::PaintTiming() {} 21 bool IsEmpty(const page_load_metrics::mojom::PaintTiming& timing) {
27 22 return !timing.first_paint && !timing.first_text_paint &&
28 PaintTiming::PaintTiming(const PaintTiming& other) = default; 23 !timing.first_image_paint && !timing.first_contentful_paint &&
29 24 !timing.first_meaningful_paint;
30 PaintTiming::~PaintTiming() {}
31
32 bool PaintTiming::operator==(const PaintTiming& other) const {
33 return first_paint == other.first_paint &&
34 first_text_paint == other.first_text_paint &&
35 first_image_paint == other.first_image_paint &&
36 first_contentful_paint == other.first_contentful_paint &&
37 first_meaningful_paint == other.first_meaningful_paint;
38 } 25 }
39 26
40 bool PaintTiming::IsEmpty() const { 27 bool IsEmpty(const page_load_metrics::mojom::ParseTiming& timing) {
41 return !first_paint && !first_text_paint && !first_image_paint && 28 return !timing.parse_start && !timing.parse_stop &&
42 !first_contentful_paint && !first_meaningful_paint; 29 !timing.parse_blocked_on_script_load_duration &&
30 !timing.parse_blocked_on_script_load_from_document_write_duration &&
31 !timing.parse_blocked_on_script_execution_duration &&
32 !timing.parse_blocked_on_script_execution_from_document_write_duration;
43 } 33 }
44 34
45 ParseTiming::ParseTiming() {} 35 bool IsEmpty(const page_load_metrics::mojom::StyleSheetTiming& timing) {
46 36 return !timing.author_style_sheet_parse_duration_before_fcp &&
47 ParseTiming::ParseTiming(const ParseTiming& other) = default; 37 !timing.update_style_duration_before_fcp;
48
49 ParseTiming::~ParseTiming() {}
50
51 bool ParseTiming::operator==(const ParseTiming& other) const {
52 return parse_start == other.parse_start && parse_stop == other.parse_stop &&
53 parse_blocked_on_script_load_duration ==
54 other.parse_blocked_on_script_load_duration &&
55 parse_blocked_on_script_load_from_document_write_duration ==
56 other.parse_blocked_on_script_load_from_document_write_duration &&
57 parse_blocked_on_script_execution_duration ==
58 other.parse_blocked_on_script_execution_duration &&
59 parse_blocked_on_script_execution_from_document_write_duration ==
60 other
61 .parse_blocked_on_script_execution_from_document_write_duration ;
62 } 38 }
63 39
64 bool ParseTiming::IsEmpty() const { 40 bool IsEmpty(const page_load_metrics::mojom::PageLoadTiming& timing) {
65 return !parse_start && !parse_stop && 41 return timing.navigation_start.is_null() && !timing.response_start &&
66 !parse_blocked_on_script_load_duration && 42 (!timing.document_timing ||
67 !parse_blocked_on_script_load_from_document_write_duration && 43 page_load_metrics::IsEmpty(*timing.document_timing)) &&
68 !parse_blocked_on_script_execution_duration && 44 (!timing.paint_timing ||
69 !parse_blocked_on_script_execution_from_document_write_duration; 45 page_load_metrics::IsEmpty(*timing.paint_timing)) &&
46 (!timing.parse_timing ||
47 page_load_metrics::IsEmpty(*timing.parse_timing)) &&
48 (!timing.style_sheet_timing ||
49 page_load_metrics::IsEmpty(*timing.style_sheet_timing));
70 } 50 }
71 51
72 StyleSheetTiming::StyleSheetTiming() {} 52 void InitPageLoadTimingForTest(mojom::PageLoadTiming* timing) {
pasko 2017/05/15 17:23:04 Not opposing this change, rather asking for self-e
Ken Rockot(use gerrit already) 2017/05/15 17:38:23 Fields are default-constructed, but these fields a
73 53 timing->document_timing = mojom::DocumentTiming::New();
74 StyleSheetTiming::StyleSheetTiming(const StyleSheetTiming& other) = default; 54 timing->paint_timing = mojom::PaintTiming::New();
75 55 timing->parse_timing = mojom::ParseTiming::New();
76 StyleSheetTiming::~StyleSheetTiming() {} 56 timing->style_sheet_timing = mojom::StyleSheetTiming::New();
77
78 bool StyleSheetTiming::operator==(const StyleSheetTiming& other) const {
79 return author_style_sheet_parse_duration_before_fcp ==
80 other.author_style_sheet_parse_duration_before_fcp &&
81 update_style_duration_before_fcp ==
82 other.update_style_duration_before_fcp;
83 }
84
85 bool StyleSheetTiming::IsEmpty() const {
86 return !author_style_sheet_parse_duration_before_fcp &&
87 !update_style_duration_before_fcp;
88 }
89
90 PageLoadTiming::PageLoadTiming() {}
91
92 PageLoadTiming::PageLoadTiming(const PageLoadTiming& other) = default;
93
94 PageLoadTiming::~PageLoadTiming() {}
95
96 bool PageLoadTiming::operator==(const PageLoadTiming& other) const {
97 return navigation_start == other.navigation_start &&
98 response_start == other.response_start &&
99 document_timing == other.document_timing &&
100 paint_timing == other.paint_timing &&
101 parse_timing == other.parse_timing &&
102 style_sheet_timing == other.style_sheet_timing;
103 }
104
105 bool PageLoadTiming::IsEmpty() const {
106 return navigation_start.is_null() && !response_start &&
107 document_timing.IsEmpty() && paint_timing.IsEmpty() &&
108 parse_timing.IsEmpty() && style_sheet_timing.IsEmpty();
109 }
110
111 PageLoadMetadata::PageLoadMetadata() {}
112
113 bool PageLoadMetadata::operator==(const PageLoadMetadata& other) const {
114 return behavior_flags == other.behavior_flags;
115 } 57 }
116 58
117 } // namespace page_load_metrics 59 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698