summaryrefslogtreecommitdiff
path: root/dom/performance/PerformanceResourceTiming.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/performance/PerformanceResourceTiming.cpp')
-rw-r--r--dom/performance/PerformanceResourceTiming.cpp49
1 files changed, 9 insertions, 40 deletions
diff --git a/dom/performance/PerformanceResourceTiming.cpp b/dom/performance/PerformanceResourceTiming.cpp
index 6f84896af1..cb08b39b65 100644
--- a/dom/performance/PerformanceResourceTiming.cpp
+++ b/dom/performance/PerformanceResourceTiming.cpp
@@ -11,7 +11,7 @@ using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_INHERITED(PerformanceResourceTiming,
PerformanceEntry,
- mTiming)
+ mPerformance)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PerformanceResourceTiming,
PerformanceEntry)
@@ -23,45 +23,14 @@ NS_INTERFACE_MAP_END_INHERITING(PerformanceEntry)
NS_IMPL_ADDREF_INHERITED(PerformanceResourceTiming, PerformanceEntry)
NS_IMPL_RELEASE_INHERITED(PerformanceResourceTiming, PerformanceEntry)
-PerformanceResourceTiming::PerformanceResourceTiming(PerformanceTiming* aPerformanceTiming,
+PerformanceResourceTiming::PerformanceResourceTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTiming,
Performance* aPerformance,
- const nsAString& aName,
- nsIHttpChannel* aChannel)
-: PerformanceEntry(aPerformance, aName, NS_LITERAL_STRING("resource")),
- mTiming(aPerformanceTiming),
- mEncodedBodySize(0),
- mTransferSize(0),
- mDecodedBodySize(0)
+ const nsAString& aName)
+ : PerformanceEntry(aPerformance->GetParentObject(), aName, NS_LITERAL_STRING("resource"))
+ , mTimingData(Move(aPerformanceTiming))
+ , mPerformance(aPerformance)
{
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()
@@ -78,13 +47,13 @@ PerformanceResourceTiming::StartTime() const
// 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();
+ DOMHighResTimeStamp redirect = mTimingData->RedirectStartHighRes(mPerformance);
redirect = redirect ? redirect : DBL_MAX;
- DOMHighResTimeStamp worker = mTiming->WorkerStartHighRes();
+ DOMHighResTimeStamp worker = mTimingData->WorkerStartHighRes(mPerformance);
worker = worker ? worker : DBL_MAX;
- DOMHighResTimeStamp asyncOpen = mTiming->AsyncOpenHighRes();
+ DOMHighResTimeStamp asyncOpen = mTimingData->AsyncOpenHighRes(mPerformance);
return std::min(asyncOpen, std::min(redirect, worker));
}