зеркало из https://github.com/mozilla/gecko-dev.git
Bug 888583 - Expose protocol version in about:networking. r=mcmanus
This commit is contained in:
Родитель
d40cf81f32
Коммит
438700f162
|
@ -15,8 +15,9 @@ dictionary SocketsDict {
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary HttpConnInfoDict {
|
dictionary HttpConnInfoDict {
|
||||||
sequence<unsigned long> rtt;
|
sequence<unsigned long> rtt;
|
||||||
sequence<unsigned long> ttl;
|
sequence<unsigned long> ttl;
|
||||||
|
sequence<DOMString> protocolVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary HttpConnDict {
|
dictionary HttpConnDict {
|
||||||
|
|
|
@ -165,10 +165,13 @@ Dashboard::GetHttpConnections()
|
||||||
HttpConnInfoDict &activeInfo = *active.AppendElement();
|
HttpConnInfoDict &activeInfo = *active.AppendElement();
|
||||||
activeInfo.mRtt.Construct();
|
activeInfo.mRtt.Construct();
|
||||||
activeInfo.mTtl.Construct();
|
activeInfo.mTtl.Construct();
|
||||||
|
activeInfo.mProtocolVersion.Construct();
|
||||||
Sequence<uint32_t> &active_rtt = activeInfo.mRtt.Value();
|
Sequence<uint32_t> &active_rtt = activeInfo.mRtt.Value();
|
||||||
Sequence<uint32_t> &active_ttl = activeInfo.mTtl.Value();
|
Sequence<uint32_t> &active_ttl = activeInfo.mTtl.Value();
|
||||||
|
Sequence<nsString> &active_protocolVersion = activeInfo.mProtocolVersion.Value();
|
||||||
if (!active_rtt.SetCapacity(mHttp.data[i].active.Length()) ||
|
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.cb = nullptr;
|
||||||
mHttp.data.Clear();
|
mHttp.data.Clear();
|
||||||
JS_ReportOutOfMemory(cx);
|
JS_ReportOutOfMemory(cx);
|
||||||
|
@ -177,15 +180,19 @@ Dashboard::GetHttpConnections()
|
||||||
for (uint32_t j = 0; j < mHttp.data[i].active.Length(); j++) {
|
for (uint32_t j = 0; j < mHttp.data[i].active.Length(); j++) {
|
||||||
*active_rtt.AppendElement() = mHttp.data[i].active[j].rtt;
|
*active_rtt.AppendElement() = mHttp.data[i].active[j].rtt;
|
||||||
*active_ttl.AppendElement() = mHttp.data[i].active[j].ttl;
|
*active_ttl.AppendElement() = mHttp.data[i].active[j].ttl;
|
||||||
|
*active_protocolVersion.AppendElement() = mHttp.data[i].active[j].protocolVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpConnInfoDict &idleInfo = *idle.AppendElement();
|
HttpConnInfoDict &idleInfo = *idle.AppendElement();
|
||||||
idleInfo.mRtt.Construct();
|
idleInfo.mRtt.Construct();
|
||||||
idleInfo.mTtl.Construct();
|
idleInfo.mTtl.Construct();
|
||||||
|
idleInfo.mProtocolVersion.Construct();
|
||||||
Sequence<uint32_t> &idle_rtt = idleInfo.mRtt.Value();
|
Sequence<uint32_t> &idle_rtt = idleInfo.mRtt.Value();
|
||||||
Sequence<uint32_t> &idle_ttl = idleInfo.mTtl.Value();
|
Sequence<uint32_t> &idle_ttl = idleInfo.mTtl.Value();
|
||||||
|
Sequence<nsString> &idle_protocolVersion = idleInfo.mProtocolVersion.Value();
|
||||||
if (!idle_rtt.SetCapacity(mHttp.data[i].idle.Length()) ||
|
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.cb = nullptr;
|
||||||
mHttp.data.Clear();
|
mHttp.data.Clear();
|
||||||
JS_ReportOutOfMemory(cx);
|
JS_ReportOutOfMemory(cx);
|
||||||
|
@ -194,6 +201,7 @@ Dashboard::GetHttpConnections()
|
||||||
for (uint32_t j = 0; j < mHttp.data[i].idle.Length(); j++) {
|
for (uint32_t j = 0; j < mHttp.data[i].idle.Length(); j++) {
|
||||||
*idle_rtt.AppendElement() = mHttp.data[i].idle[j].rtt;
|
*idle_rtt.AppendElement() = mHttp.data[i].idle[j].rtt;
|
||||||
*idle_ttl.AppendElement() = mHttp.data[i].idle[j].ttl;
|
*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;
|
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
|
} } // namespace mozilla::net
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "nsIThread.h"
|
#include "nsIThread.h"
|
||||||
#include "nsSocketTransport2.h"
|
#include "nsSocketTransport2.h"
|
||||||
#include "mozilla/net/DashboardTypes.h"
|
#include "mozilla/net/DashboardTypes.h"
|
||||||
|
#include "nsHttp.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
|
@ -34,6 +34,10 @@ struct HttpConnInfo
|
||||||
{
|
{
|
||||||
uint32_t ttl;
|
uint32_t ttl;
|
||||||
uint32_t rtt;
|
uint32_t rtt;
|
||||||
|
nsString protocolVersion;
|
||||||
|
|
||||||
|
void SetHTTP1ProtocolVersion(uint8_t pv);
|
||||||
|
void SetHTTP2ProtocolVersion(uint8_t pv);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HttpRetParams
|
struct HttpRetParams
|
||||||
|
|
|
@ -71,6 +71,7 @@ nsHttpConnection::nsHttpConnection()
|
||||||
, mReportedSpdy(false)
|
, mReportedSpdy(false)
|
||||||
, mEverUsedSpdy(false)
|
, mEverUsedSpdy(false)
|
||||||
, mTransactionCaps(0)
|
, mTransactionCaps(0)
|
||||||
|
, mLastHttpResponseVersion(NS_HTTP_VERSION_1_1)
|
||||||
{
|
{
|
||||||
LOG(("Creating nsHttpConnection @%x\n", this));
|
LOG(("Creating nsHttpConnection @%x\n", this));
|
||||||
|
|
||||||
|
@ -886,6 +887,8 @@ nsHttpConnection::OnHeadersAvailable(nsAHttpTransaction *trans,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mLastHttpResponseVersion = responseHead->Version();
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ public:
|
||||||
nsresult ResumeSend();
|
nsresult ResumeSend();
|
||||||
nsresult ResumeRecv();
|
nsresult ResumeRecv();
|
||||||
int64_t MaxBytesRead() {return mMaxBytesRead;}
|
int64_t MaxBytesRead() {return mMaxBytesRead;}
|
||||||
|
uint8_t GetLastHttpResponseVersion() { return mLastHttpResponseVersion; }
|
||||||
|
|
||||||
friend class nsHttpConnectionForceRecv;
|
friend class nsHttpConnectionForceRecv;
|
||||||
nsresult ForceRecv();
|
nsresult ForceRecv();
|
||||||
|
@ -134,6 +135,7 @@ public:
|
||||||
void EndIdleMonitoring();
|
void EndIdleMonitoring();
|
||||||
|
|
||||||
bool UsingSpdy() { return !!mUsingSpdyVersion; }
|
bool UsingSpdy() { return !!mUsingSpdyVersion; }
|
||||||
|
uint8_t GetSpdyVersion() { return mUsingSpdyVersion; }
|
||||||
bool EverUsedSpdy() { return mEverUsedSpdy; }
|
bool EverUsedSpdy() { return mEverUsedSpdy; }
|
||||||
PRIntervalTime Rtt() { return mRtt; }
|
PRIntervalTime Rtt() { return mRtt; }
|
||||||
|
|
||||||
|
@ -255,6 +257,9 @@ private:
|
||||||
|
|
||||||
// The capabailities associated with the most recent transaction
|
// The capabailities associated with the most recent transaction
|
||||||
uint32_t mTransactionCaps;
|
uint32_t mTransactionCaps;
|
||||||
|
|
||||||
|
// mLastHttpResponseVersion stores the last response's http version seen.
|
||||||
|
uint8_t mLastHttpResponseVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsHttpConnection_h__
|
#endif // nsHttpConnection_h__
|
||||||
|
|
|
@ -3321,12 +3321,18 @@ nsHttpConnectionMgr::ReadConnectionEntry(const nsACString &key,
|
||||||
HttpConnInfo info;
|
HttpConnInfo info;
|
||||||
info.ttl = ent->mActiveConns[i]->TimeToLive();
|
info.ttl = ent->mActiveConns[i]->TimeToLive();
|
||||||
info.rtt = ent->mActiveConns[i]->Rtt();
|
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);
|
data.active.AppendElement(info);
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < ent->mIdleConns.Length(); i++) {
|
for (uint32_t i = 0; i < ent->mIdleConns.Length(); i++) {
|
||||||
HttpConnInfo info;
|
HttpConnInfo info;
|
||||||
info.ttl = ent->mIdleConns[i]->TimeToLive();
|
info.ttl = ent->mIdleConns[i]->TimeToLive();
|
||||||
info.rtt = ent->mIdleConns[i]->Rtt();
|
info.rtt = ent->mIdleConns[i]->Rtt();
|
||||||
|
info.SetHTTP1ProtocolVersion(ent->mIdleConns[i]->GetLastHttpResponseVersion());
|
||||||
data.idle.AppendElement(info);
|
data.idle.AppendElement(info);
|
||||||
}
|
}
|
||||||
data.spdy = ent->mUsingSpdy;
|
data.spdy = ent->mUsingSpdy;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче