зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1916601
- Part 2: Allow constructing PerformanceTimingData from CacheablePerformanceTimingData and timing data. r=sefeng
Also make it possible to construct CacheablePerformanceTimingData from channels to create a cache. Differential Revision: https://phabricator.services.mozilla.com/D223346
This commit is contained in:
Родитель
80541d8f65
Коммит
f3d76ae1a3
|
@ -29,10 +29,10 @@ class CacheablePerformanceTimingData {
|
|||
public:
|
||||
CacheablePerformanceTimingData() = default;
|
||||
|
||||
protected:
|
||||
CacheablePerformanceTimingData(nsITimedChannel* aChannel,
|
||||
nsIHttpChannel* aHttpChannel);
|
||||
|
||||
protected:
|
||||
explicit CacheablePerformanceTimingData(
|
||||
const CacheablePerformanceTimingData& aOther);
|
||||
|
||||
|
|
|
@ -72,6 +72,22 @@ PerformanceTimingData* PerformanceTimingData::Create(
|
|||
return new PerformanceTimingData(aTimedChannel, aChannel, 0);
|
||||
}
|
||||
|
||||
/* static */
|
||||
PerformanceTimingData* PerformanceTimingData::Create(
|
||||
const CacheablePerformanceTimingData& aCachedData,
|
||||
DOMHighResTimeStamp aZeroTime, TimeStamp aStartTime, TimeStamp aEndTime,
|
||||
RenderBlockingStatusType aRenderBlockingStatus) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Check if resource timing is prefed off.
|
||||
if (!StaticPrefs::dom_enable_resource_timing()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new PerformanceTimingData(aCachedData, aZeroTime, aStartTime, aEndTime,
|
||||
aRenderBlockingStatus);
|
||||
}
|
||||
|
||||
PerformanceTiming::PerformanceTiming(Performance* aPerformance,
|
||||
nsITimedChannel* aChannel,
|
||||
nsIHttpChannel* aHttpChannel,
|
||||
|
@ -246,6 +262,21 @@ CacheablePerformanceTimingData::CacheablePerformanceTimingData(
|
|||
}
|
||||
}
|
||||
|
||||
PerformanceTimingData::PerformanceTimingData(
|
||||
const CacheablePerformanceTimingData& aCachedData,
|
||||
DOMHighResTimeStamp aZeroTime, TimeStamp aStartTime, TimeStamp aEndTime,
|
||||
RenderBlockingStatusType aRenderBlockingStatus)
|
||||
: CacheablePerformanceTimingData(aCachedData),
|
||||
mAsyncOpen(aStartTime),
|
||||
mResponseEnd(aEndTime),
|
||||
mZeroTime(aZeroTime),
|
||||
mTransferSize(kLocalCacheTransferSize),
|
||||
mRenderBlockingStatus(aRenderBlockingStatus) {
|
||||
if (!StaticPrefs::dom_enable_performance()) {
|
||||
mZeroTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CacheablePerformanceTimingData::CacheablePerformanceTimingData(
|
||||
const IPCPerformanceTimingData& aIPCData)
|
||||
: mEncodedBodySize(aIPCData.encodedBodySize()),
|
||||
|
|
|
@ -35,6 +35,11 @@ class PerformanceTimingData final : public CacheablePerformanceTimingData {
|
|||
friend struct mozilla::ipc::IPDLParamTraits<
|
||||
mozilla::dom::PerformanceTimingData>;
|
||||
|
||||
// https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-transfersize
|
||||
// The transferSize getter steps are to perform the following steps:
|
||||
// 1. If this's cache mode is "local", then return 0.
|
||||
static constexpr uint64_t kLocalCacheTransferSize = 0;
|
||||
|
||||
public:
|
||||
PerformanceTimingData() = default; // For deserialization
|
||||
// This can return null.
|
||||
|
@ -47,6 +52,18 @@ class PerformanceTimingData final : public CacheablePerformanceTimingData {
|
|||
PerformanceTimingData(nsITimedChannel* aChannel, nsIHttpChannel* aHttpChannel,
|
||||
DOMHighResTimeStamp aZeroTime);
|
||||
|
||||
static PerformanceTimingData* Create(
|
||||
const CacheablePerformanceTimingData& aCachedData,
|
||||
DOMHighResTimeStamp aZeroTime, TimeStamp aStartTime, TimeStamp aEndTime,
|
||||
RenderBlockingStatusType aRenderBlockingStatus);
|
||||
|
||||
private:
|
||||
PerformanceTimingData(const CacheablePerformanceTimingData& aCachedData,
|
||||
DOMHighResTimeStamp aZeroTime, TimeStamp aStartTime,
|
||||
TimeStamp aEndTime,
|
||||
RenderBlockingStatusType aRenderBlockingStatus);
|
||||
|
||||
public:
|
||||
explicit PerformanceTimingData(const IPCPerformanceTimingData& aIPCData);
|
||||
|
||||
IPCPerformanceTimingData ToIPC();
|
||||
|
|
Загрузка…
Ссылка в новой задаче