diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-04-29 14:44:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-29 14:44:39 +0200 |
commit | 64aec5a353b4eb58e075c01b2d6d948aa142e6ff (patch) | |
tree | d1e865c31c0864837f47f2eb1c99edd3a011c5d8 /dom/performance/PerformanceResourceTiming.cpp | |
parent | 6fe08dcf34417e825b7b9b6b33141a4a3b46ba24 (diff) | |
parent | 306db80410e802b0fe9a3b5273d4cf29586a1b17 (diff) | |
download | UXP-64aec5a353b4eb58e075c01b2d6d948aa142e6ff.tar UXP-64aec5a353b4eb58e075c01b2d6d948aa142e6ff.tar.gz UXP-64aec5a353b4eb58e075c01b2d6d948aa142e6ff.tar.lz UXP-64aec5a353b4eb58e075c01b2d6d948aa142e6ff.tar.xz UXP-64aec5a353b4eb58e075c01b2d6d948aa142e6ff.zip |
Merge pull request #294 from janekptacijarabaci/js_dom_performance-resource-timing_2
moebius#161: The Performance Resource Timing (make timestamps be relative to startTime)
Diffstat (limited to 'dom/performance/PerformanceResourceTiming.cpp')
-rw-r--r-- | dom/performance/PerformanceResourceTiming.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/dom/performance/PerformanceResourceTiming.cpp b/dom/performance/PerformanceResourceTiming.cpp index 94df27408..2eaa4eb9a 100644 --- a/dom/performance/PerformanceResourceTiming.cpp +++ b/dom/performance/PerformanceResourceTiming.cpp @@ -25,7 +25,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 +34,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() |