summaryrefslogtreecommitdiffstats
path: root/dom/performance/PerformanceTiming.cpp
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 11:49:50 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 11:49:50 +0200
commite040ed925030f899f845d458c226f7e439f4ec8b (patch)
tree797edf76896b10a38446171aa341da8dfef8ca08 /dom/performance/PerformanceTiming.cpp
parentaff03b0a67c41cf7af5df9c9eef715a8b27a2667 (diff)
downloadUXP-e040ed925030f899f845d458c226f7e439f4ec8b.tar
UXP-e040ed925030f899f845d458c226f7e439f4ec8b.tar.gz
UXP-e040ed925030f899f845d458c226f7e439f4ec8b.tar.lz
UXP-e040ed925030f899f845d458c226f7e439f4ec8b.tar.xz
UXP-e040ed925030f899f845d458c226f7e439f4ec8b.zip
moebius#158: The Performance Resource Timing (added support for "workerStart")
https://github.com/MoonchildProductions/moebius/pull/158
Diffstat (limited to 'dom/performance/PerformanceTiming.cpp')
-rwxr-xr-xdom/performance/PerformanceTiming.cpp71
1 files changed, 52 insertions, 19 deletions
diff --git a/dom/performance/PerformanceTiming.cpp b/dom/performance/PerformanceTiming.cpp
index e2f76a21f..887a23938 100755
--- a/dom/performance/PerformanceTiming.cpp
+++ b/dom/performance/PerformanceTiming.cpp
@@ -73,6 +73,7 @@ PerformanceTiming::InitializeTimingInfo(nsITimedChannel* aChannel)
{
if (aChannel) {
aChannel->GetAsyncOpen(&mAsyncOpen);
+ aChannel->GetDispatchFetchEventStart(&mWorkerStart);
aChannel->GetAllRedirectsSameOrigin(&mAllRedirectsSameOrigin);
aChannel->GetRedirectCount(&mRedirectCount);
aChannel->GetRedirectStart(&mRedirectStart);
@@ -88,31 +89,39 @@ PerformanceTiming::InitializeTimingInfo(nsITimedChannel* aChannel)
aChannel->GetResponseEnd(&mResponseEnd);
aChannel->GetCacheReadEnd(&mCacheReadEnd);
- // the performance timing api essentially requires that the event timestamps
- // are >= asyncOpen().. but in truth the browser engages in a number of
- // speculative activities that sometimes mean connections and lookups begin
- // earlier. Workaround that here by just using asyncOpen as the minimum
- // timestamp for dns and connection info.
+ // The performance timing api essentially requires that the event timestamps
+ // have a strict relation with each other. The truth, however, is the browser
+ // engages in a number of speculative activities that sometimes mean connections
+ // and lookups begin at different times. Workaround that here by clamping
+ // these values to what we expect FetchStart to be. This means the later of
+ // AsyncOpen or WorkerStart times.
if (!mAsyncOpen.IsNull()) {
- if (!mDomainLookupStart.IsNull() && mDomainLookupStart < mAsyncOpen) {
- mDomainLookupStart = mAsyncOpen;
+ // We want to clamp to the expected FetchStart value. This is later of
+ // the AsyncOpen and WorkerStart values.
+ const TimeStamp* clampTime = &mAsyncOpen;
+ if (!mWorkerStart.IsNull() && mWorkerStart > mAsyncOpen) {
+ clampTime = &mWorkerStart;
}
- if (!mDomainLookupEnd.IsNull() && mDomainLookupEnd < mAsyncOpen) {
- mDomainLookupEnd = mAsyncOpen;
+ if (!mDomainLookupStart.IsNull() && mDomainLookupStart < *clampTime) {
+ mDomainLookupStart = *clampTime;
}
- if (!mConnectStart.IsNull() && mConnectStart < mAsyncOpen) {
- mConnectStart = mAsyncOpen;
+ if (!mDomainLookupEnd.IsNull() && mDomainLookupEnd < *clampTime) {
+ mDomainLookupEnd = *clampTime;
+ }
+
+ if (!mConnectStart.IsNull() && mConnectStart < *clampTime) {
+ mConnectStart = *clampTime;
}
if (mSecureConnection && !mSecureConnectionStart.IsNull() &&
- mSecureConnectionStart < mAsyncOpen) {
- mSecureConnectionStart = mAsyncOpen;
+ mSecureConnectionStart < *clampTime) {
+ mSecureConnectionStart = *clampTime;
}
- if (!mConnectEnd.IsNull() && mConnectEnd < mAsyncOpen) {
- mConnectEnd = mAsyncOpen;
+ if (!mConnectEnd.IsNull() && mConnectEnd < *clampTime) {
+ mConnectEnd = *clampTime;
}
}
}
@@ -131,9 +140,13 @@ PerformanceTiming::FetchStartHighRes()
}
MOZ_ASSERT(!mAsyncOpen.IsNull(), "The fetch start time stamp should always be "
"valid if the performance timing is enabled");
- mFetchStart = (!mAsyncOpen.IsNull())
- ? TimeStampToDOMHighRes(mAsyncOpen)
- : 0.0;
+ if (!mAsyncOpen.IsNull()) {
+ if (!mWorkerStart.IsNull() && mWorkerStart > mAsyncOpen) {
+ mFetchStart = TimeStampToDOMHighRes(mWorkerStart);
+ } else {
+ mFetchStart = TimeStampToDOMHighRes(mAsyncOpen);
+ }
+ }
}
return TimerClamping::ReduceMsTimeValue(mFetchStart);
}
@@ -180,7 +193,7 @@ PerformanceTiming::TimingAllowed() const
return mTimingAllowed;
}
-uint16_t
+uint8_t
PerformanceTiming::GetRedirectCount() const
{
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized()) {
@@ -205,6 +218,26 @@ PerformanceTiming::ShouldReportCrossOriginRedirect() const
return (mRedirectCount != 0) && mReportCrossOriginRedirect;
}
+DOMHighResTimeStamp
+PerformanceTiming::AsyncOpenHighRes()
+{
+ if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+ mAsyncOpen.IsNull()) {
+ return mZeroTime;
+ }
+ return TimeStampToReducedDOMHighResOrFetchStart(mAsyncOpen);
+}
+
+DOMHighResTimeStamp
+PerformanceTiming::WorkerStartHighRes()
+{
+ if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized() ||
+ mWorkerStart.IsNull()) {
+ return mZeroTime;
+ }
+ return TimeStampToReducedDOMHighResOrFetchStart(mWorkerStart);
+}
+
/**
* RedirectStartHighRes() is used by both the navigation timing and the
* resource timing. Since, navigation timing and resource timing check and