--- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -10682,17 +10682,16 @@ nsDocShell::DoURILoad(nsIURI* aURI, // can be exposed on the service worker FetchEvent. rv = loadInfo->SetIsDocshellReload(mLoadType & LOAD_CMD_RELOAD); NS_ENSURE_SUCCESS(rv, rv); if (!isSrcdoc) { rv = NS_NewChannelInternal(getter_AddRefs(channel), aURI, loadInfo, - nullptr, // PerformanceStorage nullptr, // loadGroup static_cast<nsIInterfaceRequestor*>(this), loadFlags); if (NS_FAILED(rv)) { if (rv == NS_ERROR_UNKNOWN_PROTOCOL) { // This is a uri with a protocol scheme we don't know how // to handle. Embedders might still be interested in
--- a/docshell/base/nsPingListener.cpp +++ b/docshell/base/nsPingListener.cpp @@ -104,17 +104,16 @@ SendPing(void* aClosure, nsIContent* aCo nsCOMPtr<nsIChannel> chan; NS_NewChannel(getter_AddRefs(chan), aURI, doc, info->requireSameHost ? nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED : nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_PING, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, // aLoadFlags, aIOService); if (!chan) { return; }
--- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -1031,28 +1031,26 @@ EventSourceImpl::InitChannelAndRequestEv // If we have the document, use it if (doc) { nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup(); rv = NS_NewChannel(getter_AddRefs(channel), mSrc, doc, securityFlags, nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE, - nullptr, // aPerformanceStorage loadGroup, nullptr, // aCallbacks loadFlags); // aLoadFlags } else { // otherwise use the principal rv = NS_NewChannel(getter_AddRefs(channel), mSrc, mPrincipal, securityFlags, nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE, - nullptr, // aPerformanceStorage nullptr, // loadGroup nullptr, // aCallbacks loadFlags); // aLoadFlags } NS_ENSURE_SUCCESS(rv, rv); mHttpChannel = do_QueryInterface(channel);
--- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1151,17 +1151,16 @@ Navigator::SendBeaconInternal(const nsAS securityFlags |= nsILoadInfo::SEC_COOKIES_INCLUDE; nsCOMPtr<nsIChannel> channel; rv = NS_NewChannel(getter_AddRefs(channel), uri, doc, securityFlags, nsIContentPolicy::TYPE_BEACON, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks loadFlags); if (NS_FAILED(rv)) { aRv.Throw(rv); return false; }
--- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -1186,17 +1186,16 @@ nsExternalResourceMap::PendingLoad::Star nsresult rv = NS_OK; nsCOMPtr<nsIChannel> channel; rv = NS_NewChannel(getter_AddRefs(channel), aURI, aRequestingNode, nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS, nsIContentPolicy::TYPE_OTHER, - nullptr, // aPerformanceStorage loadGroup); NS_ENSURE_SUCCESS(rv, rv); mURI = aURI; return channel->AsyncOpen2(this); }
--- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -2504,17 +2504,16 @@ nsObjectLoadingContent::OpenChannel() nsContentPolicyType contentPolicyType = GetContentPolicyType(); rv = NS_NewChannel(getter_AddRefs(chan), mURI, thisContent, securityFlags, contentPolicyType, - nullptr, // aPerformanceStorage group, // aLoadGroup shim, // aCallbacks nsIChannel::LOAD_CALL_CONTENT_SNIFFERS | nsIChannel::LOAD_CLASSIFY_URI | nsIChannel::LOAD_BYPASS_SERVICE_WORKER | nsIRequest::LOAD_HTML_OBJECT_DATA); NS_ENSURE_SUCCESS(rv, rv); if (inherit) {
--- a/dom/base/nsSyncLoadService.cpp +++ b/dom/base/nsSyncLoadService.cpp @@ -316,17 +316,16 @@ nsSyncLoadService::LoadDocument(nsIURI * nsIDOMDocument** aResult) { nsCOMPtr<nsIChannel> channel; nsresult rv = NS_NewChannel(getter_AddRefs(channel), aURI, aLoaderPrincipal, aSecurityFlags, aContentPolicyType, - nullptr, // PerformanceStorage aLoadGroup); NS_ENSURE_SUCCESS(rv, rv); if (!aForceToXML) { channel->SetContentType(NS_LITERAL_CSTRING("text/xml")); } bool isChrome = false, isResource = false;
--- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -421,19 +421,17 @@ public: MOZ_ASSERT(workerPrivate); nsCOMPtr<nsIPrincipal> principal = workerPrivate->GetPrincipal(); MOZ_ASSERT(principal); nsCOMPtr<nsILoadGroup> loadGroup = workerPrivate->GetLoadGroup(); MOZ_ASSERT(loadGroup); // We don't track if a worker is spawned from a tracking script for now, // so pass false as the last argument to FetchDriver(). fetch = new FetchDriver(mRequest, principal, loadGroup, - workerPrivate->MainThreadEventTarget(), - workerPrivate->GetPerformanceStorage(), - false); + workerPrivate->MainThreadEventTarget(), false); nsAutoCString spec; if (proxy->GetWorkerPrivate()->GetBaseURI()) { proxy->GetWorkerPrivate()->GetBaseURI()->GetAsciiSpec(spec); } fetch->SetWorkerScript(spec); fetch->SetClientInfo(mClientInfo); fetch->SetController(mController); @@ -527,19 +525,17 @@ FetchRequest(nsIGlobalObject* aGlobal, c } Telemetry::Accumulate(Telemetry::FETCH_IS_MAINTHREAD, 1); RefPtr<MainThreadFetchResolver> resolver = new MainThreadFetchResolver(p, observer, signal, request->MozErrors()); RefPtr<FetchDriver> fetch = new FetchDriver(r, principal, loadGroup, - aGlobal->EventTargetFor(TaskCategory::Other), - nullptr, // PerformanceStorage - isTrackingFetch); + aGlobal->EventTargetFor(TaskCategory::Other), isTrackingFetch); fetch->SetDocument(doc); resolver->SetLoadGroup(loadGroup); aRv = fetch->Fetch(signal, resolver); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } } else { WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
--- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -26,17 +26,16 @@ #include "nsNetUtil.h" #include "nsPrintfCString.h" #include "nsProxyRelease.h" #include "nsStreamUtils.h" #include "nsStringStream.h" #include "nsHttpChannel.h" #include "mozilla/dom/File.h" -#include "mozilla/dom/PerformanceStorage.h" #include "mozilla/dom/workers/Workers.h" #include "mozilla/EventStateManager.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/Unused.h" #include "Fetch.h" #include "FetchUtil.h" #include "InternalRequest.h" @@ -321,27 +320,23 @@ AlternativeDataStreamListener::CheckList //----------------------------------------------------------------------------- // FetchDriver //----------------------------------------------------------------------------- NS_IMPL_ISUPPORTS(FetchDriver, nsIStreamListener, nsIChannelEventSink, nsIInterfaceRequestor, nsIThreadRetargetableStreamListener) -FetchDriver::FetchDriver(InternalRequest* aRequest, - nsIPrincipal* aPrincipal, - nsILoadGroup* aLoadGroup, - nsIEventTarget* aMainThreadEventTarget, - PerformanceStorage* aPerformanceStorage, +FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal, + nsILoadGroup* aLoadGroup, nsIEventTarget* aMainThreadEventTarget, bool aIsTrackingFetch) : mPrincipal(aPrincipal) , mLoadGroup(aLoadGroup) , mRequest(aRequest) , mMainThreadEventTarget(aMainThreadEventTarget) - , mPerformanceStorage(aPerformanceStorage) , mNeedToObserveOnDataAvailable(false) , mIsTrackingFetch(aIsTrackingFetch) #ifdef DEBUG , mResponseAvailableCalled(false) , mFetchCalled(false) #endif { AssertIsOnMainThread(); @@ -516,41 +511,38 @@ FetchDriver::HttpFetch(const nsACString& bypassFlag | nsIChannel::LOAD_CLASSIFY_URI; if (mDocument) { MOZ_ASSERT(mDocument->NodePrincipal() == mPrincipal); rv = NS_NewChannel(getter_AddRefs(chan), uri, mDocument, secFlags, mRequest->ContentPolicyType(), - nullptr, /* aPerformanceStorage */ mLoadGroup, nullptr, /* aCallbacks */ loadFlags, ios); } else if (mClientInfo.isSome()) { rv = NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, mClientInfo.ref(), mController, secFlags, mRequest->ContentPolicyType(), - mPerformanceStorage, mLoadGroup, nullptr, /* aCallbacks */ loadFlags, ios); } else { rv = NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, secFlags, mRequest->ContentPolicyType(), - mPerformanceStorage, mLoadGroup, nullptr, /* aCallbacks */ loadFlags, ios); } NS_ENSURE_SUCCESS(rv, rv); // Insert ourselves into the notification callbacks chain so we can set
--- a/dom/fetch/FetchDriver.h +++ b/dom/fetch/FetchDriver.h @@ -27,17 +27,16 @@ class nsIOutputStream; class nsILoadGroup; class nsIPrincipal; namespace mozilla { namespace dom { class InternalRequest; class InternalResponse; -class PerformanceStorage; /** * Provides callbacks to be called when response is available or on error. * Implemenations usually resolve or reject the promise returned from fetch(). * The callbacks can be called synchronously or asynchronously from FetchDriver::Fetch. */ class FetchDriverObserver { @@ -105,17 +104,16 @@ public: NS_DECL_NSICHANNELEVENTSINK NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal, nsILoadGroup* aLoadGroup, nsIEventTarget* aMainThreadEventTarget, - PerformanceStorage* aPerformanceStorage, bool aIsTrackingFetch); nsresult Fetch(AbortSignal* aSignal, FetchDriverObserver* aObserver); void SetDocument(nsIDocument* aDocument); @@ -144,20 +142,16 @@ private: nsCOMPtr<nsIOutputStream> mPipeOutputStream; RefPtr<FetchDriverObserver> mObserver; nsCOMPtr<nsIDocument> mDocument; Maybe<ClientInfo> mClientInfo; Maybe<ServiceWorkerDescriptor> mController; nsCOMPtr<nsIChannel> mChannel; nsAutoPtr<SRICheckDataVerifier> mSRIDataVerifier; nsCOMPtr<nsIEventTarget> mMainThreadEventTarget; - - // This is set only when Fetch is used in workers. - RefPtr<PerformanceStorage> mPerformanceStorage; - SRIMetadata mSRIMetadata; nsCString mWorkerScript; // This is written once in OnStartRequest on the main thread and then // written/read in OnDataAvailable() on any thread. Necko guarantees // that these do not overlap. bool mNeedToObserveOnDataAvailable;
--- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -1213,17 +1213,16 @@ public: nsCOMPtr<nsIChannel> channel; nsresult rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel), aElement->mLoadingSrc, static_cast<Element*>(aElement), triggeringPrincipal, securityFlags, contentPolicyType, - nullptr, // aPerformanceStorage loadGroup, nullptr, // aCallbacks nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY | nsIChannel::LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE | nsIChannel::LOAD_CLASSIFY_URI | nsIChannel::LOAD_CALL_CONTENT_SNIFFERS); if (NS_FAILED(rv)) {
--- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -322,17 +322,16 @@ HTMLTrackElement::LoadResource() nsCOMPtr<nsIChannel> channel; nsCOMPtr<nsILoadGroup> loadGroup = OwnerDoc()->GetDocumentLoadGroup(); rv = NS_NewChannel(getter_AddRefs(channel), uri, static_cast<Element*>(this), secFlags, nsIContentPolicy::TYPE_INTERNAL_TRACK, - nullptr, // PerformanceStorage loadGroup, nullptr, // aCallbacks nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI); NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv)); mListener = new WebVTTListener(this); rv = mListener->LoadResource();
--- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -1625,17 +1625,16 @@ nsHTMLDocument::Open(JSContext* cx, // So we reset the document and then reinitialize it. nsCOMPtr<nsIChannel> channel; nsCOMPtr<nsILoadGroup> group = do_QueryReferent(mDocumentLoadGroup); aError = NS_NewChannel(getter_AddRefs(channel), uri, callerDoc, nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage group); if (aError.Failed()) { return nullptr; } if (callerChannel) { nsLoadFlags callerLoadFlags;
--- a/dom/media/ChannelMediaResource.cpp +++ b/dom/media/ChannelMediaResource.cpp @@ -721,17 +721,16 @@ ChannelMediaResource::RecreateChannel() getter_AddRefs(triggeringPrincipal)); nsresult rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(mChannel), mURI, element, triggeringPrincipal, securityFlags, contentPolicyType, - nullptr, // aPerformanceStorage loadGroup, nullptr, // aCallbacks loadFlags); NS_ENSURE_SUCCESS(rv, rv); if (setAttrs) { nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo(); if (loadInfo) {
--- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -232,16 +232,17 @@ Performance::ClearUserEntries(const Opti ++i; } } } void Performance::ClearResourceTimings() { + MOZ_ASSERT(NS_IsMainThread()); mResourceEntries.Clear(); } DOMHighResTimeStamp Performance::RoundTime(double aTime) const { // Round down to the nearest 20us, because if the timer is too accurate people // can do nasty timing attacks with it. @@ -425,24 +426,23 @@ Performance::SetResourceTimingBufferSize { mResourceTimingBufferSize = aMaxSize; } void Performance::InsertResourceEntry(PerformanceEntry* aEntry) { MOZ_ASSERT(aEntry); - MOZ_ASSERT(mResourceEntries.Length() <= mResourceTimingBufferSize); + MOZ_ASSERT(mResourceEntries.Length() < mResourceTimingBufferSize); // We won't add an entry when 'privacy.resistFingerprint' is true. if (nsContentUtils::ShouldResistFingerprinting()) { return; } - // Don't add the entry if the buffer is full if (mResourceEntries.Length() >= mResourceTimingBufferSize) { return; } mResourceEntries.InsertElementSorted(aEntry, PerformanceEntryComparator()); if (mResourceEntries.Length() == mResourceTimingBufferSize) { // call onresourcetimingbufferfull
--- a/dom/performance/Performance.h +++ b/dom/performance/Performance.h @@ -8,28 +8,28 @@ #define mozilla_dom_Performance_h #include "mozilla/Attributes.h" #include "mozilla/DOMEventTargetHelper.h" #include "nsCOMPtr.h" #include "nsDOMNavigationTiming.h" class nsITimedChannel; +class nsIHttpChannel; namespace mozilla { class ErrorResult; namespace dom { class PerformanceEntry; class PerformanceNavigation; class PerformanceObserver; class PerformanceService; -class PerformanceStorage; class PerformanceTiming; namespace workers { class WorkerPrivate; } // Base class for main-thread and worker Performance API class Performance : public DOMEventTargetHelper @@ -56,17 +56,18 @@ public: virtual void GetEntriesByType(const nsAString& aEntryType, nsTArray<RefPtr<PerformanceEntry>>& aRetval); virtual void GetEntriesByName(const nsAString& aName, const Optional<nsAString>& aEntryType, nsTArray<RefPtr<PerformanceEntry>>& aRetval); - virtual PerformanceStorage* AsPerformanceStorage() = 0; + virtual void AddEntry(nsIHttpChannel* channel, + nsITimedChannel* timedChannel) = 0; void ClearResourceTimings(); DOMHighResTimeStamp Now() const; DOMHighResTimeStamp TimeOrigin(); void Mark(const nsAString& aName, ErrorResult& aRv); @@ -95,54 +96,58 @@ public: virtual void GetMozMemory(JSContext *aCx, JS::MutableHandle<JSObject*> aObj) = 0; virtual nsDOMNavigationTiming* GetDOMTiming() const = 0; virtual nsITimedChannel* GetChannel() const = 0; - virtual TimeStamp CreationTimeStamp() const = 0; - void MemoryPressure(); size_t SizeOfUserEntries(mozilla::MallocSizeOf aMallocSizeOf) const; size_t SizeOfResourceEntries(mozilla::MallocSizeOf aMallocSizeOf) const; - void InsertResourceEntry(PerformanceEntry* aEntry); - protected: Performance(); explicit Performance(nsPIDOMWindowInner* aWindow); virtual ~Performance(); virtual void InsertUserEntry(PerformanceEntry* aEntry); + void InsertResourceEntry(PerformanceEntry* aEntry); void ClearUserEntries(const Optional<nsAString>& aEntryName, const nsAString& aEntryType); DOMHighResTimeStamp ResolveTimestampFromName(const nsAString& aName, ErrorResult& aRv); virtual void DispatchBufferFullEvent() = 0; + virtual TimeStamp CreationTimeStamp() const = 0; + virtual DOMHighResTimeStamp CreationTime() const = 0; virtual bool IsPerformanceTimingAttribute(const nsAString& aName) { return false; } virtual DOMHighResTimeStamp GetPerformanceTimingFromString(const nsAString& aTimingName) { return 0; } + bool IsResourceEntryLimitReached() const + { + return mResourceEntries.Length() >= mResourceTimingBufferSize; + } + void LogEntry(PerformanceEntry* aEntry, const nsACString& aOwner) const; void TimingNotification(PerformanceEntry* aEntry, const nsACString& aOwner, uint64_t epoch); void RunNotificationObserversTask(); void QueueEntry(PerformanceEntry* aEntry); DOMHighResTimeStamp RoundTime(double aTime) const;
--- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -113,34 +113,74 @@ PerformanceMainThread::Navigation() * This method is not thread safe and can only be called on the main thread. */ void PerformanceMainThread::AddEntry(nsIHttpChannel* channel, nsITimedChannel* timedChannel) { MOZ_ASSERT(NS_IsMainThread()); - nsAutoString initiatorType; - nsAutoString entryName; + // Check if resource timing is prefed off. + if (!nsContentUtils::IsResourceTimingEnabled()) { + return; + } - UniquePtr<PerformanceTimingData> performanceTimingData( - PerformanceTimingData::Create(timedChannel, channel, 0, initiatorType, - entryName)); - if (!performanceTimingData) { + // Don't add the entry if the buffer is full + if (IsResourceEntryLimitReached()) { return; } - // The PerformanceResourceTiming object will use the PerformanceTimingData - // object to get all the required timings. - RefPtr<PerformanceResourceTiming> performanceEntry = - new PerformanceResourceTiming(Move(performanceTimingData), this, - entryName); + if (channel && timedChannel) { + nsAutoCString name; + nsAutoString initiatorType; + nsCOMPtr<nsIURI> originalURI; + + timedChannel->GetInitiatorType(initiatorType); + + // According to the spec, "The name attribute must return the resolved URL + // of the requested resource. This attribute must not change even if the + // fetch redirected to a different URL." + channel->GetOriginalURI(getter_AddRefs(originalURI)); + originalURI->GetSpec(name); + NS_ConvertUTF8toUTF16 entryName(name); + + bool reportTiming = true; + timedChannel->GetReportResourceTiming(&reportTiming); - performanceEntry->SetInitiatorType(initiatorType); - InsertResourceEntry(performanceEntry); + if (!reportTiming) { +#ifdef DEBUG_jwatt + NS_WARNING( + nsPrintfCString("Not reporting CORS resource: %s", name.get()).get()); +#endif + return; + } + + // The nsITimedChannel argument will be used to gather all the timings. + // The nsIHttpChannel argument will be used to check if any cross-origin + // redirects occurred. + // The last argument is the "zero time" (offset). Since we don't want + // any offset for the resource timing, this will be set to "0" - the + // resource timing returns a relative timing (no offset). + RefPtr<PerformanceTiming> performanceTiming = + new PerformanceTiming(this, timedChannel, channel, + 0); + + // The PerformanceResourceTiming object will use the PerformanceTiming + // object to get all the required timings. + RefPtr<PerformanceResourceTiming> performanceEntry = + new PerformanceResourceTiming(performanceTiming, this, entryName, channel); + + // If the initiator type had no valid value, then set it to the default + // ("other") value. + if (initiatorType.IsEmpty()) { + initiatorType = NS_LITERAL_STRING("other"); + } + performanceEntry->SetInitiatorType(initiatorType); + InsertResourceEntry(performanceEntry); + } } // To be removed once bug 1124165 lands bool PerformanceMainThread::IsPerformanceTimingAttribute(const nsAString& aName) { // Note that toJSON is added to this list due to bug 1047848 static const char* attributes[] = @@ -280,25 +320,21 @@ PerformanceMainThread::CreationTime() co { return GetDOMTiming()->GetNavigationStart(); } void PerformanceMainThread::EnsureDocEntry() { if (!mDocEntry && nsContentUtils::IsPerformanceNavigationTimingEnabled()) { - UniquePtr<PerformanceTimingData> timing( - new PerformanceTimingData(mChannel, nullptr, 0)); - nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel); - if (httpChannel) { - timing->SetPropertiesFromHttpChannel(httpChannel); - } - - mDocEntry = new PerformanceNavigationTiming(Move(timing), this); + RefPtr<PerformanceTiming> timing = + new PerformanceTiming(this, mChannel, nullptr, 0); + mDocEntry = new PerformanceNavigationTiming(timing, this, + httpChannel); } } void PerformanceMainThread::GetEntries(nsTArray<RefPtr<PerformanceEntry>>& aRetval) { // We return an empty list when 'privacy.resistFingerprinting' is on.
--- a/dom/performance/PerformanceMainThread.h +++ b/dom/performance/PerformanceMainThread.h @@ -3,38 +3,31 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_PerformanceMainThread_h #define mozilla_dom_PerformanceMainThread_h #include "Performance.h" -#include "PerformanceStorage.h" namespace mozilla { namespace dom { class PerformanceMainThread final : public Performance - , public PerformanceStorage { public: PerformanceMainThread(nsPIDOMWindowInner* aWindow, nsDOMNavigationTiming* aDOMTiming, nsITimedChannel* aChannel); NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMainThread, Performance) - PerformanceStorage* AsPerformanceStorage() override - { - return this; - } - virtual PerformanceTiming* Timing() override; virtual PerformanceNavigation* Navigation() override; virtual void AddEntry(nsIHttpChannel* channel, nsITimedChannel* timedChannel) override; TimeStamp CreationTimeStamp() const override;
--- a/dom/performance/PerformanceNavigation.cpp +++ b/dom/performance/PerformanceNavigation.cpp @@ -31,13 +31,13 @@ PerformanceNavigation::WrapObject(JSCont JS::Handle<JSObject*> aGivenProto) { return PerformanceNavigationBinding::Wrap(cx, this, aGivenProto); } uint16_t PerformanceNavigation::RedirectCount() const { - return GetPerformanceTiming()->Data()->GetRedirectCount(); + return GetPerformanceTiming()->GetRedirectCount(); } } // dom namespace } // mozilla namespace
--- a/dom/performance/PerformanceNavigationTiming.cpp +++ b/dom/performance/PerformanceNavigationTiming.cpp @@ -19,65 +19,65 @@ JSObject* PerformanceNavigationTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return PerformanceNavigationTimingBinding::Wrap(aCx, this, aGivenProto); } DOMHighResTimeStamp PerformanceNavigationTiming::UnloadEventStart() const { - return mPerformance->GetDOMTiming()->GetUnloadEventStartHighRes(); + return mTiming->GetDOMTiming()->GetUnloadEventStartHighRes(); } DOMHighResTimeStamp PerformanceNavigationTiming::UnloadEventEnd() const { - return mPerformance->GetDOMTiming()->GetUnloadEventEndHighRes(); + return mTiming->GetDOMTiming()->GetUnloadEventEndHighRes(); } DOMHighResTimeStamp PerformanceNavigationTiming::DomInteractive() const { - return mPerformance->GetDOMTiming()->GetDomInteractiveHighRes(); + return mTiming->GetDOMTiming()->GetDomInteractiveHighRes(); } DOMHighResTimeStamp PerformanceNavigationTiming::DomContentLoadedEventStart() const { - return mPerformance->GetDOMTiming()->GetDomContentLoadedEventStartHighRes(); + return mTiming->GetDOMTiming()->GetDomContentLoadedEventStartHighRes(); } DOMHighResTimeStamp PerformanceNavigationTiming::DomContentLoadedEventEnd() const { - return mPerformance->GetDOMTiming()->GetDomContentLoadedEventEndHighRes(); + return mTiming->GetDOMTiming()->GetDomContentLoadedEventEndHighRes(); } DOMHighResTimeStamp PerformanceNavigationTiming::DomComplete() const { - return mPerformance->GetDOMTiming()->GetDomCompleteHighRes(); + return mTiming->GetDOMTiming()->GetDomCompleteHighRes(); } DOMHighResTimeStamp PerformanceNavigationTiming::LoadEventStart() const { - return mPerformance->GetDOMTiming()->GetLoadEventStartHighRes(); + return mTiming->GetDOMTiming()->GetLoadEventStartHighRes(); } DOMHighResTimeStamp PerformanceNavigationTiming::LoadEventEnd() const { - return mPerformance->GetDOMTiming()->GetLoadEventEndHighRes(); + return mTiming->GetDOMTiming()->GetLoadEventEndHighRes(); } NavigationType PerformanceNavigationTiming::Type() const { - switch(mPerformance->GetDOMTiming()->GetType()) { + switch(mTiming->GetDOMTiming()->GetType()) { case nsDOMNavigationTiming::TYPE_NAVIGATE: return NavigationType::Navigate; break; case nsDOMNavigationTiming::TYPE_RELOAD: return NavigationType::Reload; break; case nsDOMNavigationTiming::TYPE_BACK_FORWARD: return NavigationType::Back_forward; @@ -87,10 +87,10 @@ PerformanceNavigationTiming::Type() cons // We fallback to the default of Navigate. return NavigationType::Navigate; } } uint16_t PerformanceNavigationTiming::RedirectCount() const { - return mTimingData->GetRedirectCount(); + return mTiming->GetRedirectCount(); }
--- a/dom/performance/PerformanceNavigationTiming.h +++ b/dom/performance/PerformanceNavigationTiming.h @@ -24,20 +24,21 @@ class PerformanceNavigationTiming final { public: NS_DECL_ISUPPORTS_INHERITED // Note that aPerformanceTiming must be initalized with zeroTime = 0 // so that timestamps are relative to startTime, as opposed to the // performance.timing object for which timestamps are absolute and has a // zeroTime initialized to navigationStart - PerformanceNavigationTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTiming, - Performance* aPerformance) - : PerformanceResourceTiming(Move(aPerformanceTiming), aPerformance, - NS_LITERAL_STRING("document")) { + explicit PerformanceNavigationTiming(PerformanceTiming* aPerformanceTiming, + Performance* aPerformance, + nsIHttpChannel* aChannel) + : PerformanceResourceTiming(aPerformanceTiming, aPerformance, + NS_LITERAL_STRING("document"), aChannel) { SetEntryType(NS_LITERAL_STRING("navigation")); SetInitiatorType(NS_LITERAL_STRING("navigation")); } DOMHighResTimeStamp Duration() const override { return nsRFPService::ReduceTimePrecisionAsMSecs(LoadEventEnd() - StartTime()); }
--- a/dom/performance/PerformanceResourceTiming.cpp +++ b/dom/performance/PerformanceResourceTiming.cpp @@ -6,60 +6,90 @@ #include "PerformanceResourceTiming.h" #include "mozilla/dom/PerformanceResourceTimingBinding.h" using namespace mozilla::dom; NS_IMPL_CYCLE_COLLECTION_INHERITED(PerformanceResourceTiming, PerformanceEntry, - mPerformance) + mTiming) NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PerformanceResourceTiming, PerformanceEntry) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PerformanceResourceTiming) NS_INTERFACE_MAP_END_INHERITING(PerformanceEntry) NS_IMPL_ADDREF_INHERITED(PerformanceResourceTiming, PerformanceEntry) NS_IMPL_RELEASE_INHERITED(PerformanceResourceTiming, PerformanceEntry) -PerformanceResourceTiming::PerformanceResourceTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTiming, +PerformanceResourceTiming::PerformanceResourceTiming(PerformanceTiming* aPerformanceTiming, Performance* aPerformance, - const nsAString& aName) - : PerformanceEntry(aPerformance->GetParentObject(), aName, NS_LITERAL_STRING("resource")) - , mTimingData(Move(aPerformanceTiming)) - , mPerformance(aPerformance) + const nsAString& aName, + nsIHttpChannel* aChannel) +: PerformanceEntry(aPerformance->GetParentObject(), aName, NS_LITERAL_STRING("resource")), + mTiming(aPerformanceTiming), + mEncodedBodySize(0), + mTransferSize(0), + mDecodedBodySize(0) { MOZ_ASSERT(aPerformance, "Parent performance object should be provided"); + SetPropertiesFromChannel(aChannel); +} + +void +PerformanceResourceTiming::SetPropertiesFromChannel(nsIHttpChannel* aChannel) +{ + if (!aChannel) { + return; + } + + nsAutoCString protocol; + Unused << aChannel->GetProtocolVersion(protocol); + SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol)); + + uint64_t encodedBodySize = 0; + Unused << aChannel->GetEncodedBodySize(&encodedBodySize); + SetEncodedBodySize(encodedBodySize); + + uint64_t transferSize = 0; + Unused << aChannel->GetTransferSize(&transferSize); + SetTransferSize(transferSize); + + uint64_t decodedBodySize = 0; + Unused << aChannel->GetDecodedBodySize(&decodedBodySize); + if (decodedBodySize == 0) { + decodedBodySize = encodedBodySize; + } + SetDecodedBodySize(decodedBodySize); } PerformanceResourceTiming::~PerformanceResourceTiming() { } DOMHighResTimeStamp PerformanceResourceTiming::StartTime() const { // Force the start time to be the earliest of: // - RedirectStart // - WorkerStart // - AsyncOpen // Ignore zero values. The RedirectStart and WorkerStart values // can come from earlier redirected channels prior to the AsyncOpen // time being recorded. - DOMHighResTimeStamp redirect = - mTimingData->RedirectStartHighRes(mPerformance); + DOMHighResTimeStamp redirect = mTiming->RedirectStartHighRes(); redirect = redirect ? redirect : DBL_MAX; - DOMHighResTimeStamp worker = mTimingData->WorkerStartHighRes(mPerformance); + DOMHighResTimeStamp worker = mTiming->WorkerStartHighRes(); worker = worker ? worker : DBL_MAX; - DOMHighResTimeStamp asyncOpen = mTimingData->AsyncOpenHighRes(mPerformance); + DOMHighResTimeStamp asyncOpen = mTiming->AsyncOpenHighRes(); return std::min(asyncOpen, std::min(redirect, worker)); } JSObject* PerformanceResourceTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return PerformanceResourceTimingBinding::Wrap(aCx, this, aGivenProto); @@ -71,12 +101,10 @@ PerformanceResourceTiming::SizeOfIncludi return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } size_t PerformanceResourceTiming::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return PerformanceEntry::SizeOfExcludingThis(aMallocSizeOf) + mInitiatorType.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + - (mTimingData - ? mTimingData->NextHopProtocol().SizeOfExcludingThisIfUnshared(aMallocSizeOf) - : 0); + mNextHopProtocol.SizeOfExcludingThisIfUnshared(aMallocSizeOf); }
--- a/dom/performance/PerformanceResourceTiming.h +++ b/dom/performance/PerformanceResourceTiming.h @@ -2,18 +2,19 @@ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_PerformanceResourceTiming_h___ #define mozilla_dom_PerformanceResourceTiming_h___ -#include "mozilla/UniquePtr.h" #include "nsCOMPtr.h" +#include "nsIChannel.h" +#include "nsITimedChannel.h" #include "Performance.h" #include "PerformanceEntry.h" #include "PerformanceTiming.h" namespace mozilla { namespace dom { // http://www.w3.org/TR/resource-timing/#performanceresourcetiming @@ -22,19 +23,20 @@ class PerformanceResourceTiming : public public: typedef mozilla::TimeStamp TimeStamp; NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED( PerformanceResourceTiming, PerformanceEntry) - PerformanceResourceTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTimingData, + PerformanceResourceTiming(PerformanceTiming* aPerformanceTiming, Performance* aPerformance, - const nsAString& aName); + const nsAString& aName, + nsIHttpChannel* aChannel = nullptr); virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; virtual DOMHighResTimeStamp StartTime() const override; virtual DOMHighResTimeStamp Duration() const override { @@ -48,128 +50,150 @@ public: void SetInitiatorType(const nsAString& aInitiatorType) { mInitiatorType = aInitiatorType; } void GetNextHopProtocol(nsAString& aNextHopProtocol) const { - if (mTimingData) { - aNextHopProtocol = mTimingData->NextHopProtocol(); - } + aNextHopProtocol = mNextHopProtocol; + } + + void SetNextHopProtocol(const nsAString& aNextHopProtocol) + { + mNextHopProtocol = aNextHopProtocol; } DOMHighResTimeStamp WorkerStart() const { - return mTimingData - ? mTimingData->WorkerStartHighRes(mPerformance) + return mTiming + ? mTiming->WorkerStartHighRes() : 0; } DOMHighResTimeStamp FetchStart() const { - return mTimingData - ? mTimingData->FetchStartHighRes(mPerformance) + return mTiming + ? mTiming->FetchStartHighRes() : 0; } DOMHighResTimeStamp RedirectStart() const { // We have to check if all the redirect URIs had the same origin (since // there is no check in RedirectEndHighRes()) - return mTimingData && mTimingData->ShouldReportCrossOriginRedirect() - ? mTimingData->RedirectStartHighRes(mPerformance) + return mTiming && mTiming->ShouldReportCrossOriginRedirect() + ? mTiming->RedirectStartHighRes() : 0; } DOMHighResTimeStamp RedirectEnd() const { // We have to check if all the redirect URIs had the same origin (since // there is no check in RedirectEndHighRes()) - return mTimingData && mTimingData->ShouldReportCrossOriginRedirect() - ? mTimingData->RedirectEndHighRes(mPerformance) + return mTiming && mTiming->ShouldReportCrossOriginRedirect() + ? mTiming->RedirectEndHighRes() : 0; } DOMHighResTimeStamp DomainLookupStart() const { - return mTimingData && mTimingData->TimingAllowed() - ? mTimingData->DomainLookupStartHighRes(mPerformance) + return mTiming && mTiming->TimingAllowed() + ? mTiming->DomainLookupStartHighRes() : 0; } DOMHighResTimeStamp DomainLookupEnd() const { - return mTimingData && mTimingData->TimingAllowed() - ? mTimingData->DomainLookupEndHighRes(mPerformance) + return mTiming && mTiming->TimingAllowed() + ? mTiming->DomainLookupEndHighRes() : 0; } DOMHighResTimeStamp ConnectStart() const { - return mTimingData && mTimingData->TimingAllowed() - ? mTimingData->ConnectStartHighRes(mPerformance) + return mTiming && mTiming->TimingAllowed() + ? mTiming->ConnectStartHighRes() : 0; } DOMHighResTimeStamp ConnectEnd() const { - return mTimingData && mTimingData->TimingAllowed() - ? mTimingData->ConnectEndHighRes(mPerformance) + return mTiming && mTiming->TimingAllowed() + ? mTiming->ConnectEndHighRes() : 0; } DOMHighResTimeStamp RequestStart() const { - return mTimingData && mTimingData->TimingAllowed() - ? mTimingData->RequestStartHighRes(mPerformance) + return mTiming && mTiming->TimingAllowed() + ? mTiming->RequestStartHighRes() : 0; } DOMHighResTimeStamp ResponseStart() const { - return mTimingData && mTimingData->TimingAllowed() - ? mTimingData->ResponseStartHighRes(mPerformance) + return mTiming && mTiming->TimingAllowed() + ? mTiming->ResponseStartHighRes() : 0; } DOMHighResTimeStamp ResponseEnd() const { - return mTimingData - ? mTimingData->ResponseEndHighRes(mPerformance) + return mTiming + ? mTiming->ResponseEndHighRes() : 0; } DOMHighResTimeStamp SecureConnectionStart() const { - return mTimingData && mTimingData->TimingAllowed() - ? mTimingData->SecureConnectionStartHighRes(mPerformance) + return mTiming && mTiming->TimingAllowed() + ? mTiming->SecureConnectionStartHighRes() : 0; } virtual const PerformanceResourceTiming* ToResourceTiming() const override { return this; } uint64_t TransferSize() const { - return mTimingData ? mTimingData->TransferSize() : 0; + return mTiming && mTiming->TimingAllowed() ? mTransferSize : 0; } uint64_t EncodedBodySize() const { - return mTimingData ? mTimingData->EncodedBodySize() : 0; + return mTiming && mTiming->TimingAllowed() ? mEncodedBodySize : 0; } uint64_t DecodedBodySize() const { - return mTimingData ? mTimingData->DecodedBodySize() : 0; + return mTiming && mTiming->TimingAllowed() ? mDecodedBodySize : 0; + } + + void SetEncodedBodySize(uint64_t aEncodedBodySize) + { + mEncodedBodySize = aEncodedBodySize; + } + + void SetTransferSize(uint64_t aTransferSize) + { + mTransferSize = aTransferSize; + } + + void SetDecodedBodySize(uint64_t aDecodedBodySize) + { + mDecodedBodySize = aDecodedBodySize; } size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override; protected: virtual ~PerformanceResourceTiming(); + void SetPropertiesFromChannel(nsIHttpChannel* aChannel); size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override; nsString mInitiatorType; - UniquePtr<PerformanceTimingData> mTimingData; - RefPtr<Performance> mPerformance; + nsString mNextHopProtocol; + RefPtr<PerformanceTiming> mTiming; + uint64_t mEncodedBodySize; + uint64_t mTransferSize; + uint64_t mDecodedBodySize; }; } // namespace dom } // namespace mozilla #endif /* mozilla_dom_PerformanceResourceTiming_h___ */
deleted file mode 100644 --- a/dom/performance/PerformanceStorage.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_PerformanceStorage_h -#define mozilla_dom_PerformanceStorage_h - -#include "nsISupportsImpl.h" - -class nsIHttpChannel; -class nsITimedChannel; - -namespace mozilla { -namespace dom { - -class PerformanceTimingData; - -class PerformanceStorage -{ -public: - NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING - - virtual void AddEntry(nsIHttpChannel* aChannel, - nsITimedChannel* aTimedChannel) = 0; - -protected: - virtual ~PerformanceStorage() {} -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_PerformanceStorage_h
deleted file mode 100644 --- a/dom/performance/PerformanceStorageWorker.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "PerformanceStorageWorker.h" -#include "WorkerPrivate.h" -#include "WorkerHolder.h" - -namespace mozilla { -namespace dom { - -using namespace workers; - -class PerformanceProxyData -{ -public: - PerformanceProxyData(UniquePtr<PerformanceTimingData>&& aData, - const nsAString& aInitiatorType, - const nsAString& aEntryName) - : mData(Move(aData)) - , mInitiatorType(aInitiatorType) - , mEntryName(aEntryName) - {} - - UniquePtr<PerformanceTimingData> mData; - nsString mInitiatorType; - nsString mEntryName; -}; - -namespace { - -// This runnable calls InitializeOnWorker() on the worker thread. Here a -// workerHolder is used to monitor when the worker thread is starting the -// shutdown procedure. -// Here we use control runnable because this code must be executed also when in -// a sync event loop. -class PerformanceStorageInitializer final : public WorkerControlRunnable -{ - RefPtr<PerformanceStorageWorker> mStorage; - -public: - PerformanceStorageInitializer(WorkerPrivate* aWorkerPrivate, - PerformanceStorageWorker* aStorage) - : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount) - , mStorage(aStorage) - {} - - bool - WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override - { - mStorage->InitializeOnWorker(); - return true; - } - - nsresult - Cancel() override - { - mStorage->ShutdownOnWorker(); - return WorkerRunnable::Cancel(); - } - - bool - PreDispatch(WorkerPrivate* aWorkerPrivate) override - { - return true; - } - - void - PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override - {} -}; - -// Here we use control runnable because this code must be executed also when in -// a sync event loop -class PerformanceEntryAdder final : public WorkerControlRunnable -{ -public: - PerformanceEntryAdder(WorkerPrivate* aWorkerPrivate, - PerformanceStorageWorker* aStorage, - UniquePtr<PerformanceProxyData>&& aData) - : WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount) - , mStorage(aStorage) - , mData(Move(aData)) - {} - - bool - WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override - { - mStorage->AddEntryOnWorker(Move(mData)); - return true; - } - - nsresult - Cancel() override - { - mStorage->ShutdownOnWorker(); - return WorkerRunnable::Cancel(); - } - - bool - PreDispatch(WorkerPrivate* aWorkerPrivate) override - { - return true; - } - - void - PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override - {} - -private: - RefPtr<PerformanceStorageWorker> mStorage; - UniquePtr<PerformanceProxyData> mData; -}; - -class PerformanceStorageWorkerHolder final : public WorkerHolder -{ - RefPtr<PerformanceStorageWorker> mStorage; - -public: - explicit PerformanceStorageWorkerHolder(PerformanceStorageWorker* aStorage) - : WorkerHolder("PerformanceStorageWorkerHolder", - WorkerHolder::AllowIdleShutdownStart) - , mStorage(aStorage) - {} - - bool - Notify(Status aStatus) override - { - if (mStorage) { - RefPtr<PerformanceStorageWorker> storage; - storage.swap(mStorage); - storage->ShutdownOnWorker(); - } - - return true; - } -}; - -} // anonymous - -/* static */ already_AddRefed<PerformanceStorageWorker> -PerformanceStorageWorker::Create(WorkerPrivate* aWorkerPrivate) -{ - MOZ_ASSERT(NS_IsMainThread()); - - RefPtr<PerformanceStorageWorker> storage = - new PerformanceStorageWorker(aWorkerPrivate); - - RefPtr<PerformanceStorageInitializer> r = - new PerformanceStorageInitializer(aWorkerPrivate, storage); - if (NS_WARN_IF(!r->Dispatch())) { - return nullptr; - } - - return storage.forget(); -} - -PerformanceStorageWorker::PerformanceStorageWorker(WorkerPrivate* aWorkerPrivate) - : mMutex("PerformanceStorageWorker::mMutex") - , mWorkerPrivate(aWorkerPrivate) - , mState(eInitializing) -{ -} - -PerformanceStorageWorker::~PerformanceStorageWorker() = default; - -void -PerformanceStorageWorker::AddEntry(nsIHttpChannel* aChannel, - nsITimedChannel* aTimedChannel) -{ - MOZ_ASSERT(NS_IsMainThread()); - - MutexAutoLock lock(mMutex); - - if (mState == eTerminated) { - return; - } - - nsAutoString initiatorType; - nsAutoString entryName; - - UniquePtr<PerformanceTimingData> performanceTimingData( - PerformanceTimingData::Create(aTimedChannel, aChannel, 0, initiatorType, - entryName)); - if (!performanceTimingData) { - return; - } - - UniquePtr<PerformanceProxyData> data( - new PerformanceProxyData(Move(performanceTimingData), initiatorType, - entryName)); - - RefPtr<PerformanceEntryAdder> r = - new PerformanceEntryAdder(mWorkerPrivate, this, Move(data)); - Unused << NS_WARN_IF(!r->Dispatch()); -} - -void -PerformanceStorageWorker::InitializeOnWorker() -{ - MutexAutoLock lock(mMutex); - MOZ_ASSERT(mState == eInitializing); - MOZ_ASSERT(mWorkerPrivate); - mWorkerPrivate->AssertIsOnWorkerThread(); - - mWorkerHolder.reset(new PerformanceStorageWorkerHolder(this)); - if (!mWorkerHolder->HoldWorker(mWorkerPrivate, Canceling)) { - MutexAutoUnlock lock(mMutex); - ShutdownOnWorker(); - return; - } - - // We are ready to accept entries. - mState = eReady; -} - -void -PerformanceStorageWorker::ShutdownOnWorker() -{ - MutexAutoLock lock(mMutex); - - if (mState == eTerminated) { - return; - } - - MOZ_ASSERT(mWorkerPrivate); - mWorkerPrivate->AssertIsOnWorkerThread(); - - mState = eTerminated; - mWorkerHolder = nullptr; - mWorkerPrivate = nullptr; -} - -void -PerformanceStorageWorker::AddEntryOnWorker(UniquePtr<PerformanceProxyData>&& aData) -{ - RefPtr<Performance> performance; - UniquePtr<PerformanceProxyData> data = Move(aData); - - { - MutexAutoLock lock(mMutex); - - if (mState == eTerminated) { - return; - } - - MOZ_ASSERT(mWorkerPrivate); - mWorkerPrivate->AssertIsOnWorkerThread(); - - MOZ_ASSERT(mState == eReady); - - WorkerGlobalScope* scope = mWorkerPrivate->GlobalScope(); - performance = scope->GetPerformance(); - } - - if (NS_WARN_IF(!performance)) { - return; - } - - RefPtr<PerformanceResourceTiming> performanceEntry = - new PerformanceResourceTiming(Move(data->mData), performance, - data->mEntryName); - performanceEntry->SetInitiatorType(data->mInitiatorType); - - performance->InsertResourceEntry(performanceEntry); -} - -} // namespace dom -} // namespace mozilla
deleted file mode 100644 --- a/dom/performance/PerformanceStorageWorker.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_PerformanceStorageWorker_h -#define mozilla_dom_PerformanceStorageWorker_h - -#include "PerformanceStorage.h" - -namespace mozilla { -namespace dom { - -namespace workers { -class WorkerHolder; -class WorkerPrivate; -} - -class PerformanceProxyData; - -class PerformanceStorageWorker final : public PerformanceStorage -{ -public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PerformanceStorageWorker, override) - - static already_AddRefed<PerformanceStorageWorker> - Create(workers::WorkerPrivate* aWorkerPrivate); - - void InitializeOnWorker(); - - void ShutdownOnWorker(); - - void AddEntry(nsIHttpChannel* aChannel, - nsITimedChannel* aTimedChannel) override; - - void AddEntryOnWorker(UniquePtr<PerformanceProxyData>&& aData); - -private: - explicit PerformanceStorageWorker(workers::WorkerPrivate* aWorkerPrivate); - ~PerformanceStorageWorker(); - - Mutex mMutex; - - // Protected by mutex. - // This raw pointer is nullified when the WorkerHolder communicates the - // shutting down of the worker thread. - workers::WorkerPrivate* mWorkerPrivate; - - // Protected by mutex. - enum { - eInitializing, - eReady, - eTerminated, - } mState; - - // Touched on worker-thread only. - UniquePtr<WorkerHolder> mWorkerHolder; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_PerformanceStorageWorker_h
--- a/dom/performance/PerformanceTiming.cpp +++ b/dom/performance/PerformanceTiming.cpp @@ -15,132 +15,82 @@ namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(PerformanceTiming, mPerformance) NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PerformanceTiming, AddRef) NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PerformanceTiming, Release) -/* static */ PerformanceTimingData* -PerformanceTimingData::Create(nsITimedChannel* aTimedChannel, - nsIHttpChannel* aChannel, - DOMHighResTimeStamp aZeroTime, - nsAString& aInitiatorType, - nsAString& aEntryName) -{ - MOZ_ASSERT(NS_IsMainThread()); - - // Check if resource timing is prefed off. - if (!nsContentUtils::IsResourceTimingEnabled()) { - return nullptr; - } - - if (!aChannel || !aTimedChannel) { - return nullptr; - } - - bool reportTiming = true; - aTimedChannel->GetReportResourceTiming(&reportTiming); - - if (!reportTiming) { - return nullptr; - } - - aTimedChannel->GetInitiatorType(aInitiatorType); - - // If the initiator type had no valid value, then set it to the default - // ("other") value. - if (aInitiatorType.IsEmpty()) { - aInitiatorType = NS_LITERAL_STRING("other"); - } - - // According to the spec, "The name attribute must return the resolved URL - // of the requested resource. This attribute must not change even if the - // fetch redirected to a different URL." - nsCOMPtr<nsIURI> originalURI; - aChannel->GetOriginalURI(getter_AddRefs(originalURI)); - - nsAutoCString name; - originalURI->GetSpec(name); - aEntryName = NS_ConvertUTF8toUTF16(name); - - // The nsITimedChannel argument will be used to gather all the timings. - // The nsIHttpChannel argument will be used to check if any cross-origin - // redirects occurred. - // The last argument is the "zero time" (offset). Since we don't want - // any offset for the resource timing, this will be set to "0" - the - // resource timing returns a relative timing (no offset). - return new PerformanceTimingData(aTimedChannel, aChannel, 0); -} - PerformanceTiming::PerformanceTiming(Performance* aPerformance, nsITimedChannel* aChannel, nsIHttpChannel* aHttpChannel, DOMHighResTimeStamp aZeroTime) - : mPerformance(aPerformance) + : mPerformance(aPerformance), + mFetchStart(0.0), + mZeroTime(nsRFPService::ReduceTimePrecisionAsMSecs(aZeroTime)), + mRedirectCount(0), + mTimingAllowed(true), + mAllRedirectsSameOrigin(true), + mInitialized(!!aChannel), + mReportCrossOriginRedirect(true) { MOZ_ASSERT(aPerformance, "Parent performance object should be provided"); - mTimingData.reset(new PerformanceTimingData(aChannel, aHttpChannel, - aZeroTime)); - - // Non-null aHttpChannel implies that this PerformanceTiming object is being - // used for subresources, which is irrelevant to this probe. - if (!aHttpChannel && - nsContentUtils::IsPerformanceTimingEnabled() && - IsTopLevelContentDocument()) { - Telemetry::Accumulate(Telemetry::TIME_TO_RESPONSE_START_MS, - mTimingData->ResponseStartHighRes(aPerformance) - - mTimingData->ZeroTime()); - } -} - -// Copy the timing info from the channel so we don't need to keep the channel -// alive just to get the timestamps. -PerformanceTimingData::PerformanceTimingData(nsITimedChannel* aChannel, - nsIHttpChannel* aHttpChannel, - DOMHighResTimeStamp aZeroTime) - : mZeroTime(0.0) - , mFetchStart(0.0) - , mEncodedBodySize(0) - , mTransferSize(0) - , mDecodedBodySize(0) - , mRedirectCount(0) - , mAllRedirectsSameOrigin(true) - , mReportCrossOriginRedirect(true) - , mSecureConnection(false) - , mTimingAllowed(true) - , mInitialized(false) -{ - mInitialized = !!aChannel; - - mZeroTime = nsRFPService::ReduceTimePrecisionAsMSecs(aZeroTime); if (!nsContentUtils::IsPerformanceTimingEnabled() || nsContentUtils::ShouldResistFingerprinting()) { mZeroTime = 0; } + // The aHttpChannel argument is null if this PerformanceTiming object is + // being used for navigation timing (which is only relevant for documents). + // It has a non-null value if this PerformanceTiming object is being used + // for resource timing, which can include document loads, both toplevel and + // in subframes, and resources linked from a document. + if (aHttpChannel) { + mTimingAllowed = CheckAllowedOrigin(aHttpChannel, aChannel); + bool redirectsPassCheck = false; + aChannel->GetAllRedirectsPassTimingAllowCheck(&redirectsPassCheck); + mReportCrossOriginRedirect = mTimingAllowed && redirectsPassCheck; + } + + mSecureConnection = false; nsCOMPtr<nsIURI> uri; if (aHttpChannel) { aHttpChannel->GetURI(getter_AddRefs(uri)); } else { nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel); if (httpChannel) { httpChannel->GetURI(getter_AddRefs(uri)); } } if (uri) { nsresult rv = uri->SchemeIs("https", &mSecureConnection); if (NS_FAILED(rv)) { mSecureConnection = false; } } + InitializeTimingInfo(aChannel); + // Non-null aHttpChannel implies that this PerformanceTiming object is being + // used for subresources, which is irrelevant to this probe. + if (!aHttpChannel && + nsContentUtils::IsPerformanceTimingEnabled() && + IsTopLevelContentDocument()) { + Telemetry::Accumulate(Telemetry::TIME_TO_RESPONSE_START_MS, + ResponseStartHighRes() - mZeroTime); + } +} + +// Copy the timing info from the channel so we don't need to keep the channel +// alive just to get the timestamps. +void +PerformanceTiming::InitializeTimingInfo(nsITimedChannel* aChannel) +{ if (aChannel) { aChannel->GetAsyncOpen(&mAsyncOpen); aChannel->GetAllRedirectsSameOrigin(&mAllRedirectsSameOrigin); aChannel->GetRedirectCount(&mRedirectCount); aChannel->GetRedirectStart(&mRedirectStart); aChannel->GetRedirectEnd(&mRedirectEnd); aChannel->GetDomainLookupStart(&mDomainLookupStart); aChannel->GetDomainLookupEnd(&mDomainLookupEnd); @@ -155,21 +105,21 @@ PerformanceTimingData::PerformanceTiming aChannel->GetDispatchFetchEventStart(&mWorkerStart); aChannel->GetHandleFetchEventStart(&mWorkerRequestStart); // TODO: Track when FetchEvent.respondWith() promise resolves as // ServiceWorker interception responseStart? aChannel->GetHandleFetchEventEnd(&mWorkerResponseEnd); // The performance timing api essentially requires that the event timestamps - // have a strict relation with each other. The truth, however, is the - // browser engages in a number of speculative activities that sometimes mean - // connections and lookups begin at different times. Workaround that here by - // clamping these values to what we expect FetchStart to be. This means the - // later of AsyncOpen or WorkerStart times. + // have a strict relation with each other. The truth, however, is the browser + // engages in a number of speculative activities that sometimes mean connections + // and lookups begin at different times. Workaround that here by clamping + // these values to what we expect FetchStart to be. This means the later of + // AsyncOpen or WorkerStart times. if (!mAsyncOpen.IsNull()) { // We want to clamp to the expected FetchStart value. This is later of // the AsyncOpen and WorkerStart values. const TimeStamp* clampTime = &mAsyncOpen; if (!mWorkerStart.IsNull() && mWorkerStart > mAsyncOpen) { clampTime = &mWorkerStart; } @@ -190,85 +140,52 @@ PerformanceTimingData::PerformanceTiming mSecureConnectionStart = *clampTime; } if (!mConnectEnd.IsNull() && mConnectEnd < *clampTime) { mConnectEnd = *clampTime; } } } - - // The aHttpChannel argument is null if this PerformanceTiming object is - // being used for navigation timing (which is only relevant for documents). - // It has a non-null value if this PerformanceTiming object is being used - // for resource timing, which can include document loads, both toplevel and - // in subframes, and resources linked from a document. - if (aHttpChannel) { - mTimingAllowed = CheckAllowedOrigin(aHttpChannel, aChannel); - bool redirectsPassCheck = false; - aChannel->GetAllRedirectsPassTimingAllowCheck(&redirectsPassCheck); - mReportCrossOriginRedirect = mTimingAllowed && redirectsPassCheck; - - SetPropertiesFromHttpChannel(aHttpChannel); - } -} - -void -PerformanceTimingData::SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel) -{ - MOZ_ASSERT(aHttpChannel); - - nsAutoCString protocol; - Unused << aHttpChannel->GetProtocolVersion(protocol); - mNextHopProtocol = NS_ConvertUTF8toUTF16(protocol); - - Unused << aHttpChannel->GetEncodedBodySize(&mEncodedBodySize); - Unused << aHttpChannel->GetTransferSize(&mTransferSize); - Unused << aHttpChannel->GetDecodedBodySize(&mDecodedBodySize); - if (mDecodedBodySize == 0) { - mDecodedBodySize = mEncodedBodySize; - } } PerformanceTiming::~PerformanceTiming() { } DOMHighResTimeStamp -PerformanceTimingData::FetchStartHighRes(Performance* aPerformance) +PerformanceTiming::FetchStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!mFetchStart) { if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } MOZ_ASSERT(!mAsyncOpen.IsNull(), "The fetch start time stamp should always be " "valid if the performance timing is enabled"); if (!mAsyncOpen.IsNull()) { if (!mWorkerRequestStart.IsNull() && mWorkerRequestStart > mAsyncOpen) { - mFetchStart = TimeStampToDOMHighRes(aPerformance, mWorkerRequestStart); + mFetchStart = TimeStampToDOMHighRes(mWorkerRequestStart); } else { - mFetchStart = TimeStampToDOMHighRes(aPerformance, mAsyncOpen); + mFetchStart = TimeStampToDOMHighRes(mAsyncOpen); } } } return nsRFPService::ReduceTimePrecisionAsMSecs(mFetchStart); } DOMTimeMilliSec PerformanceTiming::FetchStart() { - return static_cast<int64_t>(mTimingData->FetchStartHighRes(mPerformance)); + return static_cast<int64_t>(FetchStartHighRes()); } bool -PerformanceTimingData::CheckAllowedOrigin(nsIHttpChannel* aResourceChannel, - nsITimedChannel* aChannel) +PerformanceTiming::CheckAllowedOrigin(nsIHttpChannel* aResourceChannel, + nsITimedChannel* aChannel) { if (!IsInitialized()) { return false; } // Check that the current document passes the ckeck. nsCOMPtr<nsILoadInfo> loadInfo; aResourceChannel->GetLoadInfo(getter_AddRefs(loadInfo)); @@ -286,328 +203,306 @@ PerformanceTimingData::CheckAllowedOrigi nsCOMPtr<nsIPrincipal> principal = loadInfo->LoadingPrincipal(); // Check if the resource is either same origin as the page that started // the load, or if the response contains the proper Timing-Allow-Origin // header with the domain of the page that started the load. return aChannel->TimingAllowCheck(principal); } +bool +PerformanceTiming::TimingAllowed() const +{ + return mTimingAllowed; +} + uint8_t -PerformanceTimingData::GetRedirectCount() const +PerformanceTiming::GetRedirectCount() const { if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return 0; } if (!mAllRedirectsSameOrigin) { return 0; } return mRedirectCount; } bool -PerformanceTimingData::ShouldReportCrossOriginRedirect() const +PerformanceTiming::ShouldReportCrossOriginRedirect() const { if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return false; } // If the redirect count is 0, or if one of the cross-origin // redirects doesn't have the proper Timing-Allow-Origin header, // then RedirectStart and RedirectEnd will be set to zero return (mRedirectCount != 0) && mReportCrossOriginRedirect; } DOMHighResTimeStamp -PerformanceTimingData::AsyncOpenHighRes(Performance* aPerformance) +PerformanceTiming::AsyncOpenHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting() || mAsyncOpen.IsNull()) { return mZeroTime; } - return nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, mAsyncOpen)); + return nsRFPService::ReduceTimePrecisionAsMSecs(TimeStampToDOMHighRes(mAsyncOpen)); } DOMHighResTimeStamp -PerformanceTimingData::WorkerStartHighRes(Performance* aPerformance) +PerformanceTiming::WorkerStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting() || mWorkerStart.IsNull()) { return mZeroTime; } - return nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, mWorkerStart)); + return nsRFPService::ReduceTimePrecisionAsMSecs(TimeStampToDOMHighRes(mWorkerStart)); } /** * RedirectStartHighRes() is used by both the navigation timing and the * resource timing. Since, navigation timing and resource timing check and * interpret cross-domain redirects in a different manner, * RedirectStartHighRes() will make no checks for cross-domain redirect. * It's up to the consumers of this method (PerformanceTiming::RedirectStart() * and PerformanceResourceTiming::RedirectStart() to make such verifications. * * @return a valid timing if the Performance Timing is enabled */ DOMHighResTimeStamp -PerformanceTimingData::RedirectStartHighRes(Performance* aPerformance) +PerformanceTiming::RedirectStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } - return TimeStampToReducedDOMHighResOrFetchStart(aPerformance, mRedirectStart); + return TimeStampToReducedDOMHighResOrFetchStart(mRedirectStart); } DOMTimeMilliSec PerformanceTiming::RedirectStart() { - if (!mTimingData->IsInitialized()) { + if (!IsInitialized()) { return 0; } // We have to check if all the redirect URIs had the same origin (since there // is no check in RedirectStartHighRes()) - if (mTimingData->AllRedirectsSameOrigin() && - mTimingData->RedirectCountReal()) { - return static_cast<int64_t>(mTimingData->RedirectStartHighRes(mPerformance)); + if (mAllRedirectsSameOrigin && mRedirectCount) { + return static_cast<int64_t>(RedirectStartHighRes()); } return 0; } /** * RedirectEndHighRes() is used by both the navigation timing and the resource * timing. Since, navigation timing and resource timing check and interpret * cross-domain redirects in a different manner, RedirectEndHighRes() will make * no checks for cross-domain redirect. It's up to the consumers of this method * (PerformanceTiming::RedirectEnd() and * PerformanceResourceTiming::RedirectEnd() to make such verifications. * * @return a valid timing if the Performance Timing is enabled */ DOMHighResTimeStamp -PerformanceTimingData::RedirectEndHighRes(Performance* aPerformance) +PerformanceTiming::RedirectEndHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } - return TimeStampToReducedDOMHighResOrFetchStart(aPerformance, mRedirectEnd); + return TimeStampToReducedDOMHighResOrFetchStart(mRedirectEnd); } DOMTimeMilliSec PerformanceTiming::RedirectEnd() { - if (!mTimingData->IsInitialized()) { + if (!IsInitialized()) { return 0; } // We have to check if all the redirect URIs had the same origin (since there // is no check in RedirectEndHighRes()) - if (mTimingData->AllRedirectsSameOrigin() && - mTimingData->RedirectCountReal()) { - return static_cast<int64_t>(mTimingData->RedirectEndHighRes(mPerformance)); + if (mAllRedirectsSameOrigin && mRedirectCount) { + return static_cast<int64_t>(RedirectEndHighRes()); } return 0; } DOMHighResTimeStamp -PerformanceTimingData::DomainLookupStartHighRes(Performance* aPerformance) +PerformanceTiming::DomainLookupStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } - return TimeStampToReducedDOMHighResOrFetchStart(aPerformance, - mDomainLookupStart); + return TimeStampToReducedDOMHighResOrFetchStart(mDomainLookupStart); } DOMTimeMilliSec PerformanceTiming::DomainLookupStart() { - return static_cast<int64_t>(mTimingData->DomainLookupStartHighRes(mPerformance)); + return static_cast<int64_t>(DomainLookupStartHighRes()); } DOMHighResTimeStamp -PerformanceTimingData::DomainLookupEndHighRes(Performance* aPerformance) +PerformanceTiming::DomainLookupEndHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } // Bug 1155008 - nsHttpTransaction is racy. Return DomainLookupStart when null - return mDomainLookupEnd.IsNull() - ? DomainLookupStartHighRes(aPerformance) - : nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, mDomainLookupEnd)); + return mDomainLookupEnd.IsNull() ? DomainLookupStartHighRes() + : nsRFPService::ReduceTimePrecisionAsMSecs( + TimeStampToDOMHighRes(mDomainLookupEnd)); } DOMTimeMilliSec PerformanceTiming::DomainLookupEnd() { - return static_cast<int64_t>(mTimingData->DomainLookupEndHighRes(mPerformance)); + return static_cast<int64_t>(DomainLookupEndHighRes()); } DOMHighResTimeStamp -PerformanceTimingData::ConnectStartHighRes(Performance* aPerformance) +PerformanceTiming::ConnectStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } - return mConnectStart.IsNull() - ? DomainLookupEndHighRes(aPerformance) - : nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, mConnectStart)); + return mConnectStart.IsNull() ? DomainLookupEndHighRes() + : nsRFPService::ReduceTimePrecisionAsMSecs( + TimeStampToDOMHighRes(mConnectStart)); } DOMTimeMilliSec PerformanceTiming::ConnectStart() { - return static_cast<int64_t>(mTimingData->ConnectStartHighRes(mPerformance)); + return static_cast<int64_t>(ConnectStartHighRes()); } DOMHighResTimeStamp -PerformanceTimingData::SecureConnectionStartHighRes(Performance* aPerformance) +PerformanceTiming::SecureConnectionStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } return !mSecureConnection ? 0 // We use 0 here, because mZeroTime is sometimes set to the navigation // start time. - : (mSecureConnectionStart.IsNull() - ? mZeroTime - : nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, mSecureConnectionStart))); + : (mSecureConnectionStart.IsNull() ? mZeroTime + : nsRFPService::ReduceTimePrecisionAsMSecs( + TimeStampToDOMHighRes(mSecureConnectionStart))); } DOMTimeMilliSec PerformanceTiming::SecureConnectionStart() { - return static_cast<int64_t>(mTimingData->SecureConnectionStartHighRes(mPerformance)); + return static_cast<int64_t>(SecureConnectionStartHighRes()); } DOMHighResTimeStamp -PerformanceTimingData::ConnectEndHighRes(Performance* aPerformance) +PerformanceTiming::ConnectEndHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } // Bug 1155008 - nsHttpTransaction is racy. Return ConnectStart when null - return mConnectEnd.IsNull() - ? ConnectStartHighRes(aPerformance) - : nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, mConnectEnd)); + return mConnectEnd.IsNull() ? ConnectStartHighRes() + : nsRFPService::ReduceTimePrecisionAsMSecs( + TimeStampToDOMHighRes(mConnectEnd)); } DOMTimeMilliSec PerformanceTiming::ConnectEnd() { - return static_cast<int64_t>(mTimingData->ConnectEndHighRes(mPerformance)); + return static_cast<int64_t>(ConnectEndHighRes()); } DOMHighResTimeStamp -PerformanceTimingData::RequestStartHighRes(Performance* aPerformance) +PerformanceTiming::RequestStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } if (mRequestStart.IsNull()) { mRequestStart = mWorkerRequestStart; } - return TimeStampToReducedDOMHighResOrFetchStart(aPerformance, mRequestStart); + return TimeStampToReducedDOMHighResOrFetchStart(mRequestStart); } DOMTimeMilliSec PerformanceTiming::RequestStart() { - return static_cast<int64_t>(mTimingData->RequestStartHighRes(mPerformance)); + return static_cast<int64_t>(RequestStartHighRes()); } DOMHighResTimeStamp -PerformanceTimingData::ResponseStartHighRes(Performance* aPerformance) +PerformanceTiming::ResponseStartHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } if (mResponseStart.IsNull() || (!mCacheReadStart.IsNull() && mCacheReadStart < mResponseStart)) { mResponseStart = mCacheReadStart; } if (mResponseStart.IsNull() || (!mRequestStart.IsNull() && mResponseStart < mRequestStart)) { mResponseStart = mRequestStart; } - return TimeStampToReducedDOMHighResOrFetchStart(aPerformance, mResponseStart); + return TimeStampToReducedDOMHighResOrFetchStart(mResponseStart); } DOMTimeMilliSec PerformanceTiming::ResponseStart() { - return static_cast<int64_t>(mTimingData->ResponseStartHighRes(mPerformance)); + return static_cast<int64_t>(ResponseStartHighRes()); } DOMHighResTimeStamp -PerformanceTimingData::ResponseEndHighRes(Performance* aPerformance) +PerformanceTiming::ResponseEndHighRes() { - MOZ_ASSERT(aPerformance); - if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() || nsContentUtils::ShouldResistFingerprinting()) { return mZeroTime; } if (mResponseEnd.IsNull() || (!mCacheReadEnd.IsNull() && mCacheReadEnd < mResponseEnd)) { mResponseEnd = mCacheReadEnd; } if (mResponseEnd.IsNull()) { mResponseEnd = mWorkerResponseEnd; } // Bug 1155008 - nsHttpTransaction is racy. Return ResponseStart when null - return mResponseEnd.IsNull() - ? ResponseStartHighRes(aPerformance) - : nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, mResponseEnd)); + return mResponseEnd.IsNull() ? ResponseStartHighRes() + : nsRFPService::ReduceTimePrecisionAsMSecs( + TimeStampToDOMHighRes(mResponseEnd)); } DOMTimeMilliSec PerformanceTiming::ResponseEnd() { - return static_cast<int64_t>(mTimingData->ResponseEndHighRes(mPerformance)); + return static_cast<int64_t>(ResponseEndHighRes()); +} + +bool +PerformanceTiming::IsInitialized() const +{ + return mInitialized; } JSObject* PerformanceTiming::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) { return PerformanceTimingBinding::Wrap(cx, this, aGivenProto); }
--- a/dom/performance/PerformanceTiming.h +++ b/dom/performance/PerformanceTiming.h @@ -15,214 +15,16 @@ #include "Performance.h" class nsIHttpChannel; class nsITimedChannel; namespace mozilla { namespace dom { -class PerformanceTiming; - -class PerformanceTimingData final -{ - friend class PerformanceTiming; - -public: - // This can return null. - static PerformanceTimingData* - Create(nsITimedChannel* aChannel, - nsIHttpChannel* aHttpChannel, - DOMHighResTimeStamp aZeroTime, - nsAString& aInitiatorType, - nsAString& aEntryName); - - PerformanceTimingData(nsITimedChannel* aChannel, - nsIHttpChannel* aHttpChannel, - DOMHighResTimeStamp aZeroTime); - - void - SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel); - - bool IsInitialized() const - { - return mInitialized; - } - - const nsString& NextHopProtocol() const - { - return mNextHopProtocol; - } - - uint64_t TransferSize() const - { - return mTimingAllowed ? mTransferSize : 0; - } - - uint64_t EncodedBodySize() const - { - return mTimingAllowed ? mEncodedBodySize : 0; - } - - uint64_t DecodedBodySize() const - { - return mTimingAllowed ? mDecodedBodySize : 0; - } - - /** - * @param aStamp - * The TimeStamp recorded for a specific event. This TimeStamp can - * be null. - * @return the duration of an event with a given TimeStamp, relative to the - * navigationStart TimeStamp (the moment the user landed on the - * page), if the given TimeStamp is valid. Otherwise, it will return - * the FetchStart timing value. - */ - inline DOMHighResTimeStamp - TimeStampToReducedDOMHighResOrFetchStart(Performance* aPerformance, - TimeStamp aStamp) - { - MOZ_ASSERT(aPerformance); - - return (!aStamp.IsNull()) - ? nsRFPService::ReduceTimePrecisionAsMSecs( - TimeStampToDOMHighRes(aPerformance, aStamp)) - : FetchStartHighRes(aPerformance); - } - - /** - * The nsITimedChannel records an absolute timestamp for each event. - * The nsDOMNavigationTiming will record the moment when the user landed on - * the page. This is a window.performance unique timestamp, so it can be used - * for all the events (navigation timing and resource timing events). - * - * The algorithm operates in 2 steps: - * 1. The first step is to subtract the two timestamps: the argument (the - * event's timestamp) and the navigation start timestamp. This will result in - * a relative timestamp of the event (relative to the navigation start - - * window.performance.timing.navigationStart). - * 2. The second step is to add any required offset (the mZeroTime). For now, - * this offset value is either 0 (for the resource timing), or equal to - * "performance.navigationStart" (for navigation timing). - * For the resource timing, mZeroTime is set to 0, causing the result to be a - * relative time. - * For the navigation timing, mZeroTime is set to "performance.navigationStart" - * causing the result be an absolute time. - * - * @param aStamp - * The TimeStamp recorded for a specific event. This TimeStamp can't - * be null. - * @return number of milliseconds value as one of: - * - relative to the navigation start time, time the user has landed on the - * page - * - an absolute wall clock time since the unix epoch - */ - inline DOMHighResTimeStamp - TimeStampToDOMHighRes(Performance* aPerformance, TimeStamp aStamp) const - { - MOZ_ASSERT(aPerformance); - MOZ_ASSERT(!aStamp.IsNull()); - - TimeDuration duration = aStamp - aPerformance->CreationTimeStamp(); - return duration.ToMilliseconds() + mZeroTime; - } - - // The last channel's AsyncOpen time. This may occur before the FetchStart - // in some cases. - DOMHighResTimeStamp AsyncOpenHighRes(Performance* aPerformance); - - // High resolution (used by resource timing) - DOMHighResTimeStamp WorkerStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp FetchStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp RedirectStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp RedirectEndHighRes(Performance* aPerformance); - DOMHighResTimeStamp DomainLookupStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp DomainLookupEndHighRes(Performance* aPerformance); - DOMHighResTimeStamp ConnectStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp SecureConnectionStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp ConnectEndHighRes(Performance* aPerformance); - DOMHighResTimeStamp RequestStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp ResponseStartHighRes(Performance* aPerformance); - DOMHighResTimeStamp ResponseEndHighRes(Performance* aPerformance); - - DOMHighResTimeStamp ZeroTime() const { return mZeroTime; } - - uint8_t RedirectCountReal() const { return mRedirectCount; } - uint8_t GetRedirectCount() const; - - bool AllRedirectsSameOrigin() const { return mAllRedirectsSameOrigin; } - - // If this is false the values of redirectStart/End will be 0 This is false if - // no redirects occured, or if any of the responses failed the - // timing-allow-origin check in HttpBaseChannel::TimingAllowCheck - bool ShouldReportCrossOriginRedirect() const; - - // Cached result of CheckAllowedOrigin. If false, security sensitive - // attributes of the resourceTiming object will be set to 0 - bool TimingAllowed() const - { - return mTimingAllowed; - } - -private: - // Checks if the resource is either same origin as the page that started - // the load, or if the response contains the Timing-Allow-Origin header - // with a value of * or matching the domain of the loading Principal - bool CheckAllowedOrigin(nsIHttpChannel* aResourceChannel, - nsITimedChannel* aChannel); - - nsString mNextHopProtocol; - - TimeStamp mAsyncOpen; - TimeStamp mRedirectStart; - TimeStamp mRedirectEnd; - TimeStamp mDomainLookupStart; - TimeStamp mDomainLookupEnd; - TimeStamp mConnectStart; - TimeStamp mSecureConnectionStart; - TimeStamp mConnectEnd; - TimeStamp mRequestStart; - TimeStamp mResponseStart; - TimeStamp mCacheReadStart; - TimeStamp mResponseEnd; - TimeStamp mCacheReadEnd; - - // ServiceWorker interception timing information - TimeStamp mWorkerStart; - TimeStamp mWorkerRequestStart; - TimeStamp mWorkerResponseEnd; - - // This is an offset that will be added to each timing ([ms] resolution). - // There are only 2 possible values: (1) logicaly equal to navigationStart - // TimeStamp (results are absolute timstamps - wallclock); (2) "0" (results - // are relative to the navigation start). - DOMHighResTimeStamp mZeroTime; - - DOMHighResTimeStamp mFetchStart; - - uint64_t mEncodedBodySize; - uint64_t mTransferSize; - uint64_t mDecodedBodySize; - - uint8_t mRedirectCount; - - bool mAllRedirectsSameOrigin; - - // If the resourceTiming object should have non-zero redirectStart and - // redirectEnd attributes. It is false if there were no redirects, or if any - // of the responses didn't pass the timing-allow-check - bool mReportCrossOriginRedirect; - - bool mSecureConnection; - - bool mTimingAllowed; - - bool mInitialized; -}; - // Script "performance.timing" object class PerformanceTiming final : public nsWrapperCache { public: /** * @param aPerformance * The performance object (the JS parent). * This will allow access to "window.performance.timing" attribute for @@ -253,16 +55,67 @@ public: return mPerformance->GetDOMTiming(); } Performance* GetParentObject() const { return mPerformance; } + /** + * @param aStamp + * The TimeStamp recorded for a specific event. This TimeStamp can + * be null. + * @return the duration of an event with a given TimeStamp, relative to the + * navigationStart TimeStamp (the moment the user landed on the + * page), if the given TimeStamp is valid. Otherwise, it will return + * the FetchStart timing value. + */ + inline DOMHighResTimeStamp TimeStampToReducedDOMHighResOrFetchStart(TimeStamp aStamp) + { + return (!aStamp.IsNull()) + ? nsRFPService::ReduceTimePrecisionAsMSecs(TimeStampToDOMHighRes(aStamp)) + : FetchStartHighRes(); + } + + /** + * The nsITimedChannel records an absolute timestamp for each event. + * The nsDOMNavigationTiming will record the moment when the user landed on + * the page. This is a window.performance unique timestamp, so it can be used + * for all the events (navigation timing and resource timing events). + * + * The algorithm operates in 2 steps: + * 1. The first step is to subtract the two timestamps: the argument (the + * envet's timesramp) and the navigation start timestamp. This will result in + * a relative timestamp of the event (relative to the navigation start - + * window.performance.timing.navigationStart). + * 2. The second step is to add any required offset (the mZeroTime). For now, + * this offset value is either 0 (for the resource timing), or equal to + * "performance.navigationStart" (for navigation timing). + * For the resource timing, mZeroTime is set to 0, causing the result to be a + * relative time. + * For the navigation timing, mZeroTime is set to "performance.navigationStart" + * causing the result be an absolute time. + * + * @param aStamp + * The TimeStamp recorded for a specific event. This TimeStamp can't + * be null. + * @return number of milliseconds value as one of: + * - relative to the navigation start time, time the user has landed on the + * page + * - an absolute wall clock time since the unix epoch + */ + inline DOMHighResTimeStamp TimeStampToDOMHighRes(TimeStamp aStamp) const + { + MOZ_ASSERT(!aStamp.IsNull()); + TimeDuration duration = + aStamp - GetDOMTiming()->GetNavigationStartTimeStamp(); + return duration.ToMilliseconds() + mZeroTime; + } + virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override; // PerformanceNavigation WebIDL methods DOMTimeMilliSec NavigationStart() const { if (!nsContentUtils::IsPerformanceTimingEnabled() || nsContentUtils::ShouldResistFingerprinting()) { @@ -287,16 +140,50 @@ public: if (!nsContentUtils::IsPerformanceTimingEnabled() || nsContentUtils::ShouldResistFingerprinting()) { return 0; } return nsRFPService::ReduceTimePrecisionAsMSecs( GetDOMTiming()->GetUnloadEventEnd()); } + uint8_t GetRedirectCount() const; + + // Checks if the resource is either same origin as the page that started + // the load, or if the response contains the Timing-Allow-Origin header + // with a value of * or matching the domain of the loading Principal + bool CheckAllowedOrigin(nsIHttpChannel* aResourceChannel, nsITimedChannel* aChannel); + + // Cached result of CheckAllowedOrigin. If false, security sensitive + // attributes of the resourceTiming object will be set to 0 + bool TimingAllowed() const; + + // If this is false the values of redirectStart/End will be 0 + // This is false if no redirects occured, or if any of the responses failed + // the timing-allow-origin check in HttpBaseChannel::TimingAllowCheck + bool ShouldReportCrossOriginRedirect() const; + + // The last channel's AsyncOpen time. This may occur before the FetchStart + // in some cases. + DOMHighResTimeStamp AsyncOpenHighRes(); + + // High resolution (used by resource timing) + DOMHighResTimeStamp WorkerStartHighRes(); + DOMHighResTimeStamp FetchStartHighRes(); + DOMHighResTimeStamp RedirectStartHighRes(); + DOMHighResTimeStamp RedirectEndHighRes(); + DOMHighResTimeStamp DomainLookupStartHighRes(); + DOMHighResTimeStamp DomainLookupEndHighRes(); + DOMHighResTimeStamp ConnectStartHighRes(); + DOMHighResTimeStamp SecureConnectionStartHighRes(); + DOMHighResTimeStamp ConnectEndHighRes(); + DOMHighResTimeStamp RequestStartHighRes(); + DOMHighResTimeStamp ResponseStartHighRes(); + DOMHighResTimeStamp ResponseEndHighRes(); + // Low resolution (used by navigation timing) DOMTimeMilliSec FetchStart(); DOMTimeMilliSec RedirectStart(); DOMTimeMilliSec RedirectEnd(); DOMTimeMilliSec DomainLookupStart(); DOMTimeMilliSec DomainLookupEnd(); DOMTimeMilliSec ConnectStart(); DOMTimeMilliSec SecureConnectionStart(); @@ -380,27 +267,61 @@ public: if (!nsContentUtils::IsPerformanceTimingEnabled() || nsContentUtils::ShouldResistFingerprinting()) { return 0; } return nsRFPService::ReduceTimePrecisionAsMSecs( GetDOMTiming()->GetTimeToNonBlankPaint()); } - PerformanceTimingData* Data() const - { - return mTimingData.get(); - } - private: ~PerformanceTiming(); + bool IsInitialized() const; + void InitializeTimingInfo(nsITimedChannel* aChannel); + bool IsTopLevelContentDocument() const; RefPtr<Performance> mPerformance; + DOMHighResTimeStamp mFetchStart; - UniquePtr<PerformanceTimingData> mTimingData; + // This is an offset that will be added to each timing ([ms] resolution). + // There are only 2 possible values: (1) logicaly equal to navigationStart + // TimeStamp (results are absolute timstamps - wallclock); (2) "0" (results + // are relative to the navigation start). + DOMHighResTimeStamp mZeroTime; + + TimeStamp mAsyncOpen; + TimeStamp mRedirectStart; + TimeStamp mRedirectEnd; + TimeStamp mDomainLookupStart; + TimeStamp mDomainLookupEnd; + TimeStamp mConnectStart; + TimeStamp mSecureConnectionStart; + TimeStamp mConnectEnd; + TimeStamp mRequestStart; + TimeStamp mResponseStart; + TimeStamp mCacheReadStart; + TimeStamp mResponseEnd; + TimeStamp mCacheReadEnd; + + // ServiceWorker interception timing information + TimeStamp mWorkerStart; + TimeStamp mWorkerRequestStart; + TimeStamp mWorkerResponseEnd; + + uint8_t mRedirectCount; + bool mTimingAllowed; + bool mAllRedirectsSameOrigin; + bool mInitialized; + + // If the resourceTiming object should have non-zero redirectStart and + // redirectEnd attributes. It is false if there were no redirects, or if + // any of the responses didn't pass the timing-allow-check + bool mReportCrossOriginRedirect; + + bool mSecureConnection; }; } // namespace dom } // namespace mozilla #endif // mozilla_dom_PerformanceTiming_h
--- a/dom/performance/PerformanceWorker.h +++ b/dom/performance/PerformanceWorker.h @@ -16,34 +16,34 @@ namespace workers { class WorkerPrivate; } class PerformanceWorker final : public Performance { public: explicit PerformanceWorker(workers::WorkerPrivate* aWorkerPrivate); - PerformanceStorage* AsPerformanceStorage() override - { - MOZ_CRASH("This should not be called on workers."); - return nullptr; - } - virtual PerformanceTiming* Timing() override { MOZ_CRASH("This should not be called on workers."); return nullptr; } virtual PerformanceNavigation* Navigation() override { MOZ_CRASH("This should not be called on workers."); return nullptr; } + virtual void AddEntry(nsIHttpChannel* channel, + nsITimedChannel* timedChannel) override + { + MOZ_CRASH("This should not be called on workers."); + } + TimeStamp CreationTimeStamp() const override; DOMHighResTimeStamp CreationTime() const override; virtual void GetMozMemory(JSContext *aCx, JS::MutableHandle<JSObject*> aObj) override { MOZ_CRASH("This should not be called on workers."); @@ -63,17 +63,17 @@ public: protected: ~PerformanceWorker(); void InsertUserEntry(PerformanceEntry* aEntry) override; void DispatchBufferFullEvent() override { - // Nothing to do here. See bug 1432758. + MOZ_CRASH("This should not be called on workers."); } private: workers::WorkerPrivate* mWorkerPrivate; }; } // namespace dom } // namespace mozilla
--- a/dom/performance/moz.build +++ b/dom/performance/moz.build @@ -13,34 +13,31 @@ EXPORTS.mozilla.dom += [ 'PerformanceMark.h', 'PerformanceMeasure.h', 'PerformanceNavigation.h', 'PerformanceNavigationTiming.h', 'PerformanceObserver.h', 'PerformanceObserverEntryList.h', 'PerformanceResourceTiming.h', 'PerformanceService.h', - 'PerformanceStorage.h', - 'PerformanceStorageWorker.h', 'PerformanceTiming.h', ] UNIFIED_SOURCES += [ 'Performance.cpp', 'PerformanceEntry.cpp', 'PerformanceMainThread.cpp', 'PerformanceMark.cpp', 'PerformanceMeasure.cpp', 'PerformanceNavigation.cpp', 'PerformanceNavigationTiming.cpp', 'PerformanceObserver.cpp', 'PerformanceObserverEntryList.cpp', 'PerformanceResourceTiming.cpp', 'PerformanceService.cpp', - 'PerformanceStorageWorker.cpp', 'PerformanceTiming.cpp', 'PerformanceWorker.cpp', ] LOCAL_INCLUDES += [ '/dom/workers', ]
deleted file mode 100644 --- a/dom/performance/tests/empty.js +++ /dev/null @@ -1,1 +0,0 @@ -/* Nothing here */
--- a/dom/performance/tests/mochitest.ini +++ b/dom/performance/tests/mochitest.ini @@ -1,20 +1,16 @@ [DEFAULT] support-files = test_performance_observer.js test_performance_user_timing.js test_worker_performance_now.js worker_performance_user_timing.js worker_performance_observer.js sharedworker_performance_user_timing.js - test_worker_performance_entries.js - test_worker_performance_entries.sjs - empty.js [test_performance_observer.html] [test_performance_user_timing.html] [test_worker_user_timing.html] [test_worker_observer.html] [test_sharedWorker_performance_user_timing.html] [test_worker_performance_now.html] [test_timeOrigin.html] -[test_worker_performance_entries.html]
deleted file mode 100644 --- a/dom/performance/tests/test_worker_performance_entries.html +++ /dev/null @@ -1,31 +0,0 @@ -<!-- Any copyright is dedicated to the Public Domain. - - http://creativecommons.org/publicdomain/zero/1.0/ --> -<!DOCTYPE HTML> -<html> -<head> - <title>PerformanceResouceTiming in workers</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -<script class="testbody" type="text/javascript"> - -SimpleTest.waitForExplicitFinish(); -var worker = new Worker('test_worker_performance_entries.js'); -worker.onmessage = function(event) { - if (event.data.type == "check") { - ok(event.data.status, event.data.msg); - return; - } - - if (event.data.type == "finish") { - SimpleTest.finish(); - return; - } - - ok(false, "?!?"); -} - -</script> -</body> -</html>
deleted file mode 100644 --- a/dom/performance/tests/test_worker_performance_entries.js +++ /dev/null @@ -1,102 +0,0 @@ -function ok(a, msg) { - postMessage({type: "check", status: !!a, msg }); -} - -function is(a, b, msg) { - ok(a === b, msg); -} - -function finish(a, msg) { - postMessage({type: "finish" }); -} - -function check(resource, initiatorType, protocol) { - let entries = performance.getEntries(); - ok(entries.length == 1, "We have an entry"); - - ok(entries[0] instanceof PerformanceEntry, - "The entry is a PerformanceEntry"); - ok(entries[0].name.endsWith(resource), "The entry has been found!"); - - is(entries[0].entryType, "resource", "Correct EntryType"); - ok(entries[0].startTime > 0, "We have a startTime"); - ok(entries[0].duration > 0, "We have a duration"); - - ok(entries[0] instanceof PerformanceResourceTiming, - "The entry is a PerformanceResourceTiming"); - - is(entries[0].initiatorType, initiatorType, "Correct initiatorType"); - is(entries[0].nextHopProtocol, protocol, "Correct protocol"); - - performance.clearResourceTimings(); -} - -function simple_checks() { - ok("performance" in self, "We have self.performance"); - performance.clearResourceTimings(); - next(); -} - -function fetch_request() { - fetch("test_worker_performance_entries.sjs") - .then(r => r.blob()) - .then(blob => { - check("test_worker_performance_entries.sjs", "fetch", "http/1.1"); - }) - .then(next); -} - -function xhr_request() { - let xhr = new XMLHttpRequest(); - xhr.open("GET", "test_worker_performance_entries.sjs"); - xhr.send(); - xhr.onload = () => { - check("test_worker_performance_entries.sjs", "xmlhttprequest", "http/1.1"); - next(); - } -} - -function sync_xhr_request() { - let xhr = new XMLHttpRequest(); - xhr.open("GET", "test_worker_performance_entries.sjs", false); - xhr.send(); - check("test_worker_performance_entries.sjs", "xmlhttprequest", "http/1.1"); - next(); -} - -function import_script() { - importScripts(["empty.js"]); - check("empty.js", "other", "http/1.1"); - next(); -} - -function redirect() { - fetch("test_worker_performance_entries.sjs?redirect") - .then(r => r.text()) - .then(text => { - is(text, "Hello world \\o/", "The redirect worked correctly"); - check("test_worker_performance_entries.sjs?redirect", "fetch", "http/1.1"); - }) - .then(next); -} - -let tests = [ - simple_checks, - fetch_request, - xhr_request, - sync_xhr_request, - import_script, - redirect, -]; - -function next() { - if (!tests.length) { - finish(); - return; - } - - let test = tests.shift(); - test(); -} - -next();
deleted file mode 100644 --- a/dom/performance/tests/test_worker_performance_entries.sjs +++ /dev/null @@ -1,12 +0,0 @@ -function handleRequest(request, response) -{ - response.setHeader("Content-Type", "text/html"); - - if (request.queryString == "redirect") { - response.setStatusLine(request.httpVersion, 302, "See Other"); - response.setHeader("Location", "test_worker_performance_entries.sjs?ok"); - } else { - response.setStatusLine(request.httpVersion, 200, "OK"); - response.write("Hello world \\o/"); - } -}
--- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -3168,17 +3168,16 @@ nsresult nsPluginHost::NewPluginURLStrea // load group otherwise this channel could be canceled // form |nsDocShell::OnLinkClickSync| bug 166613 rv = NS_NewChannel(getter_AddRefs(channel), url, requestingNode, nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS | nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL, nsIContentPolicy::TYPE_OBJECT_SUBREQUEST, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup listenerPeer, nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI | nsIChannel::LOAD_BYPASS_SERVICE_WORKER); NS_ENSURE_SUCCESS(rv, rv); if (doc) { // And if it's a script allow it to execute against the
--- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -1060,17 +1060,16 @@ ScriptLoader::StartLoad(ScriptLoadReques nsCOMPtr<nsIChannel> channel; nsresult rv = NS_NewChannelWithTriggeringPrincipal( getter_AddRefs(channel), aRequest->mURI, context, aRequest->mTriggeringPrincipal, securityFlags, contentPolicyType, - nullptr, // aPerformanceStorage loadGroup, prompter, nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI); NS_ENSURE_SUCCESS(rv, rv); // To avoid decoding issues, the build-id is part of the JSBytecodeMimeType
--- a/dom/security/nsCSPContext.cpp +++ b/dom/security/nsCSPContext.cpp @@ -1068,28 +1068,26 @@ nsCSPContext::SendReports( // try to create a new channel for every report-uri nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI; if (doc) { rv = NS_NewChannel(getter_AddRefs(reportChannel), reportURI, doc, nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_CSP_REPORT, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks loadFlags); } else { rv = NS_NewChannel(getter_AddRefs(reportChannel), reportURI, mLoadingPrincipal, nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_CSP_REPORT, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks loadFlags); } if (NS_FAILED(rv)) { CSPCONTEXTLOG(("Could not create new channel for report URI %s", reportURICstring.get()));
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp +++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp @@ -1359,17 +1359,16 @@ nsresult nsWebBrowserPersist::SaveURIInt // Open a channel to the URI nsCOMPtr<nsIChannel> inputChannel; rv = NS_NewChannel(getter_AddRefs(inputChannel), aURI, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup static_cast<nsIInterfaceRequestor*>(this), loadFlags); nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(inputChannel); if (pbChannel) { pbChannel->SetPrivate(aIsPrivate);
--- a/dom/webidl/Performance.webidl +++ b/dom/webidl/Performance.webidl @@ -37,17 +37,17 @@ partial interface Performance { partial interface Performance { PerformanceEntryList getEntries(); PerformanceEntryList getEntriesByType(DOMString entryType); PerformanceEntryList getEntriesByName(DOMString name, optional DOMString entryType); }; // http://www.w3.org/TR/resource-timing/#extensions-performance-interface -[Exposed=(Window,Worker)] +[Exposed=Window] partial interface Performance { void clearResourceTimings(); void setResourceTimingBufferSize(unsigned long maxSize); attribute EventHandler onresourcetimingbufferfull; }; // GC microbenchmarks, pref-guarded, not for general use (bug 1125412) [Exposed=Window]
--- a/dom/webidl/PerformanceResourceTiming.webidl +++ b/dom/webidl/PerformanceResourceTiming.webidl @@ -5,17 +5,16 @@ * * The origin of this IDL file is * https://w3c.github.io/resource-timing/#performanceresourcetiming * * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C * liability, trademark and document use rules apply. */ -[Exposed=(Window,Worker)] interface PerformanceResourceTiming : PerformanceEntry { readonly attribute DOMString initiatorType; readonly attribute DOMString nextHopProtocol; readonly attribute DOMHighResTimeStamp workerStart; readonly attribute DOMHighResTimeStamp redirectStart; readonly attribute DOMHighResTimeStamp redirectEnd;
--- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -52,17 +52,16 @@ #include "mozilla/dom/cache/CacheStorage.h" #include "mozilla/dom/ChannelInfo.h" #include "mozilla/dom/ClientChannelHelper.h" #include "mozilla/dom/ClientInfo.h" #include "mozilla/dom/Exceptions.h" #include "mozilla/dom/InternalResponse.h" #include "mozilla/dom/nsCSPService.h" #include "mozilla/dom/nsCSPUtils.h" -#include "mozilla/dom/PerformanceStorage.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/PromiseNativeHandler.h" #include "mozilla/dom/Response.h" #include "mozilla/dom/ScriptLoader.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/SRILogHelper.h" #include "mozilla/UniquePtr.h" #include "Principal.h" @@ -106,17 +105,16 @@ GetBaseURI(bool aIsMainScript, WorkerPri return baseURI; } nsresult ChannelFromScriptURL(nsIPrincipal* principal, nsIURI* baseURI, nsIDocument* parentDoc, - WorkerPrivate* aWorkerPrivate, nsILoadGroup* loadGroup, nsIIOService* ios, nsIScriptSecurityManager* secMan, const nsAString& aScriptURL, const Maybe<ClientInfo>& aClientInfo, const Maybe<ServiceWorkerDescriptor>& aController, bool aIsMainScript, WorkerScriptType aWorkerScriptType, @@ -187,52 +185,44 @@ ChannelFromScriptURL(nsIPrincipal* princ // that we want to use. So make sure to avoid using 'parentDoc' in that // situation. if (parentDoc && parentDoc->NodePrincipal() == principal) { rv = NS_NewChannel(getter_AddRefs(channel), uri, parentDoc, secFlags, contentPolicyType, - nullptr, // aPerformanceStorage loadGroup, nullptr, // aCallbacks aLoadFlags, ios); } else { // We must have a loadGroup with a load context for the principal to // traverse the channel correctly. MOZ_ASSERT(loadGroup); MOZ_ASSERT(NS_LoadGroupMatchesPrincipal(loadGroup, principal)); - RefPtr<PerformanceStorage> performanceStorage; - if (aWorkerPrivate && !aIsMainScript) { - performanceStorage = aWorkerPrivate->GetPerformanceStorage(); - } - if (aClientInfo.isSome()) { rv = NS_NewChannel(getter_AddRefs(channel), uri, principal, aClientInfo.ref(), aController, secFlags, contentPolicyType, - performanceStorage, loadGroup, nullptr, // aCallbacks aLoadFlags, ios); } else { rv = NS_NewChannel(getter_AddRefs(channel), uri, principal, secFlags, contentPolicyType, - performanceStorage, loadGroup, nullptr, // aCallbacks aLoadFlags, ios); } } NS_ENSURE_SUCCESS(rv, rv); @@ -996,18 +986,17 @@ private: } } } if (!channel) { // Only top level workers' main script use the document charset for the // script uri encoding. Otherwise, default encoding (UTF-8) is applied. bool useDefaultEncoding = !(!parentWorker && IsMainWorkerScript()); - rv = ChannelFromScriptURL(principal, baseURI, parentDoc, mWorkerPrivate, - loadGroup, ios, + rv = ChannelFromScriptURL(principal, baseURI, parentDoc, loadGroup, ios, secMan, loadInfo.mURL, mClientInfo, mController, IsMainWorkerScript(), mWorkerScriptType, mWorkerPrivate->ContentPolicyType(), loadFlags, useDefaultEncoding, getter_AddRefs(channel)); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -2272,18 +2261,18 @@ ChannelFromScriptURLMainThread(nsIPrinci { AssertIsOnMainThread(); nsCOMPtr<nsIIOService> ios(do_GetIOService()); nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager(); NS_ASSERTION(secMan, "This should never be null!"); - return ChannelFromScriptURL(aPrincipal, aBaseURI, aParentDoc, nullptr, - aLoadGroup, ios, secMan, aScriptURL, aClientInfo, + return ChannelFromScriptURL(aPrincipal, aBaseURI, aParentDoc, aLoadGroup, + ios, secMan, aScriptURL, aClientInfo, Maybe<ServiceWorkerDescriptor>(), true, WorkerScript, aMainScriptContentPolicyType, nsIRequest::LOAD_NORMAL, aDefaultURIEncoding, aChannel); } nsresult ChannelFromScriptURLWorkerThread(JSContext* aCx,
--- a/dom/workers/ServiceWorkerScriptCache.cpp +++ b/dom/workers/ServiceWorkerScriptCache.cpp @@ -725,20 +725,17 @@ CompareNetwork::Initialize(nsIPrincipal* nsContentPolicyType contentPolicyType = mIsMainScript ? nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER : nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS; // Note that because there is no "serviceworker" RequestContext type, we can // use the TYPE_INTERNAL_SCRIPT content policy types when loading a service // worker. rv = NS_NewChannel(getter_AddRefs(mChannel), uri, aPrincipal, secFlags, - contentPolicyType, - nullptr, /* aPerformanceStorage */ - loadGroup, - nullptr /* aCallbacks */, + contentPolicyType, loadGroup, nullptr /* aCallbacks */, mLoadFlags); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel); if (httpChannel) { // Spec says no redirects allowed for top-level SW scripts.
--- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -59,17 +59,16 @@ #include "mozilla/dom/FunctionBinding.h" #include "mozilla/dom/IndexedDatabaseManager.h" #include "mozilla/dom/MessageEvent.h" #include "mozilla/dom/MessageEventBinding.h" #include "mozilla/dom/MessagePort.h" #include "mozilla/dom/MessagePortBinding.h" #include "mozilla/dom/nsCSPUtils.h" #include "mozilla/dom/Performance.h" -#include "mozilla/dom/PerformanceStorageWorker.h" #include "mozilla/dom/PMessagePort.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/PromiseDebugging.h" #include "mozilla/dom/PromiseNativeHandler.h" #include "mozilla/dom/SimpleGlobalObject.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/StructuredCloneHolder.h" #include "mozilla/dom/TabChild.h" @@ -7195,28 +7194,16 @@ WorkerPrivate::DumpCrashInformation(nsAC nsTObserverArray<WorkerHolder*>::ForwardIterator iter(mHolders); while (iter.HasMore()) { WorkerHolder* holder = iter.GetNext(); aString.Append("|"); aString.Append(holder->Name()); } } -PerformanceStorage* -WorkerPrivate::GetPerformanceStorage() -{ - AssertIsOnMainThread(); - - if (!mPerformanceStorage) { - mPerformanceStorage = PerformanceStorageWorker::Create(this); - } - - return mPerformanceStorage; -} - NS_IMPL_ISUPPORTS_INHERITED0(ExternalRunnableWrapper, WorkerRunnable) template <class Derived> NS_IMPL_ADDREF(WorkerPrivateParent<Derived>::EventTarget) template <class Derived> NS_IMPL_RELEASE(WorkerPrivateParent<Derived>::EventTarget)
--- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -63,17 +63,16 @@ struct RuntimeStats; namespace mozilla { class ThrottledEventQueue; namespace dom { class ClientInfo; class ClientSource; class Function; class MessagePort; class MessagePortIdentifier; -class PerformanceStorage; class PromiseNativeHandler; class StructuredCloneHolder; class WorkerDebuggerGlobalScope; class WorkerGlobalScope; struct WorkerOptions; } // namespace dom namespace ipc { class PrincipalInfo; @@ -1063,18 +1062,16 @@ class WorkerPrivate : public WorkerPriva nsCOMPtr<nsITimer> mGCTimer; RefPtr<MemoryReporter> mMemoryReporter; // fired on the main thread if the worker script fails to load nsCOMPtr<nsIRunnable> mLoadFailedRunnable; - RefPtr<PerformanceStorage> mPerformanceStorage; - JS::UniqueChars mDefaultLocale; // nulled during worker JSContext init TimeStamp mKillTime; uint32_t mErrorHandlerRecursionCount; uint32_t mNextTimeoutId; Status mStatus; UniquePtr<ClientSource> mClientSource; bool mFrozen; bool mTimerRunning; @@ -1510,19 +1507,16 @@ public: GetController() const; void Control(const ServiceWorkerDescriptor& aServiceWorker); void ExecutionReady(); - PerformanceStorage* - GetPerformanceStorage(); - private: WorkerPrivate(WorkerPrivate* aParent, const nsAString& aScriptURL, bool aIsChromeWorker, WorkerType aWorkerType, const nsAString& aWorkerName, const nsACString& aServiceWorkerScope, WorkerLoadInfo& aLoadInfo); bool
--- a/dom/workers/test/serviceworkers/test_serviceworker_interfaces.js +++ b/dom/workers/test/serviceworkers/test_serviceworker_interfaces.js @@ -184,18 +184,16 @@ var interfaceNamesInGlobalScope = "PerformanceMark", // IMPORTANT: Do not change this list without review from a DOM peer! "PerformanceMeasure", // IMPORTANT: Do not change this list without review from a DOM peer! "PerformanceObserver", // IMPORTANT: Do not change this list without review from a DOM peer! "PerformanceObserverEntryList", // IMPORTANT: Do not change this list without review from a DOM peer! - "PerformanceResourceTiming", -// IMPORTANT: Do not change this list without review from a DOM peer! "ProgressEvent", // IMPORTANT: Do not change this list without review from a DOM peer! "PushEvent", // IMPORTANT: Do not change this list without review from a DOM peer! "PushManager", // IMPORTANT: Do not change this list without review from a DOM peer! "PushMessageData", // IMPORTANT: Do not change this list without review from a DOM peer!
--- a/dom/workers/test/test_worker_interfaces.js +++ b/dom/workers/test/test_worker_interfaces.js @@ -178,18 +178,16 @@ var interfaceNamesInGlobalScope = {name: "PerformanceMark", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "PerformanceMeasure", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "PerformanceObserver", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "PerformanceObserverEntryList", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer! - {name: "PerformanceResourceTiming", insecureContext: true}, -// IMPORTANT: Do not change this list without review from a DOM peer! {name: "ProgressEvent", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "PushManager", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "PushSubscription", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer! {name: "PushSubscriptionOptions", insecureContext: true}, // IMPORTANT: Do not change this list without review from a DOM peer!
--- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -1107,26 +1107,24 @@ nsXBLService::FetchBindingDocument(nsICo rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel), aDocumentURI, aBoundDocument, aOriginPrincipal, nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS | nsILoadInfo::SEC_ALLOW_CHROME, nsIContentPolicy::TYPE_XBL, - nullptr, // aPerformanceStorage loadGroup); } else { rv = NS_NewChannel(getter_AddRefs(channel), aDocumentURI, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS, nsIContentPolicy::TYPE_XBL, - nullptr, // PerformanceStorage loadGroup); } NS_ENSURE_SUCCESS(rv, rv); if (!aForceSyncLoad) { // We can be asynchronous nsXBLStreamListener* xblListener = new nsXBLStreamListener(aBoundDocument, xblSink, doc);
--- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -2503,40 +2503,37 @@ XMLHttpRequestMainThread::CreateChannel( nsresult rv; nsCOMPtr<nsIDocument> responsibleDocument = GetDocumentIfCurrent(); if (responsibleDocument && responsibleDocument->NodePrincipal() == mPrincipal) { rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, responsibleDocument, secFlags, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST, - nullptr, // aPerformanceStorage loadGroup, nullptr, // aCallbacks loadFlags); } else if (mClientInfo.isSome()) { rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal, mClientInfo.ref(), mController, secFlags, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST, - mPerformanceStorage, // aPerformanceStorage loadGroup, nullptr, // aCallbacks loadFlags); } else { // Otherwise use the principal. rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal, secFlags, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST, - mPerformanceStorage, // aPerformanceStorage loadGroup, nullptr, // aCallbacks loadFlags); } NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel)); if (httpChannel) {
--- a/dom/xhr/XMLHttpRequestMainThread.h +++ b/dom/xhr/XMLHttpRequestMainThread.h @@ -36,17 +36,16 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/NotNull.h" #include "mozilla/dom/MutableBlobStorage.h" #include "mozilla/dom/BodyExtractor.h" #include "mozilla/dom/ClientInfo.h" #include "mozilla/dom/TypedArray.h" #include "mozilla/dom/File.h" #include "mozilla/dom/FormData.h" -#include "mozilla/dom/PerformanceStorage.h" #include "mozilla/dom/ServiceWorkerDescriptor.h" #include "mozilla/dom/URLSearchParams.h" #include "mozilla/dom/XMLHttpRequest.h" #include "mozilla/dom/XMLHttpRequestBinding.h" #include "mozilla/dom/XMLHttpRequestEventTarget.h" #include "mozilla/dom/XMLHttpRequestString.h" #include "mozilla/Encoding.h" @@ -197,31 +196,29 @@ public: ENUM_MAX }; XMLHttpRequestMainThread(); void Construct(nsIPrincipal* aPrincipal, nsIGlobalObject* aGlobalObject, nsIURI* aBaseURI = nullptr, - nsILoadGroup* aLoadGroup = nullptr, - PerformanceStorage* aPerformanceStorage = nullptr) + nsILoadGroup* aLoadGroup = nullptr) { MOZ_ASSERT(aPrincipal); nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobalObject); if (win) { if (win->GetExtantDoc()) { mStyleBackend = win->GetExtantDoc()->GetStyleBackendType(); } } mPrincipal = aPrincipal; BindToOwner(aGlobalObject); mBaseURI = aBaseURI; mLoadGroup = aLoadGroup; - mPerformanceStorage = aPerformanceStorage; } void InitParameters(bool aAnon, bool aSystem); void SetParameters(bool aAnon, bool aSystem) { mIsAnon = aAnon || aSystem; mIsSystem = aSystem; @@ -586,18 +583,16 @@ protected: nsCOMPtr<nsIPrincipal> mPrincipal; nsCOMPtr<nsIChannel> mChannel; nsCString mRequestMethod; nsCOMPtr<nsIURI> mRequestURL; nsCOMPtr<nsIDocument> mResponseXML; nsCOMPtr<nsIStreamListener> mXMLParserStreamListener; - RefPtr<PerformanceStorage> mPerformanceStorage; - // used to implement getAllResponseHeaders() class nsHeaderVisitor : public nsIHttpHeaderVisitor { struct HeaderEntry final { nsCString mName; nsCString mValue;
--- a/dom/xhr/XMLHttpRequestWorker.cpp +++ b/dom/xhr/XMLHttpRequestWorker.cpp @@ -868,18 +868,17 @@ Proxy::Init() return false; } nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(ownerWindow); mXHR = new XMLHttpRequestMainThread(); mXHR->Construct(mWorkerPrivate->GetPrincipal(), global, mWorkerPrivate->GetBaseURI(), - mWorkerPrivate->GetLoadGroup(), - mWorkerPrivate->GetPerformanceStorage()); + mWorkerPrivate->GetLoadGroup()); mXHR->SetParameters(mMozAnon, mMozSystem); mXHR->SetClientInfoAndController(mClientInfo, mController); ErrorResult rv; mXHRUpload = mXHR->GetUpload(rv); if (NS_WARN_IF(rv.Failed())) { mXHR = nullptr;
--- a/dom/xml/XMLDocument.cpp +++ b/dom/xml/XMLDocument.cpp @@ -428,17 +428,16 @@ XMLDocument::Load(const nsAString& aUrl, // nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active, // which in turn keeps STOP button from becoming active rv = NS_NewChannel(getter_AddRefs(channel), uri, callingDoc ? callingDoc.get() : static_cast<nsIDocument*>(this), nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST, - nullptr, // aPerformanceStorage loadGroup, req, nsIRequest::LOAD_BACKGROUND); if (NS_FAILED(rv)) { aRv.Throw(rv); return false; }
--- a/dom/xslt/base/txURIUtils.cpp +++ b/dom/xslt/base/txURIUtils.cpp @@ -53,17 +53,16 @@ URIUtils::ResetWithSource(nsIDocument *a nsCOMPtr<nsIChannel> channel = sourceDoc->GetChannel(); if (!channel) { // Need to synthesize one nsresult rv = NS_NewChannel(getter_AddRefs(channel), sourceDoc->GetDocumentURI(), sourceDoc, nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL, nsIContentPolicy::TYPE_OTHER, - nullptr, // aPerformanceStorage loadGroup, nullptr, // aCallbacks nsIChannel::LOAD_BYPASS_SERVICE_WORKER); if (NS_FAILED(rv)) { return; } }
--- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp @@ -450,17 +450,16 @@ txCompileObserver::startLoad(nsIURI* aUr nsCOMPtr<nsIChannel> channel; nsresult rv = NS_NewChannelWithTriggeringPrincipal( getter_AddRefs(channel), aUri, mLoaderDocument, aReferrerPrincipal, // triggeringPrincipal nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, nsIContentPolicy::TYPE_XSLT, - nullptr, // aPerformanceStorage loadGroup); NS_ENSURE_SUCCESS(rv, rv); channel->SetContentType(NS_LITERAL_CSTRING("text/xml")); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); if (httpChannel) {
--- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -2441,17 +2441,16 @@ XULDocument::LoadOverlayInternal(nsIURI* // with the right principal and in the correct // compartment. rv = NS_NewChannel(getter_AddRefs(channel), aURI, NodePrincipal(), nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS | nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage group); if (NS_SUCCEEDED(rv)) { rv = channel->AsyncOpen2(listener); } if (NS_FAILED(rv)) { // Abandon this prototype
--- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp +++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp @@ -292,17 +292,16 @@ nsresult nsAutoConfig::downloadAutoConfi MOZ_LOG(MCD, LogLevel::Debug, ("running MCD url %s\n", mConfigURL.get())); // open a channel for the url rv = NS_NewChannel(getter_AddRefs(channel), url, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage nullptr, // loadGroup nullptr, // aCallbacks nsIRequest::INHIBIT_PERSISTENT_CACHING | nsIRequest::LOAD_BYPASS_CACHE); if (NS_FAILED(rv)) return rv;
--- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -801,17 +801,16 @@ NewImageChannel(nsIChannel** aResult, // the principal is that of the user stylesheet. if (requestingNode && aTriggeringPrincipal) { rv = NS_NewChannelWithTriggeringPrincipal(aResult, aURI, requestingNode, aTriggeringPrincipal, securityFlags, aPolicyType, - nullptr, // PerformanceStorage nullptr, // loadGroup callbacks, aLoadFlags); if (NS_FAILED(rv)) { return rv; } @@ -833,17 +832,16 @@ NewImageChannel(nsIChannel** aResult, // triggeringPrincipal should always be the systemPrincipal. // However, there are exceptions: one is Notifications which create a // channel in the parent prcoess in which case we can't get a requestingNode. rv = NS_NewChannel(aResult, aURI, nsContentUtils::GetSystemPrincipal(), securityFlags, aPolicyType, - nullptr, // PerformanceStorage nullptr, // loadGroup callbacks, aLoadFlags); if (NS_FAILED(rv)) { return rv; }
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -251,17 +251,16 @@ class MOZ_STACK_CLASS ComponentLoaderInf nsIChannel* ScriptChannel() { MOZ_ASSERT(mScriptChannel); return mScriptChannel; } nsresult EnsureScriptChannel() { BEGIN_ENSURE(ScriptChannel, IOService, URI); return NS_NewChannel(getter_AddRefs(mScriptChannel), mURI, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_SCRIPT, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, mIOService); } nsIURI* ResolvedURI() { MOZ_ASSERT(mResolvedURI); return mResolvedURI; } nsresult EnsureResolvedURI() {
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp +++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp @@ -462,17 +462,16 @@ mozJSSubScriptLoader::ReadScriptAsync(ns // lookups (bug 632490). nsCOMPtr<nsIChannel> channel; nsresult rv; rv = NS_NewChannel(getter_AddRefs(channel), uri, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, serv); if (!NS_SUCCEEDED(rv)) { return rv; } @@ -513,17 +512,16 @@ mozJSSubScriptLoader::ReadScript(nsIURI* nsCOMPtr<nsIChannel> chan; nsCOMPtr<nsIInputStream> instream; nsresult rv; rv = NS_NewChannel(getter_AddRefs(chan), uri, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, serv); if (NS_SUCCEEDED(rv)) { chan->SetContentType(NS_LITERAL_CSTRING("application/javascript")); rv = chan->Open2(getter_AddRefs(instream));
--- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -652,17 +652,16 @@ FontFaceSet::StartLoad(gfxUserFontEntry* // being loaded might have a different origin from the principal of the // stylesheet that initiated the font load. rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel), aFontFaceSrc->mURI->get(), mDocument, principal ? principal->get() : nullptr, nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, nsIContentPolicy::TYPE_FONT, - nullptr, // PerformanceStorage loadGroup); NS_ENSURE_SUCCESS(rv, rv); RefPtr<nsFontFaceLoader> fontLoader = new nsFontFaceLoader(aUserFontEntry, aFontFaceSrc->mURI->get(), this, channel); if (LOG_ENABLED()) {
--- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1505,33 +1505,31 @@ Loader::LoadSheet(SheetLoadData* aLoadDa // origin) that is applying the styles. if (aLoadData->mRequestingNode && aLoadData->mLoaderPrincipal) { rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel), aLoadData->mURI, aLoadData->mRequestingNode, aLoadData->mLoaderPrincipal, securityFlags, contentPolicyType, - nullptr, // Performancestorage loadGroup, nullptr, // aCallbacks nsIChannel::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI); } else { // either we are loading something inside a document, in which case // we should always have a requestingNode, or we are loading something // outside a document, in which case the loadingPrincipal and the // triggeringPrincipal should always be the systemPrincipal. rv = NS_NewChannel(getter_AddRefs(channel), aLoadData->mURI, nsContentUtils::GetSystemPrincipal(), securityFlags, contentPolicyType, - nullptr, // aPerformanceStorage loadGroup, nullptr, // aCallbacks nsIChannel::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI); } if (NS_FAILED(rv)) { #ifdef DEBUG
--- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -811,17 +811,16 @@ nsJARChannel::AsyncOpen(nsIStreamListene // kick off an async download of the base URI... nsCOMPtr<nsIStreamListener> downloader = new MemoryDownloader(this); uint32_t loadFlags = mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS); rv = NS_NewChannelInternal(getter_AddRefs(channel), mJarBaseURI, mLoadInfo, - nullptr, // PerformanceStorage mLoadGroup, mCallbacks, loadFlags); if (NS_FAILED(rv)) { mIsPending = false; mListenerContext = nullptr; mListener = nullptr; mCallbacks = nullptr;
--- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -4,17 +4,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/LoadInfo.h" #include "mozilla/Assertions.h" #include "mozilla/dom/ClientIPCTypes.h" #include "mozilla/dom/ClientSource.h" -#include "mozilla/dom/PerformanceStorage.h" #include "mozilla/dom/TabChild.h" #include "mozilla/dom/ToJSValue.h" #include "mozIThirdPartyUtil.h" #include "nsFrameLoader.h" #include "nsIContentSecurityPolicy.h" #include "nsIDocShell.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" @@ -329,17 +328,16 @@ LoadInfo::LoadInfo(const LoadInfo& rhs) , mPrincipalToInherit(rhs.mPrincipalToInherit) , mSandboxedLoadingPrincipal(rhs.mSandboxedLoadingPrincipal) , mResultPrincipalURI(rhs.mResultPrincipalURI) , mClientInfo(rhs.mClientInfo) // mReservedClientSource must be handled specially during redirect // mReservedClientInfo must be handled specially during redirect // mInitialClientInfo must be handled specially during redirect , mController(rhs.mController) - , mPerformanceStorage(rhs.mPerformanceStorage) , mLoadingContext(rhs.mLoadingContext) , mContextForTopLevelLoad(rhs.mContextForTopLevelLoad) , mSecurityFlags(rhs.mSecurityFlags) , mInternalContentPolicyType(rhs.mInternalContentPolicyType) , mTainting(rhs.mTainting) , mUpgradeInsecureRequests(rhs.mUpgradeInsecureRequests) , mVerifySignedContent(rhs.mVerifySignedContent) , mEnforceSRI(rhs.mEnforceSRI) @@ -1243,22 +1241,10 @@ LoadInfo::ClearController() } const Maybe<ServiceWorkerDescriptor>& LoadInfo::GetController() { return mController; } -void -LoadInfo::SetPerformanceStorage(PerformanceStorage* aPerformanceStorage) -{ - mPerformanceStorage = aPerformanceStorage; -} - -PerformanceStorage* -LoadInfo::GetPerformanceStorage() -{ - return mPerformanceStorage; -} - } // namespace net } // namespace mozilla
--- a/netwerk/base/LoadInfo.h +++ b/netwerk/base/LoadInfo.h @@ -19,17 +19,16 @@ #include "mozilla/dom/ServiceWorkerDescriptor.h" class nsINode; class nsPIDOMWindowOuter; namespace mozilla { namespace dom { -class PerformanceStorage; class XMLHttpRequestMainThread; } namespace net { class OptionalLoadInfoArgs; } // namespace net namespace ipc { @@ -162,17 +161,16 @@ private: nsCOMPtr<nsIPrincipal> mSandboxedLoadingPrincipal; nsCOMPtr<nsIURI> mResultPrincipalURI; Maybe<mozilla::dom::ClientInfo> mClientInfo; UniquePtr<mozilla::dom::ClientSource> mReservedClientSource; Maybe<mozilla::dom::ClientInfo> mReservedClientInfo; Maybe<mozilla::dom::ClientInfo> mInitialClientInfo; Maybe<mozilla::dom::ServiceWorkerDescriptor> mController; - RefPtr<mozilla::dom::PerformanceStorage> mPerformanceStorage; nsWeakPtr mLoadingContext; nsWeakPtr mContextForTopLevelLoad; nsSecurityFlags mSecurityFlags; nsContentPolicyType mInternalContentPolicyType; LoadTainting mTainting; bool mUpgradeInsecureRequests; bool mVerifySignedContent;
--- a/netwerk/base/Predictor.cpp +++ b/netwerk/base/Predictor.cpp @@ -1444,17 +1444,16 @@ Predictor::Prefetch(nsIURI *uri, nsIURI referrer->GetAsciiSpec(strReferrer); PREDICTOR_LOG(("Predictor::Prefetch uri=%s referrer=%s verifier=%p", strUri.get(), strReferrer.get(), verifier)); nsCOMPtr<nsIChannel> channel; nsresult rv = NS_NewChannel(getter_AddRefs(channel), uri, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, /* aPerformanceStorage */ nullptr, /* aLoadGroup */ nullptr, /* aCallbacks */ nsIRequest::LOAD_BACKGROUND); if (NS_FAILED(rv)) { PREDICTOR_LOG((" NS_NewChannel failed rv=0x%" PRIX32, static_cast<uint32_t>(rv))); return rv; }
--- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -19,17 +19,16 @@ interface nsIURI; #include "mozilla/LoadTainting.h" #include "mozilla/UniquePtr.h" #include "nsStringFwd.h" namespace mozilla { namespace dom { class ClientInfo; class ClientSource; -class PerformanceStorage; class ServiceWorkerDescriptor; } // namespace dom } // namespace mozilla %} [ref] native nsIRedirectHistoryEntryArray(const nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>>); native OriginAttributes(mozilla::OriginAttributes); [ref] native const_OriginAttributesRef(const mozilla::OriginAttributes); @@ -37,17 +36,16 @@ native OriginAttributes(mozilla::OriginA [ref] native Uint64ArrayRef(const nsTArray<uint64_t>); [ref] native PrincipalArrayRef(const nsTArray<nsCOMPtr<nsIPrincipal>>); [ref] native const_ClientInfoRef(const mozilla::dom::ClientInfo); native UniqueClientSource(mozilla::UniquePtr<mozilla::dom::ClientSource>); native UniqueClientSourceMove(mozilla::UniquePtr<mozilla::dom::ClientSource>&&); [ref] native const_MaybeClientInfoRef(const mozilla::Maybe<mozilla::dom::ClientInfo>); [ref] native const_ServiceWorkerDescriptorRef(const mozilla::dom::ServiceWorkerDescriptor); [ref] native const_MaybeServiceWorkerDescriptorRef(const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>); -[ptr] native PerformanceStoragePtr(mozilla::dom::PerformanceStorage); typedef unsigned long nsSecurityFlags; /** * The LoadInfo object contains information about a network load, why it * was started, and how we plan on using the resulting response. * If a network request is redirected, the new channel will receive a new * LoadInfo object. The new object will contain mostly the same @@ -921,23 +919,9 @@ interface nsILoadInfo : nsISupports void ClearController(); /** * Get the service worker controlling this network request, if one has * been set. */ [noscript, nostdcall, notxpcom] const_MaybeServiceWorkerDescriptorRef GetController(); - - /** - * Set a custom performance storage. This is meant to be executed only for - * workers. If a PerformanceStorage is not set, the loadingDocument->Window - * Performance object will be used instead. - */ - [noscript, nostdcall, notxpcom] - void SetPerformanceStorage(in PerformanceStoragePtr aPerformanceStorage); - - /** - * Get the PerformanceStorage. - */ - [noscript, nostdcall, notxpcom] - PerformanceStoragePtr GetPerformanceStorage(); };
--- a/netwerk/base/nsIncrementalDownload.cpp +++ b/netwerk/base/nsIncrementalDownload.cpp @@ -245,17 +245,16 @@ nsIncrementalDownload::ProcessTimeout() // Fetch next chunk nsCOMPtr<nsIChannel> channel; nsresult rv = NS_NewChannel(getter_AddRefs(channel), mFinalURI, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage nullptr, // loadGroup this, // aCallbacks mLoadFlags); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(channel, &rv);
--- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -78,17 +78,16 @@ #include "nsICertBlocklist.h" #include "nsICertOverrideService.h" #include <limits> using namespace mozilla; using namespace mozilla::net; using mozilla::dom::ClientInfo; -using mozilla::dom::PerformanceStorage; using mozilla::dom::ServiceWorkerDescriptor; #define DEFAULT_RP 3 #define DEFAULT_PRIVATE_RP 2 static uint32_t sDefaultRp = DEFAULT_RP; static uint32_t defaultPrivateRp = DEFAULT_PRIVATE_RP; @@ -160,17 +159,16 @@ NS_NewFileURI(nsIURI **result, rv = ioService->NewFileURI(spec, result); return rv; } nsresult NS_NewChannelInternal(nsIChannel **outChannel, nsIURI *aUri, nsILoadInfo *aLoadInfo, - PerformanceStorage *aPerformanceStorage /* = nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { // NS_NewChannelInternal is mostly called for channel redirects. We should allow // the creation of a channel even if the original channel did not have a loadinfo // attached. @@ -206,24 +204,16 @@ NS_NewChannelInternal(nsIChannel MOZ_DIAGNOSTIC_ASSERT(!(channelLoadFlags & nsIChannel::LOAD_REPLACE)); #endif if (aLoadFlags != nsIRequest::LOAD_NORMAL) { rv = channel->SetLoadFlags(aLoadFlags); NS_ENSURE_SUCCESS(rv, rv); } - if (aPerformanceStorage) { - nsCOMPtr<nsILoadInfo> loadInfo; - rv = channel->GetLoadInfo(getter_AddRefs(loadInfo)); - NS_ENSURE_SUCCESS(rv, rv); - - loadInfo->SetPerformanceStorage(aPerformanceStorage); - } - channel.forget(outChannel); return NS_OK; } namespace { void AssertLoadingPrincipalAndClientInfoMatch(nsIPrincipal* aLoadingPrincipal, @@ -274,47 +264,44 @@ AssertLoadingPrincipalAndClientInfoMatch } nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - PerformanceStorage *aPerformanceStorage /* nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { return NS_NewChannelInternal(outChannel, aUri, nullptr, // aLoadingNode, aLoadingPrincipal, nullptr, // aTriggeringPrincipal Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType, - aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService); } nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal, const ClientInfo &aLoadingClientInfo, const Maybe<ServiceWorkerDescriptor>& aController, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - PerformanceStorage *aPerformanceStorage /* nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { AssertLoadingPrincipalAndClientInfoMatch(aLoadingPrincipal, aLoadingClientInfo, aContentPolicyType); @@ -326,34 +313,32 @@ NS_NewChannel(nsIChannel **out aUri, nullptr, // aLoadingNode, aLoadingPrincipal, nullptr, // aTriggeringPrincipal loadingClientInfo, aController, aSecurityFlags, aContentPolicyType, - aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService); } nsresult NS_NewChannelInternal(nsIChannel **outChannel, nsIURI *aUri, nsINode *aLoadingNode, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal, const Maybe<ClientInfo>& aLoadingClientInfo, const Maybe<ServiceWorkerDescriptor>& aController, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - PerformanceStorage *aPerformanceStorage /* nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { NS_ENSURE_ARG_POINTER(outChannel); nsCOMPtr<nsIIOService> grip; @@ -395,101 +380,88 @@ NS_NewChannelInternal(nsIChannel MOZ_DIAGNOSTIC_ASSERT(!(channelLoadFlags & nsIChannel::LOAD_REPLACE)); #endif if (aLoadFlags != nsIRequest::LOAD_NORMAL) { rv = channel->SetLoadFlags(aLoadFlags); NS_ENSURE_SUCCESS(rv, rv); } - if (aPerformanceStorage) { - nsCOMPtr<nsILoadInfo> loadInfo; - rv = channel->GetLoadInfo(getter_AddRefs(loadInfo)); - NS_ENSURE_SUCCESS(rv, rv); - - loadInfo->SetPerformanceStorage(aPerformanceStorage); - } - channel.forget(outChannel); return NS_OK; } nsresult /*NS_NewChannelWithNodeAndTriggeringPrincipal */ NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel, nsIURI *aUri, nsINode *aLoadingNode, nsIPrincipal *aTriggeringPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - PerformanceStorage *aPerformanceStorage /* = nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { MOZ_ASSERT(aLoadingNode); NS_ASSERTION(aTriggeringPrincipal, "Can not create channel without a triggering Principal!"); return NS_NewChannelInternal(outChannel, aUri, aLoadingNode, aLoadingNode->NodePrincipal(), aTriggeringPrincipal, Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType, - aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService); } // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - PerformanceStorage *aPerformanceStorage /* = nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { NS_ASSERTION(aLoadingPrincipal, "Can not create channel without a loading Principal!"); return NS_NewChannelInternal(outChannel, aUri, nullptr, // aLoadingNode aLoadingPrincipal, aTriggeringPrincipal, Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType, - aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService); } // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal, const ClientInfo &aLoadingClientInfo, const Maybe<ServiceWorkerDescriptor>& aController, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - PerformanceStorage *aPerformanceStorage /* = nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { AssertLoadingPrincipalAndClientInfoMatch(aLoadingPrincipal, aLoadingClientInfo, aContentPolicyType); @@ -501,46 +473,43 @@ NS_NewChannelWithTriggeringPrincipal(nsI aUri, nullptr, // aLoadingNode aLoadingPrincipal, aTriggeringPrincipal, loadingClientInfo, aController, aSecurityFlags, aContentPolicyType, - aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService); } nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri, nsINode *aLoadingNode, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - PerformanceStorage *aPerformanceStorage /* = nullptr */, nsILoadGroup *aLoadGroup /* = nullptr */, nsIInterfaceRequestor *aCallbacks /* = nullptr */, nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */, nsIIOService *aIoService /* = nullptr */) { NS_ASSERTION(aLoadingNode, "Can not create channel without a loading Node!"); return NS_NewChannelInternal(outChannel, aUri, aLoadingNode, aLoadingNode->NodePrincipal(), nullptr, // aTriggeringPrincipal Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType, - aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService); } nsresult NS_GetIsDocumentChannel(nsIChannel * aChannel, bool *aIsDocument) @@ -1062,17 +1031,16 @@ NS_NewStreamLoaderInternal(nsIStreamLoad aUri, aLoadingNode, aLoadingPrincipal, nullptr, // aTriggeringPrincipal Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType, - nullptr, // PerformanceStorage aLoadGroup, aCallbacks, aLoadFlags); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); if (httpChannel) { rv = httpChannel->SetReferrer(aReferrer);
--- a/netwerk/base/nsNetUtil.h +++ b/netwerk/base/nsNetUtil.h @@ -53,17 +53,16 @@ class nsIIncrementalStreamLoaderObserver class nsIUnicharStreamLoader; class nsIUnicharStreamLoaderObserver; namespace mozilla { class Encoding; class OriginAttributes; namespace dom { class ClientInfo; -class PerformanceStorage; class ServiceWorkerDescriptor; } // namespace dom } // namespace mozilla template <class> class nsCOMPtr; template <typename> struct already_AddRefed; already_AddRefed<nsIIOService> do_GetIOService(nsresult *error = 0); @@ -155,113 +154,105 @@ nsresult NS_NewChannelInternal(nsIChanne nsIURI *aUri, nsINode *aLoadingNode, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal, const mozilla::Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo, const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup *aLoadGroup = nullptr, nsIInterfaceRequestor *aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService *aIoService = nullptr); // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannelInternal(nsIChannel **outChannel, nsIURI *aUri, nsILoadInfo *aLoadInfo, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup *aLoadGroup = nullptr, nsIInterfaceRequestor *aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService *aIoService = nullptr); // See NS_NewChannelInternal for usage and argument description nsresult /*NS_NewChannelWithNodeAndTriggeringPrincipal */ NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel, nsIURI *aUri, nsINode *aLoadingNode, nsIPrincipal *aTriggeringPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup *aLoadGroup = nullptr, nsIInterfaceRequestor *aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService *aIoService = nullptr); // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup *aLoadGroup = nullptr, nsIInterfaceRequestor *aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService *aIoService = nullptr); // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannelWithTriggeringPrincipal(nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal, nsIPrincipal *aTriggeringPrincipal, const mozilla::dom::ClientInfo& aLoadingClientInfo, const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup *aLoadGroup = nullptr, nsIInterfaceRequestor *aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService *aIoService = nullptr); // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri, nsINode *aLoadingNode, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup *aLoadGroup = nullptr, nsIInterfaceRequestor *aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService *aIoService = nullptr); // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup *aLoadGroup = nullptr, nsIInterfaceRequestor *aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService *aIoService = nullptr); // See NS_NewChannelInternal for usage and argument description nsresult NS_NewChannel(nsIChannel** outChannel, nsIURI* aUri, nsIPrincipal* aLoadingPrincipal, const mozilla::dom::ClientInfo& aLoadingClientInfo, const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController, nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType, - mozilla::dom::PerformanceStorage* aPerformanceStorage = nullptr, nsILoadGroup* aLoadGroup = nullptr, nsIInterfaceRequestor* aCallbacks = nullptr, nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, nsIIOService* aIoService = nullptr); nsresult NS_GetIsDocumentChannel(nsIChannel * aChannel, bool *aIsDocument); nsresult NS_MakeAbsoluteURI(nsACString &result,
--- a/netwerk/base/nsPACMan.cpp +++ b/netwerk/base/nsPACMan.cpp @@ -494,17 +494,16 @@ nsPACMan::StartLoading() if (pacURI) { nsresult rv = pacURI->GetSpec(mNormalPACURISpec); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv)); NS_NewChannel(getter_AddRefs(channel), pacURI, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage, nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, ios); } else { LOG(("nsPACMan::StartLoading Failed pacspec uri conversion %s\n", mPACURISpec.get()));
--- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -147,17 +147,17 @@ FTPChannelParent::DoAsyncOpen(const URIP OriginAttributes attrs; rv = loadInfo->GetOriginAttributes(&attrs); if (NS_FAILED(rv)) { return SendFailedAsyncOpen(rv); } nsCOMPtr<nsIChannel> chan; rv = NS_NewChannelInternal(getter_AddRefs(chan), uri, loadInfo, - nullptr, nullptr, nullptr, + nullptr, nullptr, nsIRequest::LOAD_NORMAL, ios); if (NS_FAILED(rv)) return SendFailedAsyncOpen(rv); mChannel = chan; // later on mChannel may become an HTTP channel (we'll be redirected to one
--- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -37,17 +37,16 @@ #include "nsIMutableArray.h" #include "nsIScriptSecurityManager.h" #include "nsIObserverService.h" #include "nsProxyRelease.h" #include "nsPIDOMWindow.h" #include "nsIDocShell.h" #include "nsINetworkInterceptController.h" #include "mozilla/dom/Performance.h" -#include "mozilla/dom/PerformanceStorage.h" #include "mozIThirdPartyUtil.h" #include "nsStreamUtils.h" #include "nsThreadUtils.h" #include "nsContentSecurityManager.h" #include "nsIChannelEventSink.h" #include "nsILoadGroupChild.h" #include "mozilla/ConsoleReportCollector.h" #include "LoadInfo.h" @@ -4151,18 +4150,18 @@ IMPL_TIMING_ATTR(ResponseStart) IMPL_TIMING_ATTR(ResponseEnd) IMPL_TIMING_ATTR(CacheReadStart) IMPL_TIMING_ATTR(CacheReadEnd) IMPL_TIMING_ATTR(RedirectStart) IMPL_TIMING_ATTR(RedirectEnd) #undef IMPL_TIMING_ATTR -mozilla::dom::PerformanceStorage* -HttpBaseChannel::GetPerformanceStorage() +mozilla::dom::Performance* +HttpBaseChannel::GetPerformance() { // If performance timing is disabled, there is no need for the Performance // object anymore. if (!mTimingEnabled) { return nullptr; } // There is no point in continuing, since the performance object in the parent @@ -4170,22 +4169,16 @@ HttpBaseChannel::GetPerformanceStorage() if (XRE_IsE10sParentProcess()) { return nullptr; } if (!mLoadInfo) { return nullptr; } - // If a custom performance storage is set, let's use it. - mozilla::dom::PerformanceStorage* performanceStorage = mLoadInfo->GetPerformanceStorage(); - if (performanceStorage) { - return performanceStorage; - } - // We don't need to report the resource timing entry for a TYPE_DOCUMENT load. if (mLoadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_DOCUMENT) { return nullptr; } nsCOMPtr<nsIDOMDocument> domDocument; mLoadInfo->GetLoadingDocument(getter_AddRefs(domDocument)); if (!domDocument) { @@ -4205,22 +4198,22 @@ HttpBaseChannel::GetPerformanceStorage() return nullptr; } nsCOMPtr<nsPIDOMWindowInner> innerWindow = loadingDocument->GetInnerWindow(); if (!innerWindow) { return nullptr; } - mozilla::dom::Performance* performance = innerWindow->GetPerformance(); - if (!performance) { + mozilla::dom::Performance* docPerformance = innerWindow->GetPerformance(); + if (!docPerformance) { return nullptr; } - return performance->AsPerformanceStorage(); + return docPerformance; } NS_IMETHODIMP HttpBaseChannel::SetReportResourceTiming(bool enabled) { mReportTiming = enabled; return NS_OK; }
--- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -57,17 +57,17 @@ class nsISecurityConsoleMessage; class nsIPrincipal; namespace mozilla { namespace dom { -class PerformanceStorage; +class Performance; } class LogCollector; namespace net { extern mozilla::LazyLogModule gHttpLog; /* @@ -420,17 +420,17 @@ protected: virtual void ReleaseListeners(); // This is fired only when a cookie is created due to the presence of // Set-Cookie header in the response header of any network request. // This notification will come only after the "http-on-examine-response" // was fired. void NotifySetCookie(char const *aCookie); - mozilla::dom::PerformanceStorage* GetPerformanceStorage(); + mozilla::dom::Performance* GetPerformance(); nsIURI* GetReferringPage(); nsPIDOMWindowInner* GetInnerDOMWindow(); void AddCookiesToRequest(); virtual MOZ_MUST_USE nsresult SetupReplacementChannel(nsIURI *, nsIChannel *, bool preserveMethod, uint32_t redirectFlags);
--- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -30,17 +30,17 @@ #include "nsContentPolicyUtils.h" #include "nsGlobalWindow.h" #include "nsStringStream.h" #include "nsHttpChannel.h" #include "nsHttpHandler.h" #include "nsNetUtil.h" #include "nsSerializationHelper.h" #include "mozilla/Attributes.h" -#include "mozilla/dom/PerformanceStorage.h" +#include "mozilla/dom/Performance.h" #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/ipc/BackgroundUtils.h" #include "mozilla/net/ChannelDiverterChild.h" #include "mozilla/net/DNS.h" #include "SerializedLoadContext.h" #include "nsInputStreamPump.h" #include "InterceptedChannel.h" @@ -1209,19 +1209,19 @@ void HttpChannelChild::DoPreOnStopRequest(nsresult aStatus) { LOG(("HttpChannelChild::DoPreOnStopRequest [this=%p status=%" PRIx32 "]\n", this, static_cast<uint32_t>(aStatus))); mIsPending = false; MaybeCallSynthesizedCallback(); - PerformanceStorage* performanceStorage = GetPerformanceStorage(); - if (performanceStorage) { - performanceStorage->AddEntry(this, this); + Performance* documentPerformance = GetPerformance(); + if (documentPerformance) { + documentPerformance->AddEntry(this, this); } if (!mCanceled && NS_SUCCEEDED(mStatus)) { mStatus = aStatus; } CollectOMTTelemetry(); } @@ -1712,17 +1712,16 @@ HttpChannelChild::SetupRedirect(nsIURI* rv = gHttpHandler->GetIOService(getter_AddRefs(ioService)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIChannel> newChannel; nsCOMPtr<nsILoadInfo> redirectLoadInfo = CloneLoadInfoForRedirect(uri, redirectFlags); rv = NS_NewChannelInternal(getter_AddRefs(newChannel), uri, redirectLoadInfo, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, ioService); NS_ENSURE_SUCCESS(rv, rv); // We won't get OnStartRequest, set cookies here. mResponseHead = new nsHttpResponseHead(*responseHead);
--- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -526,17 +526,17 @@ HttpChannelParent::DoAsyncOpen( const U } if (!loadInfo) { return SendFailedAsyncOpen(NS_ERROR_UNEXPECTED); } nsCOMPtr<nsIChannel> channel; rv = NS_NewChannelInternal(getter_AddRefs(channel), uri, loadInfo, - nullptr, nullptr, nullptr, aLoadFlags, ios); + nullptr, nullptr, aLoadFlags, ios); if (NS_FAILED(rv)) { return SendFailedAsyncOpen(rv); } RefPtr<HttpBaseChannel> httpChannel = do_QueryObject(channel, &rv); if (NS_FAILED(rv)) { return SendFailedAsyncOpen(rv); }
--- a/netwerk/protocol/http/InterceptedHttpChannel.cpp +++ b/netwerk/protocol/http/InterceptedHttpChannel.cpp @@ -2,17 +2,17 @@ /* vim: set sw=2 ts=8 et tw=80 : */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "InterceptedHttpChannel.h" #include "nsContentSecurityManager.h" #include "nsEscape.h" -#include "mozilla/dom/PerformanceStorage.h" +#include "mozilla/dom/Performance.h" namespace mozilla { namespace net { NS_IMPL_ISUPPORTS_INHERITED(InterceptedHttpChannel, HttpBaseChannel, nsIInterceptedChannel, nsICacheInfoChannel, @@ -207,17 +207,16 @@ InterceptedHttpChannel::FollowSyntheticR mRequestHead.ParsedMethod()); nsCOMPtr<nsIChannel> newChannel; nsCOMPtr<nsILoadInfo> redirectLoadInfo = CloneLoadInfoForRedirect(redirectURI, redirectFlags); rv = NS_NewChannelInternal(getter_AddRefs(newChannel), redirectURI, redirectLoadInfo, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks mLoadFlags, ioService); NS_ENSURE_SUCCESS(rv, rv); rv = SetupReplacementChannel(redirectURI, newChannel, !rewriteToGET, redirectFlags); @@ -661,17 +660,16 @@ InterceptedHttpChannel::ResetInterceptio uint32_t flags = nsIChannelEventSink::REDIRECT_INTERNAL; nsCOMPtr<nsIChannel> newChannel; nsCOMPtr<nsILoadInfo> redirectLoadInfo = CloneLoadInfoForRedirect(mURI, flags); nsresult rv = NS_NewChannelInternal(getter_AddRefs(newChannel), mURI, redirectLoadInfo, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks mLoadFlags); NS_ENSURE_SUCCESS(rv, rv); rv = SetupReplacementChannel(mURI, newChannel, true, flags); NS_ENSURE_SUCCESS(rv, rv); @@ -1072,20 +1070,20 @@ InterceptedHttpChannel::OnStopRequest(ns // Its possible that we have any async runnable queued to report some // progress when OnStopRequest() is triggered. Report any left over // progress immediately. The extra runnable will then do nothing thanks // to the ReleaseListeners() call below. MaybeCallStatusAndProgress(); mIsPending = false; - // Register entry to the PerformanceStorage resource timing - mozilla::dom::PerformanceStorage* performanceStorage = GetPerformanceStorage(); - if (performanceStorage) { - performanceStorage->AddEntry(this, this); + // Register entry to the Performance resource timing + mozilla::dom::Performance* documentPerformance = GetPerformance(); + if (documentPerformance) { + documentPerformance->AddEntry(this, this); } if (mListener) { mListener->OnStopRequest(this, mListenerContext, mStatus); } gHttpHandler->OnStopRequest(this);
--- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -1489,17 +1489,16 @@ nsCORSListenerProxy::StartCORSPreflight( // check won't be safe any more. loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER | nsIRequest::LOAD_ANONYMOUS; nsCOMPtr<nsIChannel> preflightChannel; rv = NS_NewChannelInternal(getter_AddRefs(preflightChannel), uri, loadInfo, - nullptr, // PerformanceStorage loadGroup, nullptr, // aCallbacks loadFlags); NS_ENSURE_SUCCESS(rv, rv); // Set method and headers nsCOMPtr<nsIHttpChannel> preHttp = do_QueryInterface(preflightChannel); NS_ASSERTION(preHttp, "Failed to QI to nsIHttpChannel!");
--- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -80,17 +80,17 @@ #include "nsInputStreamPump.h" #include "nsURLHelper.h" #include "nsISocketTransport.h" #include "nsIStreamConverterService.h" #include "nsISiteSecurityService.h" #include "nsString.h" #include "nsCRT.h" #include "CacheObserver.h" -#include "mozilla/dom/PerformanceStorage.h" +#include "mozilla/dom/Performance.h" #include "mozilla/Telemetry.h" #include "AlternateServices.h" #include "InterceptedChannel.h" #include "nsIHttpPushListener.h" #include "nsIX509Cert.h" #include "ScopedNSSTypes.h" #include "NullPrincipal.h" #include "nsIDeprecationWarner.h" @@ -2834,17 +2834,16 @@ nsHttpChannel::StartRedirectChannelToURI nsCOMPtr<nsIIOService> ioService; rv = gHttpHandler->GetIOService(getter_AddRefs(ioService)); NS_ENSURE_SUCCESS(rv, rv); rv = NS_NewChannelInternal(getter_AddRefs(newChannel), upgradedURI, redirectLoadInfo, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, ioService); NS_ENSURE_SUCCESS(rv, rv); rv = SetupReplacementChannel(upgradedURI, newChannel, true, flags); NS_ENSURE_SUCCESS(rv, rv); @@ -5588,17 +5587,16 @@ nsHttpChannel::ContinueProcessRedirectio else redirectFlags = nsIChannelEventSink::REDIRECT_TEMPORARY; nsCOMPtr<nsIChannel> newChannel; nsCOMPtr<nsILoadInfo> redirectLoadInfo = CloneLoadInfoForRedirect(mRedirectURI, redirectFlags); rv = NS_NewChannelInternal(getter_AddRefs(newChannel), mRedirectURI, redirectLoadInfo, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, ioService); NS_ENSURE_SUCCESS(rv, rv); rv = SetupReplacementChannel(mRedirectURI, newChannel, !rewriteToGET, redirectFlags); @@ -7327,20 +7325,20 @@ nsHttpChannel::OnStopRequest(nsIRequest LOG(("FinalizeCacheEntry failed (%08x)", static_cast<uint32_t>(rv))); } } } ReportRcwnStats(isFromNet); - // Register entry to the PerformanceStorage resource timing - mozilla::dom::PerformanceStorage* performanceStorage = GetPerformanceStorage(); - if (performanceStorage) { - performanceStorage->AddEntry(this, this); + // Register entry to the Performance resource timing + mozilla::dom::Performance* documentPerformance = GetPerformance(); + if (documentPerformance) { + documentPerformance->AddEntry(this, this); } if (mListener) { LOG(("nsHttpChannel %p calling OnStopRequest\n", this)); MOZ_ASSERT(mOnStartRequestCalled, "OnStartRequest should be called before OnStopRequest"); MOZ_ASSERT(!mOnStopRequestCalled, "We should not call OnStopRequest twice"); @@ -8504,17 +8502,16 @@ nsHttpChannel::OnPush(const nsACString & nsCOMPtr<nsIIOService> ioService; rv = gHttpHandler->GetIOService(getter_AddRefs(ioService)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIChannel> pushChannel; rv = NS_NewChannelInternal(getter_AddRefs(pushChannel), pushResource, mLoadInfo, - nullptr, // PerformanceStorage nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, ioService); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIHttpChannel> pushHttpChannel = do_QueryInterface(pushChannel); MOZ_ASSERT(pushHttpChannel);
--- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp @@ -112,17 +112,16 @@ WyciwygChannelParent::RecvInit(const URI nsCOMPtr<nsIChannel> chan; rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(chan), uri, requestingPrincipal, triggeringPrincipal, aSecurityFlags, aContentPolicyType, - nullptr, // PerformanceStorage nullptr, // loadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL, ios); if (NS_FAILED(rv)) { if (!SendCancelEarly(rv)) { return IPC_FAIL_NO_REASON(this);
--- a/rdf/base/nsRDFXMLDataSource.cpp +++ b/rdf/base/nsRDFXMLDataSource.cpp @@ -936,17 +936,16 @@ RDFXMLDataSourceImpl::Refresh(bool aBloc else { // Null LoadGroup ? nsCOMPtr<nsIChannel> channel; rv = NS_NewChannel(getter_AddRefs(channel), mURL, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup this); // aCallbacks NS_ENSURE_SUCCESS(rv, rv); rv = channel->AsyncOpen2(this); NS_ENSURE_SUCCESS(rv, rv); // So we don't try to issue two asynchronous loads at once. mLoadState = eLoadState_Pending;
--- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -284567,21 +284567,16 @@ {} ] ], "resource-timing/resources/blue.png": [ [ {} ] ], - "resource-timing/resources/empty.js": [ - [ - {} - ] - ], "resource-timing/resources/fake_responses.html": [ [ {} ] ], "resource-timing/resources/fake_responses.py": [ [ {} @@ -348856,22 +348851,16 @@ ] ], "resource-timing/resource_subframe_self_navigation.html": [ [ "/resource-timing/resource_subframe_self_navigation.html", {} ] ], - "resource-timing/resource_timing.worker.js": [ - [ - "/resource-timing/resource_timing.worker.html", - {} - ] - ], "resource-timing/single-entry-per-resource.html": [ [ "/resource-timing/single-entry-per-resource.html", { "timeout": "long" } ] ], @@ -573641,32 +573630,24 @@ "resource-timing/resource_dynamic_insertion.html": [ "1b6e111056101c88623eda6148042c310a5b7a6d", "testharness" ], "resource-timing/resource_subframe_self_navigation.html": [ "072eb2cd05a0711abc498f4180738aef7d1bf282", "testharness" ], - "resource-timing/resource_timing.worker.js": [ - "c458be6cb1c70c151761f69b07d92163a30001f5", - "testharness" - ], "resource-timing/resources/TAOResponse.py": [ "9e8051a2ff8fff72b36ed1cecb61f9e7bba29071", "support" ], "resource-timing/resources/blue.png": [ "99949c515749e66f471c3589ee7a0ef518aaccb5", "support" ], - "resource-timing/resources/empty.js": [ - "51e0050cf1bdeb051d0d7ab6f23a7a2173cb40db", - "support" - ], "resource-timing/resources/fake_responses.html": [ "c942abc1e8c1672935ffc8ce34821891345bacb9", "support" ], "resource-timing/resources/fake_responses.py": [ "ea5b33477356da9f1053413537f36684ac5efdf2", "support" ],
new file mode 100644 --- /dev/null +++ b/testing/web-platform/meta/performance-timeline/case-sensitivity.any.js.ini @@ -0,0 +1,9 @@ +[case-sensitivity.any.worker.html] + [getEntriesByType values are case sensitive] + expected: FAIL + + [getEntriesByName values are case sensitive] + expected: FAIL + + +[case-sensitivity.any.html]
deleted file mode 100644 --- a/testing/web-platform/tests/resource-timing/resource_timing.worker.js +++ /dev/null @@ -1,64 +0,0 @@ -importScripts("/resources/testharness.js"); - -function check(initiatorType, protocol) { - let entries = performance.getEntries(); - assert_equals(entries.length, 1); - - assert_true(entries[0] instanceof PerformanceEntry); - assert_equals(entries[0].entryType, "resource"); - assert_true(entries[0].startTime > 0); - assert_true(entries[0].duration > 0); - - assert_true(entries[0] instanceof PerformanceResourceTiming); - assert_equals(entries[0].initiatorType, initiatorType); - assert_equals(entries[0].nextHopProtocol, protocol); -} - -async_test(t => { - performance.clearResourceTimings(); - - // Fetch - fetch("resources/empty.js") - .then(r => r.blob()) - .then(blob => { - check("fetch", "http/1.1"); - }) - - // XMLHttpRequest - .then(() => { - return new Promise(resolve => { - performance.clearResourceTimings(); - let xhr = new XMLHttpRequest(); - xhr.onload = () => { - check("xmlhttprequest", "http/1.1"); - resolve(); - }; - xhr.open("GET", "resources/empty.js"); - xhr.send(); - }); - }) - - // Sync XMLHttpREquest - .then(() => { - performance.clearResourceTimings(); - let xhr = new XMLHttpRequest(); - xhr.open("GET", "resources/empty.js", false); - xhr.send(); - - check("xmlhttprequest", "http/1.1"); - }) - - // ImportScripts - .then(() => { - performance.clearResourceTimings(); - importScripts(["resources/empty.js"]); - check("other", "http/1.1"); - }) - - // All done. - .then(() => { - t.done(); - }); -}, "Performance Resouce Entries in workers"); - -done();
deleted file mode 100644 --- a/testing/web-platform/tests/resource-timing/resources/empty.js +++ /dev/null @@ -1,1 +0,0 @@ -/* Nothing here */
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -2122,17 +2122,16 @@ nsUrlClassifierDBService::SendThreatHitR nsIChannel::LOAD_BYPASS_CACHE; nsCOMPtr<nsIChannel> reportChannel; rv = NS_NewChannel(getter_AddRefs(reportChannel), reportURI, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup nullptr, loadFlags); NS_ENSURE_SUCCESS(rv, rv); // Safe Browsing has a separate cookie jar nsCOMPtr<nsILoadInfo> loadInfo = reportChannel->GetLoadInfo(); mozilla::OriginAttributes attrs;
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp @@ -135,17 +135,16 @@ nsUrlClassifierStreamUpdater::FetchUpdat nsresult rv; uint32_t loadFlags = nsIChannel::INHIBIT_CACHING | nsIChannel::LOAD_BYPASS_CACHE; rv = NS_NewChannel(getter_AddRefs(mChannel), aUpdateUrl, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // aPerformanceStorage nullptr, // aLoadGroup this, // aInterfaceRequestor loadFlags); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo(); mozilla::OriginAttributes attrs;
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp @@ -176,17 +176,16 @@ nsManifestCheck::Begin() rv = mManifestHash->Init(nsICryptoHash::MD5); NS_ENSURE_SUCCESS(rv, rv); rv = NS_NewChannel(getter_AddRefs(mChannel), mURI, mLoadingPrincipal, nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage nullptr, // loadGroup nullptr, // aCallbacks nsIRequest::LOAD_BYPASS_CACHE); NS_ENSURE_SUCCESS(rv, rv); // configure HTTP specific stuff nsCOMPtr<nsIHttpChannel> httpChannel = @@ -374,17 +373,16 @@ nsOfflineCacheUpdateItem::OpenChannel(ns flags |= mLoadFlags; rv = NS_NewChannel(getter_AddRefs(mChannel), mURI, mLoadingPrincipal, nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage nullptr, // aLoadGroup this, // aCallbacks flags); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel = do_QueryInterface(mChannel, &rv);
--- a/uriloader/prefetch/nsPrefetchService.cpp +++ b/uriloader/prefetch/nsPrefetchService.cpp @@ -147,17 +147,16 @@ nsPrefetchNode::OpenChannel() mURI, source, source->NodePrincipal(), nullptr, //aTriggeringPrincipal Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), securityFlags, mPolicyType, - nullptr, // aPerformanceStorage loadGroup, // aLoadGroup this, // aCallbacks nsIRequest::LOAD_BACKGROUND | nsICachingChannel::LOAD_ONLY_IF_MODIFIED); NS_ENSURE_SUCCESS(rv, rv); // configure HTTP specific stuff
--- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -72,17 +72,16 @@ nsresult nsDataObj::CStream::Init(nsIURI return NS_ERROR_FAILURE; } nsresult rv; rv = NS_NewChannel(getter_AddRefs(mChannel), pSourceURI, aRequestingPrincipal, nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS, aContentPolicyType, - nullptr, // PerformanceStorage nullptr, // loadGroup nullptr, // aCallbacks nsIRequest::LOAD_FROM_CACHE); NS_ENSURE_SUCCESS(rv, rv); rv = mChannel->AsyncOpen2(this); NS_ENSURE_SUCCESS(rv, rv); return NS_OK;
--- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -1277,17 +1277,16 @@ nsDirectoryViewerFactory::CreateInstance if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIChannel> channel; rv = NS_NewChannel(getter_AddRefs(channel), uri, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, - nullptr, // PerformanceStorage aLoadGroup); if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIStreamListener> listener; rv = factory->CreateInstance(aCommand, channel, aLoadGroup, NS_LITERAL_CSTRING("application/vnd.mozilla.xul+xml"), aContainer, aExtraInfo, getter_AddRefs(listener), aDocViewerResult);