dom/base/PerformanceResourceTiming.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef mozilla_dom_PerformanceResourceTiming_h___
michael@0 7 #define mozilla_dom_PerformanceResourceTiming_h___
michael@0 8
michael@0 9 #include "nsCOMPtr.h"
michael@0 10 #include "nsPerformance.h"
michael@0 11 #include "nsIChannel.h"
michael@0 12 #include "nsITimedChannel.h"
michael@0 13 #include "nsDOMNavigationTiming.h"
michael@0 14 #include "PerformanceEntry.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17 namespace dom {
michael@0 18
michael@0 19 // http://www.w3.org/TR/resource-timing/#performanceresourcetiming
michael@0 20 class PerformanceResourceTiming MOZ_FINAL : public PerformanceEntry
michael@0 21 {
michael@0 22 public:
michael@0 23 typedef mozilla::TimeStamp TimeStamp;
michael@0 24
michael@0 25 NS_DECL_ISUPPORTS_INHERITED
michael@0 26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
michael@0 27 PerformanceResourceTiming,
michael@0 28 PerformanceEntry)
michael@0 29
michael@0 30 PerformanceResourceTiming(nsPerformanceTiming* aPerformanceTiming,
michael@0 31 nsPerformance* aPerformance);
michael@0 32 virtual ~PerformanceResourceTiming();
michael@0 33
michael@0 34 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 35
michael@0 36
michael@0 37 virtual DOMHighResTimeStamp StartTime() const;
michael@0 38
michael@0 39 virtual DOMHighResTimeStamp Duration() const
michael@0 40 {
michael@0 41 return ResponseEnd() - StartTime();
michael@0 42 }
michael@0 43
michael@0 44 void GetInitiatorType(nsAString& aInitiatorType) const
michael@0 45 {
michael@0 46 aInitiatorType = mInitiatorType;
michael@0 47 }
michael@0 48
michael@0 49 void SetInitiatorType(const nsAString& aInitiatorType)
michael@0 50 {
michael@0 51 mInitiatorType = aInitiatorType;
michael@0 52 }
michael@0 53
michael@0 54 DOMHighResTimeStamp FetchStart() const {
michael@0 55 return mTiming
michael@0 56 ? mTiming->FetchStartHighRes()
michael@0 57 : 0;
michael@0 58 }
michael@0 59
michael@0 60 DOMHighResTimeStamp RedirectStart() const {
michael@0 61 // We have to check if all the redirect URIs had the same origin (since
michael@0 62 // there is no check in RedirectEndHighRes())
michael@0 63 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 64 ? mTiming->RedirectStartHighRes()
michael@0 65 : 0;
michael@0 66 }
michael@0 67
michael@0 68 DOMHighResTimeStamp RedirectEnd() const {
michael@0 69 // We have to check if all the redirect URIs had the same origin (since
michael@0 70 // there is no check in RedirectEndHighRes())
michael@0 71 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 72 ? mTiming->RedirectEndHighRes()
michael@0 73 : 0;
michael@0 74 }
michael@0 75
michael@0 76 DOMHighResTimeStamp DomainLookupStart() const {
michael@0 77 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 78 ? mTiming->DomainLookupStartHighRes()
michael@0 79 : 0;
michael@0 80 }
michael@0 81
michael@0 82 DOMHighResTimeStamp DomainLookupEnd() const {
michael@0 83 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 84 ? mTiming->DomainLookupEndHighRes()
michael@0 85 : 0;
michael@0 86 }
michael@0 87
michael@0 88 DOMHighResTimeStamp ConnectStart() const {
michael@0 89 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 90 ? mTiming->ConnectStartHighRes()
michael@0 91 : 0;
michael@0 92 }
michael@0 93
michael@0 94 DOMHighResTimeStamp ConnectEnd() const {
michael@0 95 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 96 ? mTiming->ConnectEndHighRes()
michael@0 97 : 0;
michael@0 98 }
michael@0 99
michael@0 100 DOMHighResTimeStamp RequestStart() const {
michael@0 101 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 102 ? mTiming->RequestStartHighRes()
michael@0 103 : 0;
michael@0 104 }
michael@0 105
michael@0 106 DOMHighResTimeStamp ResponseStart() const {
michael@0 107 return mTiming && mTiming->IsSameOriginAsReferral()
michael@0 108 ? mTiming->ResponseStartHighRes()
michael@0 109 : 0;
michael@0 110 }
michael@0 111
michael@0 112 DOMHighResTimeStamp ResponseEnd() const {
michael@0 113 return mTiming
michael@0 114 ? mTiming->ResponseEndHighRes()
michael@0 115 : 0;
michael@0 116 }
michael@0 117
michael@0 118 DOMHighResTimeStamp SecureConnectionStart() const
michael@0 119 {
michael@0 120 // This measurement is not available for Navigation Timing either.
michael@0 121 // There is a different bug submitted for it.
michael@0 122 return 0;
michael@0 123 }
michael@0 124
michael@0 125 protected:
michael@0 126 nsString mInitiatorType;
michael@0 127 nsRefPtr<nsPerformanceTiming> mTiming;
michael@0 128 };
michael@0 129
michael@0 130 } // namespace dom
michael@0 131 } // namespace mozilla
michael@0 132
michael@0 133 #endif /* mozilla_dom_PerformanceResourceTiming_h___ */

mercurial