summaryrefslogtreecommitdiffstats
path: root/dom/performance
diff options
context:
space:
mode:
Diffstat (limited to 'dom/performance')
-rw-r--r--dom/performance/PerformanceMainThread.cpp5
-rw-r--r--dom/performance/PerformanceResourceTiming.h6
-rw-r--r--dom/performance/PerformanceTiming.cpp48
-rw-r--r--dom/performance/PerformanceTiming.h3
4 files changed, 58 insertions, 4 deletions
diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp
index b60b68f62..86d42c5f8 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 abb653d66..2dd6b4a06 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 527cf9441..4070b6a0f 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;
+ }
+ }
}
}
@@ -274,6 +302,26 @@ PerformanceTiming::ConnectStart()
}
DOMHighResTimeStamp
+PerformanceTiming::SecureConnectionStartHighRes()
+{
+ if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized()) {
+ return mZeroTime;
+ }
+
+ // Round down to the nearest 1ms
+ const double maxResolutionMs = 1;
+ return mSecureConnectionStart.IsNull()
+ ? mZeroTime
+ : floor(TimeStampToDOMHighRes(mSecureConnectionStart) / maxResolutionMs) * maxResolutionMs;
+}
+
+DOMTimeMilliSec
+PerformanceTiming::SecureConnectionStart()
+{
+ return static_cast<int64_t>(SecureConnectionStartHighRes());
+}
+
+DOMHighResTimeStamp
PerformanceTiming::ConnectEndHighRes()
{
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized()) {
diff --git a/dom/performance/PerformanceTiming.h b/dom/performance/PerformanceTiming.h
index aef54a258..0bc73fd3f 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;