diff --git a/dom/webidl/NetDashboard.webidl b/dom/webidl/NetDashboard.webidl index f5c59b79ea42..45692e04c61a 100644 --- a/dom/webidl/NetDashboard.webidl +++ b/dom/webidl/NetDashboard.webidl @@ -15,8 +15,9 @@ dictionary SocketsDict { }; dictionary HttpConnInfoDict { - sequence rtt; - sequence ttl; + sequence rtt; + sequence ttl; + sequence protocolVersion; }; dictionary HttpConnDict { diff --git a/netwerk/base/src/Dashboard.cpp b/netwerk/base/src/Dashboard.cpp index f1ff064cface..3fb9ff7f5806 100644 --- a/netwerk/base/src/Dashboard.cpp +++ b/netwerk/base/src/Dashboard.cpp @@ -165,10 +165,13 @@ Dashboard::GetHttpConnections() HttpConnInfoDict &activeInfo = *active.AppendElement(); activeInfo.mRtt.Construct(); activeInfo.mTtl.Construct(); + activeInfo.mProtocolVersion.Construct(); Sequence &active_rtt = activeInfo.mRtt.Value(); Sequence &active_ttl = activeInfo.mTtl.Value(); + Sequence &active_protocolVersion = activeInfo.mProtocolVersion.Value(); if (!active_rtt.SetCapacity(mHttp.data[i].active.Length()) || - !active_ttl.SetCapacity(mHttp.data[i].active.Length())) { + !active_ttl.SetCapacity(mHttp.data[i].active.Length()) || + !active_protocolVersion.SetCapacity(mHttp.data[i].active.Length())) { mHttp.cb = nullptr; mHttp.data.Clear(); JS_ReportOutOfMemory(cx); @@ -177,15 +180,19 @@ Dashboard::GetHttpConnections() for (uint32_t j = 0; j < mHttp.data[i].active.Length(); j++) { *active_rtt.AppendElement() = mHttp.data[i].active[j].rtt; *active_ttl.AppendElement() = mHttp.data[i].active[j].ttl; + *active_protocolVersion.AppendElement() = mHttp.data[i].active[j].protocolVersion; } HttpConnInfoDict &idleInfo = *idle.AppendElement(); idleInfo.mRtt.Construct(); idleInfo.mTtl.Construct(); + idleInfo.mProtocolVersion.Construct(); Sequence &idle_rtt = idleInfo.mRtt.Value(); Sequence &idle_ttl = idleInfo.mTtl.Value(); + Sequence &idle_protocolVersion = idleInfo.mProtocolVersion.Value(); if (!idle_rtt.SetCapacity(mHttp.data[i].idle.Length()) || - !idle_ttl.SetCapacity(mHttp.data[i].idle.Length())) { + !idle_ttl.SetCapacity(mHttp.data[i].idle.Length()) || + !idle_protocolVersion.SetCapacity(mHttp.data[i].idle.Length())) { mHttp.cb = nullptr; mHttp.data.Clear(); JS_ReportOutOfMemory(cx); @@ -194,6 +201,7 @@ Dashboard::GetHttpConnections() for (uint32_t j = 0; j < mHttp.data[i].idle.Length(); j++) { *idle_rtt.AppendElement() = mHttp.data[i].idle[j].rtt; *idle_ttl.AppendElement() = mHttp.data[i].idle[j].ttl; + *idle_protocolVersion.AppendElement() = mHttp.data[i].idle[j].protocolVersion; } } @@ -436,4 +444,31 @@ Dashboard::GetDNSCacheEntries() return NS_OK; } +void +HttpConnInfo::SetHTTP1ProtocolVersion(uint8_t pv) +{ + switch (pv) { + case NS_HTTP_VERSION_0_9: + protocolVersion.Assign(NS_LITERAL_STRING("http/0.9")); + break; + case NS_HTTP_VERSION_1_0: + protocolVersion.Assign(NS_LITERAL_STRING("http/1.0")); + break; + case NS_HTTP_VERSION_1_1: + protocolVersion.Assign(NS_LITERAL_STRING("http/1.1")); + break; + default: + protocolVersion.Assign(NS_LITERAL_STRING("unknown protocol version")); + } +} + +void +HttpConnInfo::SetHTTP2ProtocolVersion(uint8_t pv) +{ + if (pv == Spdy::SPDY_VERSION_2) + protocolVersion.Assign(NS_LITERAL_STRING("spdy/2")); + else + protocolVersion.Assign(NS_LITERAL_STRING("spdy/3")); +} + } } // namespace mozilla::net diff --git a/netwerk/base/src/Dashboard.h b/netwerk/base/src/Dashboard.h index 3cad4c55750b..5c2e1e406d09 100644 --- a/netwerk/base/src/Dashboard.h +++ b/netwerk/base/src/Dashboard.h @@ -14,6 +14,7 @@ #include "nsIThread.h" #include "nsSocketTransport2.h" #include "mozilla/net/DashboardTypes.h" +#include "nsHttp.h" namespace mozilla { namespace net { diff --git a/netwerk/base/src/DashboardTypes.h b/netwerk/base/src/DashboardTypes.h index 9838982172b9..954c72462aa2 100644 --- a/netwerk/base/src/DashboardTypes.h +++ b/netwerk/base/src/DashboardTypes.h @@ -34,6 +34,10 @@ struct HttpConnInfo { uint32_t ttl; uint32_t rtt; + nsString protocolVersion; + + void SetHTTP1ProtocolVersion(uint8_t pv); + void SetHTTP2ProtocolVersion(uint8_t pv); }; struct HttpRetParams diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index 2a46db3b7323..bf71e24d2cf1 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -71,6 +71,7 @@ nsHttpConnection::nsHttpConnection() , mReportedSpdy(false) , mEverUsedSpdy(false) , mTransactionCaps(0) + , mLastHttpResponseVersion(NS_HTTP_VERSION_1_1) { LOG(("Creating nsHttpConnection @%x\n", this)); @@ -886,6 +887,8 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans, } } + mLastHttpResponseVersion = responseHead->Version(); + return NS_OK; } diff --git a/netwerk/protocol/http/nsHttpConnection.h b/netwerk/protocol/http/nsHttpConnection.h index a5c1e7d1c85e..ef3808e3d4cf 100644 --- a/netwerk/protocol/http/nsHttpConnection.h +++ b/netwerk/protocol/http/nsHttpConnection.h @@ -119,6 +119,7 @@ public: nsresult ResumeSend(); nsresult ResumeRecv(); int64_t MaxBytesRead() {return mMaxBytesRead;} + uint8_t GetLastHttpResponseVersion() { return mLastHttpResponseVersion; } friend class nsHttpConnectionForceRecv; nsresult ForceRecv(); @@ -134,6 +135,7 @@ public: void EndIdleMonitoring(); bool UsingSpdy() { return !!mUsingSpdyVersion; } + uint8_t GetSpdyVersion() { return mUsingSpdyVersion; } bool EverUsedSpdy() { return mEverUsedSpdy; } PRIntervalTime Rtt() { return mRtt; } @@ -255,6 +257,9 @@ private: // The capabailities associated with the most recent transaction uint32_t mTransactionCaps; + + // mLastHttpResponseVersion stores the last response's http version seen. + uint8_t mLastHttpResponseVersion; }; #endif // nsHttpConnection_h__ diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 0c761bae10e5..797b33f9a83d 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -3321,12 +3321,18 @@ nsHttpConnectionMgr::ReadConnectionEntry(const nsACString &key, HttpConnInfo info; info.ttl = ent->mActiveConns[i]->TimeToLive(); info.rtt = ent->mActiveConns[i]->Rtt(); + if (ent->mActiveConns[i]->UsingSpdy()) + info.SetHTTP2ProtocolVersion(ent->mActiveConns[i]->GetSpdyVersion()); + else + info.SetHTTP1ProtocolVersion(ent->mActiveConns[i]->GetLastHttpResponseVersion()); + data.active.AppendElement(info); } for (uint32_t i = 0; i < ent->mIdleConns.Length(); i++) { HttpConnInfo info; info.ttl = ent->mIdleConns[i]->TimeToLive(); info.rtt = ent->mIdleConns[i]->Rtt(); + info.SetHTTP1ProtocolVersion(ent->mIdleConns[i]->GetLastHttpResponseVersion()); data.idle.AppendElement(info); } data.spdy = ent->mUsingSpdy;