Bumping manifests a=b2g-bump
[gecko.git] / dom / base / PerformanceResourceTiming.h
blobfe1ff63b59b4715003a0bd56a71cf5b2320d6e5c
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___
9 #include "nsCOMPtr.h"
10 #include "nsPerformance.h"
11 #include "nsIChannel.h"
12 #include "nsITimedChannel.h"
13 #include "nsDOMNavigationTiming.h"
14 #include "PerformanceEntry.h"
16 namespace mozilla {
17 namespace dom {
19 // http://www.w3.org/TR/resource-timing/#performanceresourcetiming
20 class PerformanceResourceTiming MOZ_FINAL : public PerformanceEntry
22 public:
23 typedef mozilla::TimeStamp TimeStamp;
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
27 PerformanceResourceTiming,
28 PerformanceEntry)
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 {
54 return mTiming
55 ? mTiming->FetchStartHighRes()
56 : 0;
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()
64 : 0;
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()
72 : 0;
75 DOMHighResTimeStamp DomainLookupStart() const {
76 return mTiming && mTiming->IsSameOriginAsReferral()
77 ? mTiming->DomainLookupStartHighRes()
78 : 0;
81 DOMHighResTimeStamp DomainLookupEnd() const {
82 return mTiming && mTiming->IsSameOriginAsReferral()
83 ? mTiming->DomainLookupEndHighRes()
84 : 0;
87 DOMHighResTimeStamp ConnectStart() const {
88 return mTiming && mTiming->IsSameOriginAsReferral()
89 ? mTiming->ConnectStartHighRes()
90 : 0;
93 DOMHighResTimeStamp ConnectEnd() const {
94 return mTiming && mTiming->IsSameOriginAsReferral()
95 ? mTiming->ConnectEndHighRes()
96 : 0;
99 DOMHighResTimeStamp RequestStart() const {
100 return mTiming && mTiming->IsSameOriginAsReferral()
101 ? mTiming->RequestStartHighRes()
102 : 0;
105 DOMHighResTimeStamp ResponseStart() const {
106 return mTiming && mTiming->IsSameOriginAsReferral()
107 ? mTiming->ResponseStartHighRes()
108 : 0;
111 DOMHighResTimeStamp ResponseEnd() const {
112 return mTiming
113 ? mTiming->ResponseEndHighRes()
114 : 0;
117 DOMHighResTimeStamp SecureConnectionStart() const
119 // This measurement is not available for Navigation Timing either.
120 // There is a different bug submitted for it.
121 return 0;
124 protected:
125 virtual ~PerformanceResourceTiming();
127 nsString mInitiatorType;
128 nsRefPtr<nsPerformanceTiming> mTiming;
131 } // namespace dom
132 } // namespace mozilla
134 #endif /* mozilla_dom_PerformanceResourceTiming_h___ */