From 644e9db1092df1477b1facc52cd3ee45ebd13040 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 1 Mar 2018 11:52:50 +0100 Subject: DevTools - network - implement the secureConnectionStart property for the PerformanceTiming https://github.com/MoonchildProductions/moebius/pull/116 ("/testing" and "/toolkit" in in the previous commit) --- dom/performance/PerformanceMainThread.cpp | 5 +++- dom/performance/PerformanceResourceTiming.h | 6 ++-- dom/performance/PerformanceTiming.cpp | 44 +++++++++++++++++++++++++++++ dom/performance/PerformanceTiming.h | 3 ++ 4 files changed, 54 insertions(+), 4 deletions(-) (limited to 'dom/performance') diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index b60b68f627..86d42c5f86 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -200,7 +200,7 @@ PerformanceMainThread::IsPerformanceTimingAttribute(const nsAString& aName) static const char* attributes[] = {"navigationStart", "unloadEventStart", "unloadEventEnd", "redirectStart", "redirectEnd", "fetchStart", "domainLookupStart", "domainLookupEnd", - "connectStart", "connectEnd", "requestStart", "responseStart", + "connectStart", "secureConnectionStart", "connectEnd", "requestStart", "responseStart", "responseEnd", "domLoading", "domInteractive", "domContentLoadedEventStart", "domContentLoadedEventEnd", "domComplete", "loadEventStart", "loadEventEnd", nullptr}; @@ -249,6 +249,9 @@ PerformanceMainThread::GetPerformanceTimingFromString(const nsAString& aProperty if (aProperty.EqualsLiteral("connectStart")) { return Timing()->ConnectStart(); } + if (aProperty.EqualsLiteral("secureConnectionStart")) { + return Timing()->SecureConnectionStart(); + } if (aProperty.EqualsLiteral("connectEnd")) { return Timing()->ConnectEnd(); } diff --git a/dom/performance/PerformanceResourceTiming.h b/dom/performance/PerformanceResourceTiming.h index abb653d66b..2dd6b4a06b 100644 --- a/dom/performance/PerformanceResourceTiming.h +++ b/dom/performance/PerformanceResourceTiming.h @@ -128,9 +128,9 @@ public: DOMHighResTimeStamp SecureConnectionStart() const { - // This measurement is not available for Navigation Timing either. - // There is a different bug submitted for it. - return 0; + return mTiming && mTiming->TimingAllowed() + ? mTiming->SecureConnectionStartHighRes() + : 0; } virtual const PerformanceResourceTiming* ToResourceTiming() const override diff --git a/dom/performance/PerformanceTiming.cpp b/dom/performance/PerformanceTiming.cpp index 527cf94419..4428f81c2b 100644 --- a/dom/performance/PerformanceTiming.cpp +++ b/dom/performance/PerformanceTiming.cpp @@ -63,12 +63,40 @@ PerformanceTiming::InitializeTimingInfo(nsITimedChannel* aChannel) aChannel->GetDomainLookupStart(&mDomainLookupStart); aChannel->GetDomainLookupEnd(&mDomainLookupEnd); aChannel->GetConnectStart(&mConnectStart); + aChannel->GetSecureConnectionStart(&mSecureConnectionStart); aChannel->GetConnectEnd(&mConnectEnd); aChannel->GetRequestStart(&mRequestStart); aChannel->GetResponseStart(&mResponseStart); aChannel->GetCacheReadStart(&mCacheReadStart); 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. + if (!mAsyncOpen.IsNull()) { + if (!mDomainLookupStart.IsNull() && mDomainLookupStart < mAsyncOpen) { + mDomainLookupStart = mAsyncOpen; + } + + if (!mDomainLookupEnd.IsNull() && mDomainLookupEnd < mAsyncOpen) { + mDomainLookupEnd = mAsyncOpen; + } + + if (!mConnectStart.IsNull() && mConnectStart < mAsyncOpen) { + mConnectStart = mAsyncOpen; + } + + if (!mSecureConnectionStart.IsNull() && mSecureConnectionStart < mAsyncOpen) { + mSecureConnectionStart = mAsyncOpen; + } + + if (!mConnectEnd.IsNull() && mConnectEnd < mAsyncOpen) { + mConnectEnd = mAsyncOpen; + } + } } } @@ -273,6 +301,22 @@ PerformanceTiming::ConnectStart() return static_cast(ConnectStartHighRes()); } +DOMHighResTimeStamp +PerformanceTiming::SecureConnectionStartHighRes() +{ + if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized()) { + return mZeroTime; + } + return mSecureConnectionStart.IsNull() ? mZeroTime + : TimeStampToDOMHighRes(mSecureConnectionStart); +} + +DOMTimeMilliSec +PerformanceTiming::SecureConnectionStart() +{ + return static_cast(SecureConnectionStartHighRes()); +} + DOMHighResTimeStamp PerformanceTiming::ConnectEndHighRes() { diff --git a/dom/performance/PerformanceTiming.h b/dom/performance/PerformanceTiming.h index aef54a258c..0bc73fd3ff 100644 --- a/dom/performance/PerformanceTiming.h +++ b/dom/performance/PerformanceTiming.h @@ -161,6 +161,7 @@ public: DOMHighResTimeStamp DomainLookupStartHighRes(); DOMHighResTimeStamp DomainLookupEndHighRes(); DOMHighResTimeStamp ConnectStartHighRes(); + DOMHighResTimeStamp SecureConnectionStartHighRes(); DOMHighResTimeStamp ConnectEndHighRes(); DOMHighResTimeStamp RequestStartHighRes(); DOMHighResTimeStamp ResponseStartHighRes(); @@ -173,6 +174,7 @@ public: DOMTimeMilliSec DomainLookupStart(); DOMTimeMilliSec DomainLookupEnd(); DOMTimeMilliSec ConnectStart(); + DOMTimeMilliSec SecureConnectionStart(); DOMTimeMilliSec ConnectEnd(); DOMTimeMilliSec RequestStart(); DOMTimeMilliSec ResponseStart(); @@ -255,6 +257,7 @@ private: TimeStamp mDomainLookupStart; TimeStamp mDomainLookupEnd; TimeStamp mConnectStart; + TimeStamp mSecureConnectionStart; TimeStamp mConnectEnd; TimeStamp mRequestStart; TimeStamp mResponseStart; -- cgit v1.2.3