/work/obj-fuzz/dist/include/nsDOMNavigationTiming.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef nsDOMNavigationTiming_h___ |
8 | | #define nsDOMNavigationTiming_h___ |
9 | | |
10 | | #include "nsCOMPtr.h" |
11 | | #include "nsCOMArray.h" |
12 | | #include "mozilla/WeakPtr.h" |
13 | | #include "mozilla/RelativeTimeline.h" |
14 | | #include "mozilla/TimeStamp.h" |
15 | | |
16 | | class nsDocShell; |
17 | | class nsIURI; |
18 | | |
19 | | typedef unsigned long long DOMTimeMilliSec; |
20 | | typedef double DOMHighResTimeStamp; |
21 | | |
22 | | class nsDOMNavigationTiming final |
23 | | : public mozilla::RelativeTimeline |
24 | | { |
25 | | public: |
26 | | enum Type { |
27 | | TYPE_NAVIGATE = 0, |
28 | | TYPE_RELOAD = 1, |
29 | | TYPE_BACK_FORWARD = 2, |
30 | | TYPE_RESERVED = 255, |
31 | | }; |
32 | | |
33 | | explicit nsDOMNavigationTiming(nsDocShell* aDocShell); |
34 | | |
35 | | NS_INLINE_DECL_REFCOUNTING(nsDOMNavigationTiming) |
36 | | |
37 | | Type GetType() const |
38 | | { |
39 | | return mNavigationType; |
40 | | } |
41 | | |
42 | | inline DOMHighResTimeStamp GetNavigationStartHighRes() const |
43 | | { |
44 | | return mNavigationStartHighRes; |
45 | | } |
46 | | |
47 | | DOMTimeMilliSec GetNavigationStart() const |
48 | | { |
49 | | return static_cast<int64_t>(GetNavigationStartHighRes()); |
50 | | } |
51 | | |
52 | | mozilla::TimeStamp GetNavigationStartTimeStamp() const |
53 | | { |
54 | | return mNavigationStart; |
55 | | } |
56 | | |
57 | | DOMTimeMilliSec GetUnloadEventStart() |
58 | | { |
59 | | return TimeStampToDOM(GetUnloadEventStartTimeStamp()); |
60 | | } |
61 | | |
62 | | DOMTimeMilliSec GetUnloadEventEnd() |
63 | | { |
64 | | return TimeStampToDOM(GetUnloadEventEndTimeStamp()); |
65 | | } |
66 | | |
67 | | DOMTimeMilliSec GetDomLoading() const |
68 | | { |
69 | | return TimeStampToDOM(mDOMLoading); |
70 | | } |
71 | | DOMTimeMilliSec GetDomInteractive() const |
72 | | { |
73 | | return TimeStampToDOM(mDOMInteractive); |
74 | | } |
75 | | DOMTimeMilliSec GetDomContentLoadedEventStart() const |
76 | | { |
77 | | return TimeStampToDOM(mDOMContentLoadedEventStart); |
78 | | } |
79 | | DOMTimeMilliSec GetDomContentLoadedEventEnd() const |
80 | | { |
81 | | return TimeStampToDOM(mDOMContentLoadedEventEnd); |
82 | | } |
83 | | DOMTimeMilliSec GetDomComplete() const |
84 | | { |
85 | | return TimeStampToDOM(mDOMComplete); |
86 | | } |
87 | | DOMTimeMilliSec GetLoadEventStart() const |
88 | | { |
89 | | return TimeStampToDOM(mLoadEventStart); |
90 | | } |
91 | | DOMTimeMilliSec GetLoadEventEnd() const |
92 | | { |
93 | | return TimeStampToDOM(mLoadEventEnd); |
94 | | } |
95 | | DOMTimeMilliSec GetTimeToNonBlankPaint() const |
96 | | { |
97 | | return TimeStampToDOM(mNonBlankPaint); |
98 | | } |
99 | | DOMTimeMilliSec GetTimeToDOMContentFlushed() const |
100 | | { |
101 | | return TimeStampToDOM(mDOMContentFlushed); |
102 | | } |
103 | | |
104 | | DOMHighResTimeStamp GetUnloadEventStartHighRes() |
105 | 0 | { |
106 | 0 | mozilla::TimeStamp stamp = GetUnloadEventStartTimeStamp(); |
107 | 0 | if (stamp.IsNull()) { |
108 | 0 | return 0; |
109 | 0 | } |
110 | 0 | return TimeStampToDOMHighRes(stamp); |
111 | 0 | } |
112 | | DOMHighResTimeStamp GetUnloadEventEndHighRes() |
113 | 0 | { |
114 | 0 | mozilla::TimeStamp stamp = GetUnloadEventEndTimeStamp(); |
115 | 0 | if (stamp.IsNull()) { |
116 | 0 | return 0; |
117 | 0 | } |
118 | 0 | return TimeStampToDOMHighRes(stamp); |
119 | 0 | } |
120 | | DOMHighResTimeStamp GetDomInteractiveHighRes() const |
121 | 0 | { |
122 | 0 | return TimeStampToDOMHighRes(mDOMInteractive); |
123 | 0 | } |
124 | | DOMHighResTimeStamp GetDomContentLoadedEventStartHighRes() const |
125 | 0 | { |
126 | 0 | return TimeStampToDOMHighRes(mDOMContentLoadedEventStart); |
127 | 0 | } |
128 | | DOMHighResTimeStamp GetDomContentLoadedEventEndHighRes() const |
129 | 0 | { |
130 | 0 | return TimeStampToDOMHighRes(mDOMContentLoadedEventEnd); |
131 | 0 | } |
132 | | DOMHighResTimeStamp GetDomCompleteHighRes() const |
133 | 0 | { |
134 | 0 | return TimeStampToDOMHighRes(mDOMComplete); |
135 | 0 | } |
136 | | DOMHighResTimeStamp GetLoadEventStartHighRes() const |
137 | 0 | { |
138 | 0 | return TimeStampToDOMHighRes(mLoadEventStart); |
139 | 0 | } |
140 | | DOMHighResTimeStamp GetLoadEventEndHighRes() const |
141 | 0 | { |
142 | 0 | return TimeStampToDOMHighRes(mLoadEventEnd); |
143 | 0 | } |
144 | | |
145 | | enum class DocShellState : uint8_t { |
146 | | eActive, |
147 | | eInactive |
148 | | }; |
149 | | |
150 | | void NotifyNavigationStart(DocShellState aDocShellState); |
151 | | void NotifyFetchStart(nsIURI* aURI, Type aNavigationType); |
152 | | void NotifyBeforeUnload(); |
153 | | void NotifyUnloadAccepted(nsIURI* aOldURI); |
154 | | void NotifyUnloadEventStart(); |
155 | | void NotifyUnloadEventEnd(); |
156 | | void NotifyLoadEventStart(); |
157 | | void NotifyLoadEventEnd(); |
158 | | |
159 | | // Document changes state to 'loading' before connecting to timing |
160 | | void SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue); |
161 | | void NotifyDOMLoading(nsIURI* aURI); |
162 | | void NotifyDOMInteractive(nsIURI* aURI); |
163 | | void NotifyDOMComplete(nsIURI* aURI); |
164 | | void NotifyDOMContentLoadedStart(nsIURI* aURI); |
165 | | void NotifyDOMContentLoadedEnd(nsIURI* aURI); |
166 | | |
167 | | void NotifyNonBlankPaintForRootContentDocument(); |
168 | | void NotifyDOMContentFlushedForRootContentDocument(); |
169 | | void NotifyDocShellStateChanged(DocShellState aDocShellState); |
170 | | |
171 | | DOMTimeMilliSec TimeStampToDOM(mozilla::TimeStamp aStamp) const; |
172 | | |
173 | | inline DOMHighResTimeStamp TimeStampToDOMHighRes(mozilla::TimeStamp aStamp) const |
174 | | { |
175 | | if (aStamp.IsNull()) { |
176 | | return 0; |
177 | | } |
178 | | mozilla::TimeDuration duration = aStamp - mNavigationStart; |
179 | | return duration.ToMilliseconds(); |
180 | | } |
181 | | |
182 | | private: |
183 | | nsDOMNavigationTiming(const nsDOMNavigationTiming &) = delete; |
184 | | ~nsDOMNavigationTiming(); |
185 | | |
186 | | void Clear(); |
187 | | |
188 | | mozilla::TimeStamp GetUnloadEventStartTimeStamp() const; |
189 | | mozilla::TimeStamp GetUnloadEventEndTimeStamp() const; |
190 | | |
191 | | bool IsTopLevelContentDocumentInContentProcess() const; |
192 | | |
193 | | mozilla::WeakPtr<nsDocShell> mDocShell; |
194 | | |
195 | | nsCOMPtr<nsIURI> mUnloadedURI; |
196 | | nsCOMPtr<nsIURI> mLoadedURI; |
197 | | |
198 | | Type mNavigationType; |
199 | | DOMHighResTimeStamp mNavigationStartHighRes; |
200 | | mozilla::TimeStamp mNavigationStart; |
201 | | mozilla::TimeStamp mNonBlankPaint; |
202 | | mozilla::TimeStamp mDOMContentFlushed; |
203 | | |
204 | | mozilla::TimeStamp mBeforeUnloadStart; |
205 | | mozilla::TimeStamp mUnloadStart; |
206 | | mozilla::TimeStamp mUnloadEnd; |
207 | | mozilla::TimeStamp mLoadEventStart; |
208 | | mozilla::TimeStamp mLoadEventEnd; |
209 | | |
210 | | mozilla::TimeStamp mDOMLoading; |
211 | | mozilla::TimeStamp mDOMInteractive; |
212 | | mozilla::TimeStamp mDOMContentLoadedEventStart; |
213 | | mozilla::TimeStamp mDOMContentLoadedEventEnd; |
214 | | mozilla::TimeStamp mDOMComplete; |
215 | | |
216 | | bool mDocShellHasBeenActiveSinceNavigationStart : 1; |
217 | | }; |
218 | | |
219 | | #endif /* nsDOMNavigationTiming_h___ */ |