DevTools - network - implement the secureConnectionStart property for the PerformanceTiming

https://github.com/MoonchildProductions/moebius/pull/116
("/testing" and "/toolkit" in in the previous commit)
pull/1/head
janekptacijarabaci 5 years ago committed by Roy Tam
parent 38e95f9e35
commit 54f2e6eafd
  1. 5
      devtools/client/locales/en-US/netmonitor.properties
  2. 11
      devtools/client/netmonitor/netmonitor-view.js
  3. 8
      devtools/client/netmonitor/netmonitor.xul
  4. 2
      devtools/client/netmonitor/requests-menu-view.js
  5. 2
      devtools/client/netmonitor/test/browser_net_simple-request-data.js
  6. 6
      devtools/client/themes/netmonitor.css
  7. 35
      devtools/shared/webconsole/network-monitor.js
  8. 5
      dom/performance/PerformanceMainThread.cpp
  9. 6
      dom/performance/PerformanceResourceTiming.h
  10. 44
      dom/performance/PerformanceTiming.cpp
  11. 3
      dom/performance/PerformanceTiming.h
  12. 3
      dom/webidl/PerformanceTiming.webidl
  13. 2
      netwerk/base/nsISocketTransport.idl
  14. 2
      netwerk/base/nsITimedChannel.idl
  15. 13
      netwerk/base/nsLoadGroup.cpp
  16. 2
      netwerk/ipc/NeckoMessageUtils.h
  17. 9
      netwerk/protocol/http/Http2Session.cpp
  18. 7
      netwerk/protocol/http/HttpBaseChannel.cpp
  19. 1
      netwerk/protocol/http/HttpChannelChild.cpp
  20. 1
      netwerk/protocol/http/HttpChannelParent.cpp
  21. 8
      netwerk/protocol/http/NullHttpChannel.cpp
  22. 24
      netwerk/protocol/http/NullHttpTransaction.cpp
  23. 4
      netwerk/protocol/http/NullHttpTransaction.h
  24. 1
      netwerk/protocol/http/TimingStruct.h
  25. 9
      netwerk/protocol/http/nsHttpChannel.cpp
  26. 1
      netwerk/protocol/http/nsHttpChannel.h
  27. 25
      netwerk/protocol/http/nsHttpConnection.cpp
  28. 6
      netwerk/protocol/http/nsHttpConnection.h
  29. 5
      netwerk/protocol/http/nsHttpConnectionMgr.cpp
  30. 22
      netwerk/protocol/http/nsHttpTransaction.cpp
  31. 3
      netwerk/protocol/http/nsHttpTransaction.h
  32. 1
      python/devtools/migrate-l10n/migrate/conf/bug1308500_1309191

@ -581,6 +581,11 @@ netmonitor.timings.blocked=Blocked:
# in a "dns" state.
netmonitor.timings.dns=DNS resolution:
# LOCALIZATION NOTE (netmonitor.timings.ssl): This is the label displayed
# in the network details timings tab identifying the amount of time spent
# in a "tls" handshake state.
netmonitor.timings.ssl=TLS setup:
# LOCALIZATION NOTE (netmonitor.timings.connect): This is the label displayed
# in the network details timings tab identifying the amount of time spent
# in a "connect" state.

