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 mozilla_dom_PerformanceResourceTiming_h___
7 #define mozilla_dom_PerformanceResourceTiming_h___
10 #include "nsPerformance.h"
11 #include "nsIChannel.h"
12 #include "nsITimedChannel.h"
13 #include "nsDOMNavigationTiming.h"
14 #include "PerformanceEntry.h"
19 // http://www.w3.org/TR/resource-timing/#performanceresourcetiming
20 class PerformanceResourceTiming MOZ_FINAL
: public PerformanceEntry
23 typedef mozilla::TimeStamp TimeStamp
;
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
27 PerformanceResourceTiming
,
30 PerformanceResourceTiming(nsPerformanceTiming
* aPerformanceTiming
,
31 nsPerformance
* aPerformance
);
33 virtual JSObject
* WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
36 virtual DOMHighResTimeStamp
StartTime() const;
38 virtual DOMHighResTimeStamp
Duration() const
40 return ResponseEnd() - StartTime();
43 void GetInitiatorType(nsAString
& aInitiatorType
) const
45 aInitiatorType
= mInitiatorType
;
48 void SetInitiatorType(const nsAString
& aInitiatorType
)
50 mInitiatorType
= aInitiatorType
;
53 DOMHighResTimeStamp
FetchStart() const {
55 ? mTiming
->FetchStartHighRes()
59 DOMHighResTimeStamp
RedirectStart() const {
60 // We have to check if all the redirect URIs had the same origin (since
61 // there is no check in RedirectEndHighRes())
62 return mTiming
&& mTiming
->IsSameOriginAsReferral()
63 ? mTiming
->RedirectStartHighRes()
67 DOMHighResTimeStamp
RedirectEnd() const {
68 // We have to check if all the redirect URIs had the same origin (since
69 // there is no check in RedirectEndHighRes())
70 return mTiming
&& mTiming
->IsSameOriginAsReferral()
71 ? mTiming
->RedirectEndHighRes()
75 DOMHighResTimeStamp
DomainLookupStart() const {
76 return mTiming
&& mTiming
->IsSameOriginAsReferral()
77 ? mTiming
->DomainLookupStartHighRes()
81 DOMHighResTimeStamp
DomainLookupEnd() const {
82 return mTiming
&& mTiming
->IsSameOriginAsReferral()
83 ? mTiming
->DomainLookupEndHighRes()
87 DOMHighResTimeStamp
ConnectStart() const {
88 return mTiming
&& mTiming
->IsSameOriginAsReferral()
89 ? mTiming
->ConnectStartHighRes()
93 DOMHighResTimeStamp
ConnectEnd() const {
94 return mTiming
&& mTiming
->IsSameOriginAsReferral()
95 ? mTiming
->ConnectEndHighRes()
99 DOMHighResTimeStamp
RequestStart() const {
100 return mTiming
&& mTiming
->IsSameOriginAsReferral()
101 ? mTiming
->RequestStartHighRes()
105 DOMHighResTimeStamp
ResponseStart() const {
106 return mTiming
&& mTiming
->IsSameOriginAsReferral()
107 ? mTiming
->ResponseStartHighRes()
111 DOMHighResTimeStamp
ResponseEnd() const {
113 ? mTiming
->ResponseEndHighRes()
117 DOMHighResTimeStamp
SecureConnectionStart() const
119 // This measurement is not available for Navigation Timing either.
120 // There is a different bug submitted for it.
125 virtual ~PerformanceResourceTiming();
127 nsString mInitiatorType
;
128 nsRefPtr
<nsPerformanceTiming
> mTiming
;
132 } // namespace mozilla
134 #endif /* mozilla_dom_PerformanceResourceTiming_h___ */