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

Side by Side Diff: components/page_load_metrics/common/page_load_timing.h

Issue 2111073003: Update PageLoadTiming to use base::Optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@optionalbug
Patch Set: remove comment Created 4 years, 5 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 #ifndef COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_ 5 #ifndef COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_
6 #define COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_ 6 #define COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_
7 7
8 #include "base/optional.h"
8 #include "base/time/time.h" 9 #include "base/time/time.h"
9 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h" 10 #include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h"
10 11
11 namespace page_load_metrics { 12 namespace page_load_metrics {
12 13
13 // PageLoadTiming contains timing metrics associated with a page load. Many of 14 // PageLoadTiming contains timing metrics associated with a page load. Many of
14 // the metrics here are based on the Navigation Timing spec: 15 // the metrics here are based on the Navigation Timing spec:
15 // http://www.w3.org/TR/navigation-timing/. 16 // http://www.w3.org/TR/navigation-timing/.
16 struct PageLoadTiming { 17 struct PageLoadTiming {
17 public: 18 public:
18 PageLoadTiming(); 19 PageLoadTiming();
19 PageLoadTiming(const PageLoadTiming& other); 20 PageLoadTiming(const PageLoadTiming& other);
20 ~PageLoadTiming(); 21 ~PageLoadTiming();
21 22
22 bool operator==(const PageLoadTiming& other) const; 23 bool operator==(const PageLoadTiming& other) const;
23 24
24 bool IsEmpty() const; 25 bool IsEmpty() const;
25 26
26 // Time that the navigation for the associated page was initiated. 27 // Time that the navigation for the associated page was initiated.
27 base::Time navigation_start; 28 base::Time navigation_start;
28 29
29 // All TimeDeltas are relative to navigation_start 30 // All TimeDeltas are relative to navigation_start
30 31
31 // TODO(shivanisha): Issue 596367 shows that it is possible for a valid
32 // TimeDelta value to be 0 (2 TimeTicks can have the same value even if they
33 // were assigned in separate instructions if the clock speed is less
34 // granular). The solution there was to use base::Optional for those values.
35 // Consider changing the below values to Optional as well.
36
37 // Time that the first byte of the response is received. 32 // Time that the first byte of the response is received.
38 base::TimeDelta response_start; 33 base::Optional<base::TimeDelta> response_start;
39 34
40 // Time that the document transitions to the 'loading' state. This is roughly 35 // Time that the document transitions to the 'loading' state. This is roughly
41 // the time that the HTML parser begins parsing the main HTML resource. 36 // the time that the HTML parser begins parsing the main HTML resource.
42 base::TimeDelta dom_loading; 37 base::Optional<base::TimeDelta> dom_loading;
43 38
44 // Time immediately before the DOMContentLoaded event is fired. 39 // Time immediately before the DOMContentLoaded event is fired.
45 base::TimeDelta dom_content_loaded_event_start; 40 base::Optional<base::TimeDelta> dom_content_loaded_event_start;
46 41
47 // Time immediately before the load event is fired. 42 // Time immediately before the load event is fired.
48 base::TimeDelta load_event_start; 43 base::Optional<base::TimeDelta> load_event_start;
49 44
50 // Time when the first layout is completed. 45 // Time when the first layout is completed.
51 base::TimeDelta first_layout; 46 base::Optional<base::TimeDelta> first_layout;
52 47
53 // Time when the first paint is performed. 48 // Time when the first paint is performed.
54 base::TimeDelta first_paint; 49 base::Optional<base::TimeDelta> first_paint;
55 // Time when the first non-blank text is painted. 50 // Time when the first non-blank text is painted.
56 base::TimeDelta first_text_paint; 51 base::Optional<base::TimeDelta> first_text_paint;
57 // Time when the first image is painted. 52 // Time when the first image is painted.
58 base::TimeDelta first_image_paint; 53 base::Optional<base::TimeDelta> first_image_paint;
59 // Time when the first contentful thing (image, text, etc.) is painted. 54 // Time when the first contentful thing (image, text, etc.) is painted.
60 base::TimeDelta first_contentful_paint; 55 base::Optional<base::TimeDelta> first_contentful_paint;
61 56
62 // Time that the document's parser started and stopped parsing main resource 57 // Time that the document's parser started and stopped parsing main resource
63 // content. 58 // content.
64 base::TimeDelta parse_start; 59 base::Optional<base::TimeDelta> parse_start;
65 base::TimeDelta parse_stop; 60 base::Optional<base::TimeDelta> parse_stop;
66 61
67 // Sum of times when the parser is blocked waiting on the load of a script. 62 // Sum of times when the parser is blocked waiting on the load of a script.
68 // This duration takes place between parser_start and parser_stop, and thus 63 // This duration takes place between parser_start and parser_stop, and thus
69 // must be less than or equal to parser_stop - parser_start. 64 // must be less than or equal to parser_stop - parser_start. Note that this
70 base::TimeDelta parse_blocked_on_script_load_duration; 65 // value may be updated multiple times during the period between parse_start
66 // and parse_stop.
67 base::Optional<base::TimeDelta> parse_blocked_on_script_load_duration;
71 68
72 // Sum of times when the parser is blocked waiting on the load of a script 69 // Sum of times when the parser is blocked waiting on the load of a script
73 // that was inserted from document.write. This duration must be less than or 70 // that was inserted from document.write. This duration must be less than or
74 // equal to parse_blocked_on_script_load_duration. Note that some uncommon 71 // equal to parse_blocked_on_script_load_duration. Note that this value may be
75 // cases where scripts are loaded via document.write are not currently covered 72 // updated multiple times during the period between parse_start and
76 // by this field. See crbug/600711 for details. 73 // parse_stop. Note that some uncommon cases where scripts are loaded via
77 base::TimeDelta parse_blocked_on_script_load_from_document_write_duration; 74 // document.write are not currently covered by this field. See crbug/600711
75 // for details.
76 base::Optional<base::TimeDelta>
77 parse_blocked_on_script_load_from_document_write_duration;
78 78
79 // If you add additional members, also be sure to update operator==, 79 // If you add additional members, also be sure to update operator==,
80 // page_load_metrics_messages.h, and IsEmpty(). 80 // page_load_metrics_messages.h, and IsEmpty().
81 }; 81 };
82 82
83 struct PageLoadMetadata { 83 struct PageLoadMetadata {
84 PageLoadMetadata(); 84 PageLoadMetadata();
85 bool operator==(const PageLoadMetadata& other) const; 85 bool operator==(const PageLoadMetadata& other) const;
86 // These are packed blink::WebLoadingBehaviorFlag enums. 86 // These are packed blink::WebLoadingBehaviorFlag enums.
87 int behavior_flags = blink::WebLoadingBehaviorNone; 87 int behavior_flags = blink::WebLoadingBehaviorNone;
88 }; 88 };
89 89
90 } // namespace page_load_metrics 90 } // namespace page_load_metrics
91 91
92 #endif // COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_ 92 #endif // COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698