@ -963,7 +963,7 @@ NetworkDetailsView.prototype = {
if (!response) {
return;
}
let { blocked, dns, connect, send, wait, receive } = response.timings;
let { blocked, dns, connect, ssl, send, wait, receive } = response.timings;
let tabboxWidth = $("#details-pane").getAttribute("width");
@ -988,6 +988,11 @@ NetworkDetailsView.prototype = {
$("#timings-summary-connect .requests-menu-timings-total")
.setAttribute("value", L10N.getFormatStr("networkMenu.totalMS", connect));
$("#timings-summary-ssl .requests-menu-timings-box")
.setAttribute("width", ssl * scale);
$("#timings-summary-ssl .requests-menu-timings-total")
.setAttribute("value", L10N.getFormatStr("networkMenu.totalMS", ssl));
$("#timings-summary-send .requests-menu-timings-box")
.setAttribute("width", send * scale);
$("#timings-summary-send .requests-menu-timings-total")
@ -1007,6 +1012,8 @@ NetworkDetailsView.prototype = {
.style.transform = "translateX(" + (scale * blocked) + "px)";
$("#timings-summary-connect .requests-menu-timings-box")
.style.transform = "translateX(" + (scale * (blocked + dns)) + "px)";
$("#timings-summary-ssl .requests-menu-timings-box")
.style.transform = "translateX(" + (scale * blocked) + "px)";
$("#timings-summary-send .requests-menu-timings-box")
.style.transform =
"translateX(" + (scale * (blocked + dns + connect)) + "px)";
@ -1022,6 +1029,8 @@ NetworkDetailsView.prototype = {
.style.transform = "translateX(" + (scale * blocked) + "px)";
$("#timings-summary-connect .requests-menu-timings-total")
.style.transform = "translateX(" + (scale * (blocked + dns)) + "px)";
$("#timings-summary-ssl .requests-menu-timings-total")
.style.transform = "translateX(" + (scale * blocked) + "px)";
$("#timings-summary-send .requests-menu-timings-total")
.style.transform =
"translateX(" + (scale * (blocked + dns + connect)) + "px)";

@ -478,6 +478,14 @@
<hbox class="requests-menu-timings-box connect"/>
<label class="plain requests-menu-timings-total"/>
</hbox>
<hbox id="timings-summary-ssl"
class="tabpanel-summary-container"
align="center">
<label class="plain tabpanel-summary-label"
data-localization="content=netmonitor.timings.ssl"/>
<hbox class="requests-menu-timings-box ssl"/>
<label class="plain requests-menu-timings-total"/>
</hbox>
<hbox id="timings-summary-send"
class="tabpanel-summary-container"
align="center">

@ -1099,7 +1099,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
*/
_createWaterfallView: function (item, timings, fromCache) {
let { target } = item;
let sections = ["blocked", "dns", "connect", "send", "wait", "receive"];
let sections = ["blocked", "dns", "connect", "ssl", "send", "wait", "receive"];
// Skipping "blocked" because it doesn't work yet.
let timingsNode = $(".requests-menu-timings", target);

@ -226,6 +226,8 @@ function test() {
"The eventTimings attachment has an incorrect |timings.blocked| property.");
is(typeof requestItem.attachment.eventTimings.timings.dns, "number",
"The eventTimings attachment has an incorrect |timings.dns| property.");
is(typeof requestItem.attachment.eventTimings.timings.ssl, "number",
"The eventTimings attachment has an incorrect |timings.ssl| property.");
is(typeof requestItem.attachment.eventTimings.timings.connect, "number",
"The eventTimings attachment has an incorrect |timings.connect| property.");
is(typeof requestItem.attachment.eventTimings.timings.send, "number",

@ -59,6 +59,7 @@
--timing-blocked-color: rgba(235, 83, 104, 0.8);
--timing-dns-color: rgba(223, 128, 255, 0.8); /* pink */
--timing-ssl-color: rgba(217, 102, 41, 0.8); /* orange */
--timing-connect-color: rgba(217, 102, 41, 0.8); /* orange */
--timing-send-color: rgba(70, 175, 227, 0.8); /* light blue */
--timing-wait-color: rgba(94, 136, 176, 0.8); /* blue grey */
@ -74,6 +75,7 @@
--timing-blocked-color: rgba(235, 83, 104, 0.8);
--timing-dns-color: rgba(223, 128, 255, 0.8); /* pink */
--timing-ssl-color: rgba(217, 102, 41, 0.8); /* orange */
--timing-connect-color: rgba(217, 102, 41, 0.8); /* orange */
--timing-send-color: rgba(0, 136, 204, 0.8); /* blue */
--timing-wait-color: rgba(95, 136, 176, 0.8); /* blue grey */
@ -505,6 +507,10 @@
background-color: var(--timing-connect-color);
}
.requests-menu-timings-box.ssl {
background-color: var(--timing-ssl-color);
}
.requests-menu-timings-box.send {
background-color: var(--timing-send-color);
}

@ -732,7 +732,9 @@ NetworkMonitor.prototype = {
0x804b0004: "STATUS_CONNECTED_TO",
0x804b0005: "STATUS_SENDING_TO",
0x804b000a: "STATUS_WAITING_FOR",
0x804b0006: "STATUS_RECEIVING_FROM"
0x804b0006: "STATUS_RECEIVING_FROM",
0x804b000c: "STATUS_TLS_STARTING",
0x804b000d: "STATUS_TLS_ENDING"
},
httpDownloadActivities: [
@ -1406,6 +1408,7 @@ NetworkMonitor.prototype = {
timings: {
blocked: 0,
dns: 0,
ssl: 0,
connect: 0,
send: 0,
wait: 0,
@ -1440,6 +1443,36 @@ NetworkMonitor.prototype = {
harTimings.connect = -1;
}
if (timings.STATUS_TLS_STARTING && timings.STATUS_TLS_ENDING) {
harTimings.ssl = timings.STATUS_TLS_ENDING.last -
timings.STATUS_TLS_STARTING.first;
} else {
harTimings.ssl = -1;
}
// sometimes the connection information events are attached to a speculative
// channel instead of this one, but necko might glue them back together in the
// nsITimedChannel interface used by Resource and Navigation Timing
let timedChannel = httpActivity.channel.QueryInterface(Ci.nsITimedChannel);
if ((harTimings.connect <= 0) && timedChannel) {
if (timedChannel.secureConnectionStartTime > timedChannel.connectStartTime) {
harTimings.connect =
timedChannel.secureConnectionStartTime - timedChannel.connectStartTime;
harTimings.ssl =
timedChannel.connectEndTime - timedChannel.secureConnectionStartTime;
} else {
harTimings.connect =
timedChannel.connectEndTime - timedChannel.connectStartTime;
harTimings.ssl = -1;
}
}
if ((harTimings.dns <= 0) && timedChannel) {
harTimings.dns =
timedChannel.domainLookupEndTime - timedChannel.domainLookupStartTime;
}
if (timings.STATUS_SENDING_TO) {
harTimings.send = timings.STATUS_SENDING_TO.last - timings.STATUS_SENDING_TO.first;
} else if (timings.REQUEST_HEADER && timings.REQUEST_BODY_SENT) {

@ -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();
}

@ -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

@ -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<int64_t>(ConnectStartHighRes());
}
DOMHighResTimeStamp
PerformanceTiming::SecureConnectionStartHighRes()
{
if (!nsContentUtils::IsPerformanceTimingEnabled() || !IsInitialized()) {
return mZeroTime;
}
return mSecureConnectionStart.IsNull() ? mZeroTime
: TimeStampToDOMHighRes(mSecureConnectionStart);
}
DOMTimeMilliSec
PerformanceTiming::SecureConnectionStart()
{
return static_cast<int64_t>(SecureConnectionStartHighRes());
}
DOMHighResTimeStamp
PerformanceTiming::ConnectEndHighRes()
{

@ -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;

@ -21,8 +21,7 @@ interface PerformanceTiming {
readonly attribute unsigned long long domainLookupEnd;
readonly attribute unsigned long long connectStart;
readonly attribute unsigned long long connectEnd;
// secureConnectionStart will be implemneted in bug 772589
// readonly attribute unsigned long long secureConnectionStart;
readonly attribute unsigned long long secureConnectionStart;
readonly attribute unsigned long long requestStart;
readonly attribute unsigned long long responseStart;
readonly attribute unsigned long long responseEnd;

@ -162,6 +162,8 @@ interface nsISocketTransport : nsITransport
const unsigned long STATUS_SENDING_TO = 0x804b0005;
const unsigned long STATUS_WAITING_FOR = 0x804b000a;
const unsigned long STATUS_RECEIVING_FROM = 0x804b0006;
const unsigned long STATUS_TLS_HANDSHAKE_STARTING = 0x804b000c;
const unsigned long STATUS_TLS_HANDSHAKE_ENDED = 0x804b000d;
/**
* connectionFlags is a bitmask that can be used to modify underlying

@ -31,6 +31,7 @@ interface nsITimedChannel : nsISupports {
[noscript] readonly attribute TimeStamp domainLookupStart;
[noscript] readonly attribute TimeStamp domainLookupEnd;
[noscript] readonly attribute TimeStamp connectStart;
[noscript] readonly attribute TimeStamp secureConnectionStart;
[noscript] readonly attribute TimeStamp connectEnd;
[noscript] readonly attribute TimeStamp requestStart;
[noscript] readonly attribute TimeStamp responseStart;
@ -69,6 +70,7 @@ interface nsITimedChannel : nsISupports {
readonly attribute PRTime domainLookupStartTime;
readonly attribute PRTime domainLookupEndTime;
readonly attribute PRTime connectStartTime;
readonly attribute PRTime secureConnectionStartTime;
readonly attribute PRTime connectEndTime;
readonly attribute PRTime requestStartTime;
readonly attribute PRTime responseStartTime;

@ -888,6 +888,11 @@ nsLoadGroup::TelemetryReportChannel(nsITimedChannel *aTimedChannel,
if (NS_FAILED(rv))
return;
TimeStamp secureConnectionStart;
rv = aTimedChannel->GetSecureConnectionStart(&secureConnectionStart);
if (NS_FAILED(rv))
return;
TimeStamp connectEnd;
rv = aTimedChannel->GetConnectEnd(&connectEnd);
if (NS_FAILED(rv))
@ -921,9 +926,15 @@ nsLoadGroup::TelemetryReportChannel(nsITimedChannel *aTimedChannel,
domainLookupStart, domainLookupEnd); \
} \
\
if (!secureConnectionStart.IsNull() && !connectEnd.IsNull()) { \
Telemetry::AccumulateTimeDelta( \
Telemetry::HTTP_##prefix##_TLS_HANDSHAKE, \
secureConnectionStart, connectEnd); \
} \
\
if (!connectStart.IsNull() && !connectEnd.IsNull()) { \
Telemetry::AccumulateTimeDelta( \
Telemetry::HTTP_##prefix##_TCP_CONNECTION, \
Telemetry::HTTP_##prefix##_TCP_CONNECTION_2, \
connectStart, connectEnd); \
} \
\

@ -147,6 +147,7 @@ struct ParamTraits<mozilla::net::ResourceTimingStruct>
WriteParam(aMsg, aParam.domainLookupStart);
WriteParam(aMsg, aParam.domainLookupEnd);
WriteParam(aMsg, aParam.connectStart);
WriteParam(aMsg, aParam.secureConnectionStart);
WriteParam(aMsg, aParam.connectEnd);
WriteParam(aMsg, aParam.requestStart);
WriteParam(aMsg, aParam.responseStart);
@ -169,6 +170,7 @@ struct ParamTraits<mozilla::net::ResourceTimingStruct>
return ReadParam(aMsg, aIter, &aResult->domainLookupStart) &&
ReadParam(aMsg, aIter, &aResult->domainLookupEnd) &&
ReadParam(aMsg, aIter, &aResult->connectStart) &&
ReadParam(aMsg, aIter, &aResult->secureConnectionStart) &&
ReadParam(aMsg, aIter, &aResult->connectEnd) &&
ReadParam(aMsg, aIter, &aResult->requestStart) &&
ReadParam(aMsg, aIter, &aResult->responseStart) &&

@ -2277,6 +2277,15 @@ Http2Session::OnTransportStatus(nsITransport* aTransport,
case NS_NET_STATUS_TLS_HANDSHAKE_ENDED:
{
Http2Stream *target = mStreamIDHash.Get(1);
if (!target) {
// any transaction will do if we can't find the low numbered one
// generally this happens when the initial transaction hasn't been
// assigned a stream id yet.
auto iter = mStreamTransactionHash.Iter();
if (!iter.Done()) {
target = iter.Data();
}
}
nsAHttpTransaction *transaction = target ? target->Transaction() : nullptr;
if (transaction)
transaction->OnTransportStatus(aTransport, aStatus, aProgress);

@ -3448,6 +3448,12 @@ HttpBaseChannel::GetConnectStart(TimeStamp* _retval) {
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetSecureConnectionStart(TimeStamp* _retval) {
*_retval = mTransactionTimings.secureConnectionStart;
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::GetConnectEnd(TimeStamp* _retval) {
*_retval = mTransactionTimings.connectEnd;
@ -3517,6 +3523,7 @@ IMPL_TIMING_ATTR(AsyncOpen)
IMPL_TIMING_ATTR(DomainLookupStart)
IMPL_TIMING_ATTR(DomainLookupEnd)
IMPL_TIMING_ATTR(ConnectStart)
IMPL_TIMING_ATTR(SecureConnectionStart)
IMPL_TIMING_ATTR(ConnectEnd)
IMPL_TIMING_ATTR(RequestStart)
IMPL_TIMING_ATTR(ResponseStart)

@ -893,6 +893,7 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
mTransactionTimings.domainLookupStart = timing.domainLookupStart;
mTransactionTimings.domainLookupEnd = timing.domainLookupEnd;
mTransactionTimings.connectStart = timing.connectStart;
mTransactionTimings.secureConnectionStart = timing.secureConnectionStart;
mTransactionTimings.connectEnd = timing.connectEnd;
mTransactionTimings.requestStart = timing.requestStart;
mTransactionTimings.responseStart = timing.responseStart;

@ -1216,6 +1216,7 @@ HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
mChannel->GetDomainLookupStart(&timing.domainLookupStart);
mChannel->GetDomainLookupEnd(&timing.domainLookupEnd);
mChannel->GetConnectStart(&timing.connectStart);
mChannel->GetSecureConnectionStart(&timing.secureConnectionStart);
mChannel->GetConnectEnd(&timing.connectEnd);
mChannel->GetRequestStart(&timing.requestStart);
mChannel->GetResponseStart(&timing.responseStart);

@ -585,6 +585,13 @@ NullHttpChannel::GetConnectStart(mozilla::TimeStamp *aConnectStart)
return NS_OK;
}
NS_IMETHODIMP
NullHttpChannel::GetSecureConnectionStart(mozilla::TimeStamp *aSecureConnectionStart)
{
*aSecureConnectionStart = mAsyncOpenTime;
return NS_OK;
}
NS_IMETHODIMP
NullHttpChannel::GetConnectEnd(mozilla::TimeStamp *aConnectEnd)
{
@ -757,6 +764,7 @@ IMPL_TIMING_ATTR(AsyncOpen)
IMPL_TIMING_ATTR(DomainLookupStart)
IMPL_TIMING_ATTR(DomainLookupEnd)
IMPL_TIMING_ATTR(ConnectStart)
IMPL_TIMING_ATTR(SecureConnectionStart)
IMPL_TIMING_ATTR(ConnectEnd)
IMPL_TIMING_ATTR(RequestStart)
IMPL_TIMING_ATTR(ResponseStart)

@ -162,6 +162,30 @@ void
NullHttpTransaction::OnTransportStatus(nsITransport* transport,
nsresult status, int64_t progress)
{
if (status == NS_NET_STATUS_RESOLVING_HOST) {
if (mTimings.domainLookupStart.IsNull()) {
mTimings.domainLookupStart = TimeStamp::Now();
}
} else if (status == NS_NET_STATUS_RESOLVED_HOST) {
if (mTimings.domainLookupEnd.IsNull()) {
mTimings.domainLookupEnd = TimeStamp::Now();
}
} else if (status == NS_NET_STATUS_CONNECTING_TO) {
if (mTimings.connectStart.IsNull()) {
mTimings.connectStart = TimeStamp::Now();
}
} else if (status == NS_NET_STATUS_CONNECTED_TO) {
if (mTimings.connectEnd.IsNull()) {
mTimings.connectEnd = TimeStamp::Now();
}
} else if (status == NS_NET_STATUS_TLS_HANDSHAKE_ENDED) {
if (mTimings.secureConnectionStart.IsNull() &&
!mTimings.connectEnd.IsNull()) {
mTimings.secureConnectionStart = mTimings.connectEnd;
}
mTimings.connectEnd = TimeStamp::Now();;
}
if (mActivityDistributor) {
NS_DispatchToMainThread(new CallObserveActivity(mActivityDistributor,
mConnectionInfo->GetOrigin(),

@ -9,6 +9,7 @@
#include "nsAHttpTransaction.h"
#include "mozilla/Attributes.h"
#include "TimingStruct.h"
// This is the minimal nsAHttpTransaction implementation. A NullHttpTransaction
// can be used to drive connection level semantics (such as SSL handshakes
@ -49,6 +50,8 @@ public:
return PR_SecondsToInterval(15);
}
TimingStruct Timings() { return mTimings; }
protected:
virtual ~NullHttpTransaction();
@ -68,6 +71,7 @@ private:
Atomic<uint32_t> mCapsToClear;
bool mIsDone;
bool mClaimed;
TimingStruct mTimings;
protected:
RefPtr<nsAHttpConnection> mConnection;

@ -14,6 +14,7 @@ struct TimingStruct {
TimeStamp domainLookupStart;
TimeStamp domainLookupEnd;
TimeStamp connectStart;
TimeStamp secureConnectionStart;
TimeStamp connectEnd;
TimeStamp requestStart;
TimeStamp responseStart;

@ -6429,6 +6429,15 @@ nsHttpChannel::GetConnectStart(TimeStamp* _retval) {
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetSecureConnectionStart(TimeStamp* _retval) {
if (mTransaction)
*_retval = mTransaction->GetSecureConnectionStart();
else
*_retval = mTransactionTimings.secureConnectionStart;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetConnectEnd(TimeStamp* _retval) {
if (mTransaction)

@ -165,6 +165,7 @@ public:
NS_IMETHOD GetDomainLookupStart(mozilla::TimeStamp *aDomainLookupStart) override;
NS_IMETHOD GetDomainLookupEnd(mozilla::TimeStamp *aDomainLookupEnd) override;
NS_IMETHOD GetConnectStart(mozilla::TimeStamp *aConnectStart) override;
NS_IMETHOD GetSecureConnectionStart(mozilla::TimeStamp *aSecureConnectionStart) override;
NS_IMETHOD GetConnectEnd(mozilla::TimeStamp *aConnectEnd) override;
NS_IMETHOD GetRequestStart(mozilla::TimeStamp *aRequestStart) override;
NS_IMETHOD GetResponseStart(mozilla::TimeStamp *aResponseStart) override;

@ -527,8 +527,15 @@ npnComplete:
mNPNComplete = true;
mTransaction->OnTransportStatus(mSocketTransport,
NS_NET_STATUS_TLS_HANDSHAKE_ENDED,
0);
NS_NET_STATUS_TLS_HANDSHAKE_ENDED, 0);
// this is happening after the bootstrap was originally written to. so update it.
if (mBootstrappedTimings.secureConnectionStart.IsNull() &&
!mBootstrappedTimings.connectEnd.IsNull()) {
mBootstrappedTimings.secureConnectionStart = mBootstrappedTimings.connectEnd;
mBootstrappedTimings.connectEnd = TimeStamp::Now();
}
if (mWaitingFor0RTTResponse) {
// Didn't get 0RTT OK, back out of the "attempting 0RTT" state
mWaitingFor0RTTResponse = false;
@ -572,8 +579,14 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, uint32_t caps, int32_t pri
LOG(("nsHttpConnection::Activate [this=%p trans=%p caps=%x]\n",
this, trans, caps));
if (!trans->IsNullTransaction())
if (!mExperienced && !trans->IsNullTransaction()) {
mExperienced = true;
nsHttpTransaction *hTrans = trans->QueryHttpTransaction();
if (hTrans) {
hTrans->BootstrapTimings(mBootstrappedTimings);
}
mBootstrappedTimings = TimingStruct();
}
mTransactionCaps = caps;
mPriority = pri;
@ -2414,5 +2427,11 @@ nsHttpConnection::CheckForTraffic(bool check)
}
}
void
nsHttpConnection::BootstrapTimings(TimingStruct times)
{
mBootstrappedTimings = times;
}
} // namespace net
} // namespace mozilla

@ -16,6 +16,7 @@
#include "TunnelUtils.h"
#include "mozilla/Mutex.h"
#include "ARefBase.h"
#include "TimingStruct.h"
#include "nsIAsyncInputStream.h"
#include "nsIAsyncOutputStream.h"
@ -379,6 +380,11 @@ private:
bool mEarlyDataNegotiated; //Only used for telemetry
nsCString mEarlyNegotiatedALPN;
bool mDid0RTTSpdy;
public:
void BootstrapTimings(TimingStruct times);
private:
TimingStruct mBootstrappedTimings;
};
} // namespace net

@ -3314,6 +3314,11 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out)
LOG(("nsHalfOpenSocket::OnOutputStreamReady "
"Created new nshttpconnection %p\n", conn.get()));
NullHttpTransaction *nullTrans = mTransaction->QueryNullTransaction();
if (nullTrans) {
conn->BootstrapTimings(nullTrans->Timings());
}
// Some capabilities are needed before a transaciton actually gets
// scheduled (e.g. how to negotiate false start)
conn->SetTransactionCaps(mTransaction->Caps());

@ -623,6 +623,14 @@ nsHttpTransaction::OnTransportStatus(nsITransport* transport,
} else if (status == NS_NET_STATUS_CONNECTED_TO) {
SetConnectEnd(TimeStamp::Now(), true);
} else if (status == NS_NET_STATUS_TLS_HANDSHAKE_ENDED) {
{
// before overwriting connectEnd, copy it to secureConnectionStart
MutexAutoLock lock(mLock);
if (mTimings.secureConnectionStart.IsNull() &&
!mTimings.connectEnd.IsNull()) {
mTimings.secureConnectionStart = mTimings.connectEnd;
}
}
SetConnectEnd(TimeStamp::Now(), false);
}
}
@ -2135,6 +2143,13 @@ nsHttpTransaction::Timings()
return timings;
}
void
nsHttpTransaction::BootstrapTimings(TimingStruct times)
{
mozilla::MutexAutoLock lock(mLock);
mTimings = times;
}
void
nsHttpTransaction::SetDomainLookupStart(mozilla::TimeStamp timeStamp, bool onlyIfNull)
{
@ -2226,6 +2241,13 @@ nsHttpTransaction::GetConnectStart()
return mTimings.connectStart;
}
mozilla::TimeStamp
nsHttpTransaction::GetSecureConnectionStart()
{
mozilla::MutexAutoLock lock(mLock);
return mTimings.secureConnectionStart;
}
mozilla::TimeStamp
nsHttpTransaction::GetConnectEnd()
{

@ -149,6 +149,7 @@ public:
// Locked methods to get and set timing info
const TimingStruct Timings();
void BootstrapTimings(TimingStruct times);
void SetDomainLookupStart(mozilla::TimeStamp timeStamp, bool onlyIfNull = false);
void SetDomainLookupEnd(mozilla::TimeStamp timeStamp, bool onlyIfNull = false);
void SetConnectStart(mozilla::TimeStamp timeStamp, bool onlyIfNull = false);
@ -160,6 +161,8 @@ public:
mozilla::TimeStamp GetDomainLookupStart();
mozilla::TimeStamp GetDomainLookupEnd();
mozilla::TimeStamp GetConnectStart();
mozilla::TimeStamp GetSecureConnectionStart();
mozilla::TimeStamp GetConnectEnd();
mozilla::TimeStamp GetRequestStart();
mozilla::TimeStamp GetResponseStart();

@ -50,6 +50,7 @@ netmonitor.properties:netmonitor.response.dimensions = netmonitor.dtd:netmonitor
netmonitor.properties:netmonitor.response.mime = netmonitor.dtd:netmonitorUI.response.mime
netmonitor.properties:netmonitor.timings.blocked = netmonitor.dtd:netmonitorUI.timings.blocked
netmonitor.properties:netmonitor.timings.dns = netmonitor.dtd:netmonitorUI.timings.dns
netmonitor.properties:netmonitor.timings.ssl = netmonitor.dtd:netmonitorUI.timings.ssl
netmonitor.properties:netmonitor.timings.connect = netmonitor.dtd:netmonitorUI.timings.connect
netmonitor.properties:netmonitor.timings.send = netmonitor.dtd:netmonitorUI.timings.send
netmonitor.properties:netmonitor.timings.wait = netmonitor.dtd:netmonitorUI.timings.wait

Loading…
Cancel
Save