diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-07-06 15:53:52 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-07-06 15:53:52 +0200 |
commit | 941e54654eabed0a3568f7fefe424a45aa02eddb (patch) | |
tree | 49aa02b174c428962d99142d8061267bfcd79e69 /dom/performance/PerformanceResourceTiming.cpp | |
parent | ad9ee72dcd7981bc47b3844a224d69fadfdfd8ef (diff) | |
parent | 0daa12376295d5d796256a116eb2a348a3a9273f (diff) | |
download | UXP-941e54654eabed0a3568f7fefe424a45aa02eddb.tar UXP-941e54654eabed0a3568f7fefe424a45aa02eddb.tar.gz UXP-941e54654eabed0a3568f7fefe424a45aa02eddb.tar.lz UXP-941e54654eabed0a3568f7fefe424a45aa02eddb.tar.xz UXP-941e54654eabed0a3568f7fefe424a45aa02eddb.zip |
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into _testBranch_test_1
Diffstat (limited to 'dom/performance/PerformanceResourceTiming.cpp')
-rw-r--r-- | dom/performance/PerformanceResourceTiming.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/dom/performance/PerformanceResourceTiming.cpp b/dom/performance/PerformanceResourceTiming.cpp index 60a20ca28..9c5475041 100644 --- a/dom/performance/PerformanceResourceTiming.cpp +++ b/dom/performance/PerformanceResourceTiming.cpp @@ -6,6 +6,7 @@ #include "PerformanceResourceTiming.h" #include "mozilla/dom/PerformanceResourceTimingBinding.h" +#include "mozilla/Unused.h" using namespace mozilla::dom; @@ -25,7 +26,8 @@ NS_IMPL_RELEASE_INHERITED(PerformanceResourceTiming, PerformanceEntry) PerformanceResourceTiming::PerformanceResourceTiming(PerformanceTiming* aPerformanceTiming, Performance* aPerformance, - const nsAString& aName) + const nsAString& aName, + nsIHttpChannel* aChannel) : PerformanceEntry(aPerformance, aName, NS_LITERAL_STRING("resource")), mTiming(aPerformanceTiming), mEncodedBodySize(0), @@ -33,6 +35,34 @@ PerformanceResourceTiming::PerformanceResourceTiming(PerformanceTiming* aPerform 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() @@ -42,8 +72,22 @@ PerformanceResourceTiming::~PerformanceResourceTiming() DOMHighResTimeStamp PerformanceResourceTiming::StartTime() const { - DOMHighResTimeStamp startTime = mTiming->RedirectStartHighRes(); - return startTime ? startTime : mTiming->FetchStartHighRes(); + // 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 = mTiming->RedirectStartHighRes(); + redirect = redirect ? redirect : DBL_MAX; + + DOMHighResTimeStamp worker = mTiming->WorkerStartHighRes(); + worker = worker ? worker : DBL_MAX; + + DOMHighResTimeStamp asyncOpen = mTiming->AsyncOpenHighRes(); + + return std::min(asyncOpen, std::min(redirect, worker)); } JSObject* |