From de9560af3e0e0d0dc93c5401c9b6ca2f0a173e36 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 29 Apr 2018 11:59:22 +0200 Subject: Bug 1317297 - nextHopProtocol is an empty string for local fetch https://hg.mozilla.org/mozilla-central/rev/9e5cd2bf4d66 --- dom/performance/PerformanceMainThread.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'dom/performance/PerformanceMainThread.cpp') diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index 86d42c5f8..fa03408c6 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -6,6 +6,7 @@ #include "PerformanceMainThread.h" #include "PerformanceNavigation.h" +#include "nsICacheInfoChannel.h" namespace mozilla { namespace dom { @@ -165,6 +166,17 @@ PerformanceMainThread::AddEntry(nsIHttpChannel* channel, nsAutoCString protocol; channel->GetProtocolVersion(protocol); + + // If this is a local fetch, nextHopProtocol should be set to empty string. + nsCOMPtr cachedChannel = do_QueryInterface(channel); + if (cachedChannel) { + bool isFromCache; + if (NS_SUCCEEDED(cachedChannel->IsFromCache(&isFromCache)) + && isFromCache) { + protocol.Truncate(); + } + } + performanceEntry->SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol)); uint64_t encodedBodySize = 0; -- cgit v1.2.3 From 7ee501103ad2efe1d28ef3c10b4111a685746c06 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 29 Apr 2018 12:07:20 +0200 Subject: Bug 1322966 - Cleanup performance.cpp https://hg.mozilla.org/mozilla-central/rev/0ad76084c4c3 --- dom/performance/PerformanceMainThread.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'dom/performance/PerformanceMainThread.cpp') diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index fa03408c6..d67c0c906 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -16,8 +16,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread, Performance) NS_IMPL_CYCLE_COLLECTION_UNLINK(mTiming, - mNavigation, - mParentPerformance) + mNavigation) tmp->mMozMemory = nullptr; mozilla::DropJSObjects(this); NS_IMPL_CYCLE_COLLECTION_UNLINK_END @@ -25,8 +24,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PerformanceMainThread, Performance) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTiming, - mNavigation, - mParentPerformance) + mNavigation) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -46,12 +44,10 @@ NS_INTERFACE_MAP_END_INHERITING(Performance) PerformanceMainThread::PerformanceMainThread(nsPIDOMWindowInner* aWindow, nsDOMNavigationTiming* aDOMTiming, - nsITimedChannel* aChannel, - Performance* aParentPerformance) + nsITimedChannel* aChannel) : Performance(aWindow) , mDOMTiming(aDOMTiming) , mChannel(aChannel) - , mParentPerformance(aParentPerformance) { MOZ_ASSERT(aWindow, "Parent window object should be provided"); } -- cgit v1.2.3 From 85a83305dd0caeb484687cf511f81024a683338b Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 29 Apr 2018 12:26:49 +0200 Subject: Bug 1322292 - Some fixes for the Performance API in workers - part 1 - Centralized Performance.now() https://hg.mozilla.org/mozilla-central/rev/291a68ca4825 --- dom/performance/PerformanceMainThread.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'dom/performance/PerformanceMainThread.cpp') diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index d67c0c906..5eac15afd 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -105,12 +105,6 @@ PerformanceMainThread::Navigation() return mNavigation; } -DOMHighResTimeStamp -PerformanceMainThread::Now() const -{ - return RoundTime(GetDOMTiming()->TimeStampToDOMHighRes(TimeStamp::Now())); -} - /** * An entry should be added only after the resource is loaded. * This method is not thread safe and can only be called on the main thread. -- cgit v1.2.3 From 089a0bd9a4dace03e5800878055b86854eee5002 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 29 Apr 2018 12:32:19 +0200 Subject: Bug 1322292 - Some fixes for the Performance API in workers - part 2 - Get rid of NowBaseTimeStamp() https://hg.mozilla.org/mozilla-central/rev/301231f4165a --- dom/performance/PerformanceMainThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dom/performance/PerformanceMainThread.cpp') diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index 5eac15afd..5c259cfb8 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -75,7 +75,7 @@ PerformanceTiming* PerformanceMainThread::Timing() { if (!mTiming) { - // For navigation timing, the third argument (an nsIHtttpChannel) is null + // For navigation timing, the third argument (an nsIHttpChannel) is null // since the cross-domain redirect were already checked. The last argument // (zero time) for performance.timing is the navigation start value. mTiming = new PerformanceTiming(this, mChannel, nullptr, -- cgit v1.2.3 From 306db80410e802b0fe9a3b5273d4cf29586a1b17 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 29 Apr 2018 14:15:18 +0200 Subject: moebius#161: The Performance Resource Timing (make timestamps be relative to startTime) https://github.com/MoonchildProductions/moebius/pull/161 --- dom/performance/PerformanceMainThread.cpp | 99 ++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 34 deletions(-) (limited to 'dom/performance/PerformanceMainThread.cpp') diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index 5c259cfb8..64c06d3ea 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -16,7 +16,8 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread, Performance) NS_IMPL_CYCLE_COLLECTION_UNLINK(mTiming, - mNavigation) + mNavigation, + mDocEntry) tmp->mMozMemory = nullptr; mozilla::DropJSObjects(this); NS_IMPL_CYCLE_COLLECTION_UNLINK_END @@ -24,7 +25,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PerformanceMainThread, Performance) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTiming, - mNavigation) + mNavigation, + mDocEntry) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -152,38 +154,7 @@ PerformanceMainThread::AddEntry(nsIHttpChannel* channel, // The PerformanceResourceTiming object will use the PerformanceTiming // object to get all the required timings. RefPtr performanceEntry = - new PerformanceResourceTiming(performanceTiming, this, entryName); - - nsAutoCString protocol; - channel->GetProtocolVersion(protocol); - - // If this is a local fetch, nextHopProtocol should be set to empty string. - nsCOMPtr cachedChannel = do_QueryInterface(channel); - if (cachedChannel) { - bool isFromCache; - if (NS_SUCCEEDED(cachedChannel->IsFromCache(&isFromCache)) - && isFromCache) { - protocol.Truncate(); - } - } - - performanceEntry->SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol)); - - uint64_t encodedBodySize = 0; - channel->GetEncodedBodySize(&encodedBodySize); - performanceEntry->SetEncodedBodySize(encodedBodySize); - - uint64_t transferSize = 0; - channel->GetTransferSize(&transferSize); - performanceEntry->SetTransferSize(transferSize); - - uint64_t decodedBodySize = 0; - channel->GetDecodedBodySize(&decodedBodySize); - if (decodedBodySize == 0) { - decodedBodySize = encodedBodySize; - } - performanceEntry->SetDecodedBodySize(decodedBodySize); - + 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()) { @@ -337,5 +308,65 @@ PerformanceMainThread::CreationTime() const return GetDOMTiming()->GetNavigationStart(); } +void +PerformanceMainThread::EnsureDocEntry() +{ + if (!mDocEntry && nsContentUtils::IsPerformanceNavigationTimingEnabled()) { + nsCOMPtr httpChannel = do_QueryInterface(mChannel); + RefPtr timing = + new PerformanceTiming(this, mChannel, nullptr, 0); + mDocEntry = new PerformanceNavigationTiming(timing, this, + httpChannel); + } +} + + +void +PerformanceMainThread::GetEntries(nsTArray>& aRetval) +{ + aRetval = mResourceEntries; + aRetval.AppendElements(mUserEntries); + + EnsureDocEntry(); + if (mDocEntry) { + aRetval.AppendElement(mDocEntry); + } + + aRetval.Sort(PerformanceEntryComparator()); +} + +void +PerformanceMainThread::GetEntriesByType(const nsAString& aEntryType, + nsTArray>& aRetval) +{ + if (aEntryType.EqualsLiteral("navigation")) { + aRetval.Clear(); + EnsureDocEntry(); + if (mDocEntry) { + aRetval.AppendElement(mDocEntry); + } + return; + } + + Performance::GetEntriesByType(aEntryType, aRetval); +} + +void +PerformanceMainThread::GetEntriesByName(const nsAString& aName, + const Optional& aEntryType, + nsTArray>& aRetval) +{ + if (aName.EqualsLiteral("document")) { + aRetval.Clear(); + EnsureDocEntry(); + if (mDocEntry) { + aRetval.AppendElement(mDocEntry); + } + return; + } + + Performance::GetEntriesByName(aName, aEntryType, aRetval); +} + } // dom namespace } // mozilla namespace -- cgit v1.2.3