summaryrefslogtreecommitdiff
path: root/chromium/components/page_load_metrics/common/page_load_timing.h
blob: a61551d4a402d20a48b138a6b65bbef78dcc2da7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2015 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 COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_
#define COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_

#include "base/time/time.h"
#include "third_party/WebKit/public/platform/WebLoadingBehaviorFlag.h"

namespace page_load_metrics {

// PageLoadTiming contains timing metrics associated with a page load. Many of
// the metrics here are based on the Navigation Timing spec:
// http://www.w3.org/TR/navigation-timing/.
struct PageLoadTiming {
 public:
  PageLoadTiming();
  PageLoadTiming(const PageLoadTiming& other);
  ~PageLoadTiming();

  bool operator==(const PageLoadTiming& other) const;

  bool IsEmpty() const;

  // Time that the navigation for the associated page was initiated.
  base::Time navigation_start;

  // All TimeDeltas are relative to navigation_start

  // TODO(shivanisha): Issue 596367 shows that it is possible for a valid
  // TimeDelta value to be 0 (2 TimeTicks can have the same value even if they
  // were assigned in separate instructions if the clock speed is less
  // granular). The solution there was to use base::Optional for those values.
  // Consider changing the below values to Optional as well.

  // Time that the first byte of the response is received.
  base::TimeDelta response_start;

  // Time that the document transitions to the 'loading' state. This is roughly
  // the time that the HTML parser begins parsing the main HTML resource.
  base::TimeDelta dom_loading;

  // Time immediately before the DOMContentLoaded event is fired.
  base::TimeDelta dom_content_loaded_event_start;

  // Time immediately before the load event is fired.
  base::TimeDelta load_event_start;

  // Time when the first layout is completed.
  base::TimeDelta first_layout;

  // Time when the first paint is performed.
  base::TimeDelta first_paint;
  // Time when the first non-blank text is painted.
  base::TimeDelta first_text_paint;
  // Time when the first image is painted.
  base::TimeDelta first_image_paint;
  // Time when the first contentful thing (image, text, etc.) is painted.
  base::TimeDelta first_contentful_paint;

  // Time that the document's parser started and stopped parsing main resource
  // content.
  base::TimeDelta parse_start;
  base::TimeDelta parse_stop;

  // Sum of times when the parser is blocked waiting on the load of a script.
  // This duration takes place between parser_start and parser_stop, and thus
  // must be less than or equal to parser_stop - parser_start.
  base::TimeDelta parse_blocked_on_script_load_duration;

  // Sum of times when the parser is blocked waiting on the load of a script
  // that was inserted from document.write. This duration must be less than or
  // equal to parse_blocked_on_script_load_duration. Note that some uncommon
  // cases where scripts are loaded via document.write are not currently covered
  // by this field. See crbug/600711 for details.
  base::TimeDelta parse_blocked_on_script_load_from_document_write_duration;

  // If you add additional members, also be sure to update operator==,
  // page_load_metrics_messages.h, and IsEmpty().
};

struct PageLoadMetadata {
  PageLoadMetadata();
  bool operator==(const PageLoadMetadata& other) const;
  // These are packed blink::WebLoadingBehaviorFlag enums.
  int behavior_flags = blink::WebLoadingBehaviorNone;
};

}  // namespace page_load_metrics

#endif  // COMPONENTS_PAGE_LOAD_METRICS_COMMON_PAGE_LOAD_TIMING_H_