Bug 1343600 - add TLS handshake Start/Stop events. r=:valentin
authorDragana Damjanovic <dd.mozilla@gmail.com>
Thu, 02 Mar 2017 03:07:00 +0100
changeset 374656 08df0e07f0ba02a27e532b25a0d3415166a6bba1
parent 374655 2cd83ad751203f5f91b1a1411fb930be9bff18c1
child 374657 fb3c9156f1b99c4b08e7c35b98ac27756c357687
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1343600
milestone54.0a1
Bug 1343600 - add TLS handshake Start/Stop events. r=:valentin
netwerk/base/Dashboard.cpp
netwerk/protocol/http/nsHttpConnection.cpp
netwerk/protocol/http/nsHttpTransaction.cpp
xpcom/base/ErrorList.h
--- a/netwerk/base/Dashboard.cpp
+++ b/netwerk/base/Dashboard.cpp
@@ -887,23 +887,25 @@ typedef struct
     nsresult key;
     const char *error;
 } ErrorEntry;
 
 #undef ERROR
 #define ERROR(key, val) {key, #key}
 
 ErrorEntry socketTransportStatuses[] = {
-        ERROR(NS_NET_STATUS_RESOLVING_HOST,  FAILURE(3)),
-        ERROR(NS_NET_STATUS_RESOLVED_HOST,   FAILURE(11)),
-        ERROR(NS_NET_STATUS_CONNECTING_TO,   FAILURE(7)),
-        ERROR(NS_NET_STATUS_CONNECTED_TO,    FAILURE(4)),
-        ERROR(NS_NET_STATUS_SENDING_TO,      FAILURE(5)),
-        ERROR(NS_NET_STATUS_WAITING_FOR,     FAILURE(10)),
-        ERROR(NS_NET_STATUS_RECEIVING_FROM,  FAILURE(6)),
+        ERROR(NS_NET_STATUS_RESOLVING_HOST,         FAILURE(3)),
+        ERROR(NS_NET_STATUS_RESOLVED_HOST,          FAILURE(11)),
+        ERROR(NS_NET_STATUS_CONNECTING_TO,          FAILURE(7)),
+        ERROR(NS_NET_STATUS_CONNECTED_TO,           FAILURE(4)),
+        ERROR(NS_NET_STATUS_TLS_HANDSHAKE_STARTING, FAILURE(12)),
+        ERROR(NS_NET_STATUS_TLS_HANDSHAKE_ENDED,    FAILURE(13)),
+        ERROR(NS_NET_STATUS_SENDING_TO,             FAILURE(5)),
+        ERROR(NS_NET_STATUS_WAITING_FOR,            FAILURE(10)),
+        ERROR(NS_NET_STATUS_RECEIVING_FROM,         FAILURE(6)),
 };
 #undef ERROR
 
 
 static void
 GetErrorString(nsresult rv, nsAString& errorString)
 {
     for (size_t i = 0; i < ArrayLength(socketTransportStatuses); ++i) {
--- a/netwerk/protocol/http/nsHttpConnection.cpp
+++ b/netwerk/protocol/http/nsHttpConnection.cpp
@@ -368,16 +368,23 @@ nsHttpConnection::EnsureNPNComplete(nsre
     if (!securityInfo) {
         goto npnComplete;
     }
 
     ssl = do_QueryInterface(securityInfo, &rv);
     if (NS_FAILED(rv))
         goto npnComplete;
 
+    if (!m0RTTChecked) {
+        // We reuse m0RTTChecked. We want to send this status only once.
+        mTransaction->OnTransportStatus(mSocketTransport,
+                                        NS_NET_STATUS_TLS_HANDSHAKE_STARTING,
+                                        0);
+    }
+
     rv = ssl->GetNegotiatedNPN(negotiatedNPN);
     if (!m0RTTChecked && (rv == NS_ERROR_NOT_CONNECTED) &&
         !mConnInfo->UsingProxy()) {
         // There is no ALPN info (yet!). We need to consider doing 0RTT. We
         // will do so if there is ALPN information from a previous session
         // (AlpnEarlySelection), we are using HTTP/1, and the request data can
         // be safely retried.
         m0RTTChecked = true;
@@ -513,16 +520,20 @@ nsHttpConnection::EnsureNPNComplete(nsre
         }
 
         Telemetry::Accumulate(Telemetry::SPDY_NPN_CONNECT, UsingSpdy());
     }
 
 npnComplete:
     LOG(("nsHttpConnection::EnsureNPNComplete [this=%p] setting complete to true", this));
     mNPNComplete = true;
+
+    mTransaction->OnTransportStatus(mSocketTransport,
+                                    NS_NET_STATUS_TLS_HANDSHAKE_ENDED,
+                                    0);
     if (mWaitingFor0RTTResponse) {
         // Didn't get 0RTT OK, back out of the "attempting 0RTT" state
         mWaitingFor0RTTResponse = false;
         LOG(("nsHttpConnection::EnsureNPNComplete [this=%p] 0rtt failed", this));
         if (NS_FAILED(mTransaction->Finish0RTT(true, negotiatedNPN != mEarlyNegotiatedALPN))) {
             mTransaction->Close(NS_ERROR_NET_RESET);
         }
         mContentBytesWritten0RTT = 0;
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -599,17 +599,19 @@ nsHttpTransaction::OnTransportStatus(nsI
     if (TimingEnabled() && GetRequestStart().IsNull()) {
         if (status == NS_NET_STATUS_RESOLVING_HOST) {
             SetDomainLookupStart(TimeStamp::Now(), true);
         } else if (status == NS_NET_STATUS_RESOLVED_HOST) {
             SetDomainLookupEnd(TimeStamp::Now());
         } else if (status == NS_NET_STATUS_CONNECTING_TO) {
             SetConnectStart(TimeStamp::Now());
         } else if (status == NS_NET_STATUS_CONNECTED_TO) {
-            SetConnectEnd(TimeStamp::Now());
+            SetConnectEnd(TimeStamp::Now(), true);
+        } else if (status == NS_NET_STATUS_TLS_HANDSHAKE_ENDED) {
+            SetConnectEnd(TimeStamp::Now(), false);
         }
     }
 
     if (!mTransportSink)
         return;
 
     MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
--- a/xpcom/base/ErrorList.h
+++ b/xpcom/base/ErrorList.h
@@ -325,23 +325,25 @@
 
   /* These are really not "results", they're statuses, used by nsITransport and
    * friends.  This is abuse of nsresult, but we'll put up with it for now. */
   /* nsITransport */
   ERROR(NS_NET_STATUS_READING,  FAILURE(8)),
   ERROR(NS_NET_STATUS_WRITING,  FAILURE(9)),
 
   /* nsISocketTransport */
-  ERROR(NS_NET_STATUS_RESOLVING_HOST,  FAILURE(3)),
-  ERROR(NS_NET_STATUS_RESOLVED_HOST,   FAILURE(11)),
-  ERROR(NS_NET_STATUS_CONNECTING_TO,   FAILURE(7)),
-  ERROR(NS_NET_STATUS_CONNECTED_TO,    FAILURE(4)),
-  ERROR(NS_NET_STATUS_SENDING_TO,      FAILURE(5)),
-  ERROR(NS_NET_STATUS_WAITING_FOR,     FAILURE(10)),
-  ERROR(NS_NET_STATUS_RECEIVING_FROM,  FAILURE(6)),
+  ERROR(NS_NET_STATUS_RESOLVING_HOST,         FAILURE(3)),
+  ERROR(NS_NET_STATUS_RESOLVED_HOST,          FAILURE(11)),
+  ERROR(NS_NET_STATUS_CONNECTING_TO,          FAILURE(7)),
+  ERROR(NS_NET_STATUS_CONNECTED_TO,           FAILURE(4)),
+  ERROR(NS_NET_STATUS_TLS_HANDSHAKE_STARTING, FAILURE(12)),
+  ERROR(NS_NET_STATUS_TLS_HANDSHAKE_ENDED,    FAILURE(13)),
+  ERROR(NS_NET_STATUS_SENDING_TO,             FAILURE(5)),
+  ERROR(NS_NET_STATUS_WAITING_FOR,            FAILURE(10)),
+  ERROR(NS_NET_STATUS_RECEIVING_FROM,         FAILURE(6)),
 
   /* nsIInterceptedChannel */
   /* Generic error for non-specific failures during service worker interception */
   ERROR(NS_ERROR_INTERCEPTION_FAILED,                  FAILURE(100)),
 
   /* nsIHstsPrimingListener */
   /* Error code for HSTS priming timeout to distinguish from blocking */
   ERROR(NS_ERROR_HSTS_PRIMING_TIMEOUT, FAILURE(110)),