michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_PerformanceResourceTiming_h___ michael@0: #define mozilla_dom_PerformanceResourceTiming_h___ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsPerformance.h" michael@0: #include "nsIChannel.h" michael@0: #include "nsITimedChannel.h" michael@0: #include "nsDOMNavigationTiming.h" michael@0: #include "PerformanceEntry.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: // http://www.w3.org/TR/resource-timing/#performanceresourcetiming michael@0: class PerformanceResourceTiming MOZ_FINAL : public PerformanceEntry michael@0: { michael@0: public: michael@0: typedef mozilla::TimeStamp TimeStamp; michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED( michael@0: PerformanceResourceTiming, michael@0: PerformanceEntry) michael@0: michael@0: PerformanceResourceTiming(nsPerformanceTiming* aPerformanceTiming, michael@0: nsPerformance* aPerformance); michael@0: virtual ~PerformanceResourceTiming(); michael@0: michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: michael@0: virtual DOMHighResTimeStamp StartTime() const; michael@0: michael@0: virtual DOMHighResTimeStamp Duration() const michael@0: { michael@0: return ResponseEnd() - StartTime(); michael@0: } michael@0: michael@0: void GetInitiatorType(nsAString& aInitiatorType) const michael@0: { michael@0: aInitiatorType = mInitiatorType; michael@0: } michael@0: michael@0: void SetInitiatorType(const nsAString& aInitiatorType) michael@0: { michael@0: mInitiatorType = aInitiatorType; michael@0: } michael@0: michael@0: DOMHighResTimeStamp FetchStart() const { michael@0: return mTiming michael@0: ? mTiming->FetchStartHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp RedirectStart() const { michael@0: // We have to check if all the redirect URIs had the same origin (since michael@0: // there is no check in RedirectEndHighRes()) michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->RedirectStartHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp RedirectEnd() const { michael@0: // We have to check if all the redirect URIs had the same origin (since michael@0: // there is no check in RedirectEndHighRes()) michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->RedirectEndHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp DomainLookupStart() const { michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->DomainLookupStartHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp DomainLookupEnd() const { michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->DomainLookupEndHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp ConnectStart() const { michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->ConnectStartHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp ConnectEnd() const { michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->ConnectEndHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp RequestStart() const { michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->RequestStartHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp ResponseStart() const { michael@0: return mTiming && mTiming->IsSameOriginAsReferral() michael@0: ? mTiming->ResponseStartHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp ResponseEnd() const { michael@0: return mTiming michael@0: ? mTiming->ResponseEndHighRes() michael@0: : 0; michael@0: } michael@0: michael@0: DOMHighResTimeStamp SecureConnectionStart() const michael@0: { michael@0: // This measurement is not available for Navigation Timing either. michael@0: // There is a different bug submitted for it. michael@0: return 0; michael@0: } michael@0: michael@0: protected: michael@0: nsString mInitiatorType; michael@0: nsRefPtr mTiming; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif /* mozilla_dom_PerformanceResourceTiming_h___ */