Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / base / nsDOMNavigationTiming.h
blob9c48d50f310c1adefa23c6914276eac51f632d3f
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsDOMNavigationTiming_h___
7 #define nsDOMNavigationTiming_h___
9 #include "nsCOMPtr.h"
10 #include "nsCOMArray.h"
11 #include "mozilla/TimeStamp.h"
13 class nsIURI;
15 typedef unsigned long long DOMTimeMilliSec;
16 typedef double DOMHighResTimeStamp;
17 typedef unsigned short nsDOMPerformanceNavigationType;
19 namespace mozilla {
20 namespace dom {
21 namespace PerformanceNavigation {
22 static const nsDOMPerformanceNavigationType TYPE_NAVIGATE = 0;
23 static const nsDOMPerformanceNavigationType TYPE_RELOAD = 1;
24 static const nsDOMPerformanceNavigationType TYPE_BACK_FORWARD = 2;
25 static const nsDOMPerformanceNavigationType TYPE_RESERVED = 255;
30 class nsDOMNavigationTiming MOZ_FINAL
32 public:
33 nsDOMNavigationTiming();
35 NS_INLINE_DECL_REFCOUNTING(nsDOMNavigationTiming)
37 nsDOMPerformanceNavigationType GetType() const {
38 return mNavigationType;
40 inline DOMHighResTimeStamp GetNavigationStartHighRes() const {
41 return mNavigationStartHighRes;
43 DOMTimeMilliSec GetNavigationStart() const {
44 return static_cast<int64_t>(GetNavigationStartHighRes());
46 mozilla::TimeStamp GetNavigationStartTimeStamp() const {
47 return mNavigationStartTimeStamp;
49 DOMTimeMilliSec GetUnloadEventStart();
50 DOMTimeMilliSec GetUnloadEventEnd();
51 DOMTimeMilliSec GetDomLoading() const {
52 return mDOMLoading;
54 DOMTimeMilliSec GetDomInteractive() const {
55 return mDOMInteractive;
57 DOMTimeMilliSec GetDomContentLoadedEventStart() const {
58 return mDOMContentLoadedEventStart;
60 DOMTimeMilliSec GetDomContentLoadedEventEnd() const {
61 return mDOMContentLoadedEventEnd;
63 DOMTimeMilliSec GetDomComplete() const {
64 return mDOMComplete;
66 DOMTimeMilliSec GetLoadEventStart() const {
67 return mLoadEventStart;
69 DOMTimeMilliSec GetLoadEventEnd() const {
70 return mLoadEventEnd;
73 void NotifyNavigationStart();
74 void NotifyFetchStart(nsIURI* aURI, nsDOMPerformanceNavigationType aNavigationType);
75 void NotifyBeforeUnload();
76 void NotifyUnloadAccepted(nsIURI* aOldURI);
77 void NotifyUnloadEventStart();
78 void NotifyUnloadEventEnd();
79 void NotifyLoadEventStart();
80 void NotifyLoadEventEnd();
82 // Document changes state to 'loading' before connecting to timing
83 void SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue);
84 void NotifyDOMLoading(nsIURI* aURI);
85 void NotifyDOMInteractive(nsIURI* aURI);
86 void NotifyDOMComplete(nsIURI* aURI);
87 void NotifyDOMContentLoadedStart(nsIURI* aURI);
88 void NotifyDOMContentLoadedEnd(nsIURI* aURI);
89 DOMTimeMilliSec TimeStampToDOM(mozilla::TimeStamp aStamp) const;
91 inline DOMHighResTimeStamp TimeStampToDOMHighRes(mozilla::TimeStamp aStamp)
93 mozilla::TimeDuration duration = aStamp - mNavigationStartTimeStamp;
94 return duration.ToMilliseconds();
97 private:
98 nsDOMNavigationTiming(const nsDOMNavigationTiming &) = delete;
99 ~nsDOMNavigationTiming();
101 void Clear();
103 nsCOMPtr<nsIURI> mUnloadedURI;
104 nsCOMPtr<nsIURI> mLoadedURI;
106 nsDOMPerformanceNavigationType mNavigationType;
107 DOMHighResTimeStamp mNavigationStartHighRes;
108 mozilla::TimeStamp mNavigationStartTimeStamp;
109 DOMTimeMilliSec DurationFromStart();
111 DOMTimeMilliSec mBeforeUnloadStart;
112 DOMTimeMilliSec mUnloadStart;
113 DOMTimeMilliSec mUnloadEnd;
114 DOMTimeMilliSec mLoadEventStart;
115 DOMTimeMilliSec mLoadEventEnd;
117 DOMTimeMilliSec mDOMLoading;
118 DOMTimeMilliSec mDOMInteractive;
119 DOMTimeMilliSec mDOMContentLoadedEventStart;
120 DOMTimeMilliSec mDOMContentLoadedEventEnd;
121 DOMTimeMilliSec mDOMComplete;
123 // Booleans to keep track of what things we've already been notified
124 // about. We don't update those once we've been notified about them
125 // once.
126 bool mLoadEventStartSet : 1;
127 bool mLoadEventEndSet : 1;
128 bool mDOMLoadingSet : 1;
129 bool mDOMInteractiveSet : 1;
130 bool mDOMContentLoadedEventStartSet : 1;
131 bool mDOMContentLoadedEventEndSet : 1;
132 bool mDOMCompleteSet : 1;
135 #endif /* nsDOMNavigationTiming_h___ */