Bug 897910 - Trace data sent or received by Firefox. r=mcmanus

This commit is contained in:
Robert Bindar 2013-07-29 12:08:03 -04:00
parent cfbcf3f69e
commit 343917fd58
3 changed files with 18 additions and 3 deletions

View File

@ -42,8 +42,11 @@ Dashboard::RequestSockets(NetDashboardCallback* cb)
void
Dashboard::GetSocketsDispatch()
{
if (gSocketTransportService)
if (gSocketTransportService) {
gSocketTransportService->GetSocketConnections(&mSock.data);
mSock.totalSent = gSocketTransportService->GetSentBytes();
mSock.totalRecv = gSocketTransportService->GetReceivedBytes();
}
nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &Dashboard::GetSockets);
mSock.thread->Dispatch(event, NS_DISPATCH_NORMAL);
}
@ -91,6 +94,9 @@ Dashboard::GetSockets()
dict.mReceived += mSock.data[i].received;
}
dict.mSent += mSock.totalSent;
dict.mReceived += mSock.totalRecv;
JS::RootedValue val(cx);
if (!dict.ToObject(cx, JS::NullPtr(), &val)) {
mSock.cb = nullptr;

View File

@ -59,6 +59,8 @@ nsSocketTransportService::nsSocketTransportService()
, mIdleListSize(SOCKET_LIMIT_MIN)
, mActiveCount(0)
, mIdleCount(0)
, mSentBytesCount(0)
, mReceivedBytesCount(0)
, mSendBufferSize(0)
, mProbedMaxCount(false)
{
@ -178,6 +180,8 @@ nsSocketTransportService::DetachSocket(SocketContext *listHead, SocketContext *s
// inform the handler that this socket is going away
sock->mHandler->OnSocketDetached(sock->mFD);
mSentBytesCount += sock->mHandler->ByteCountSent();
mReceivedBytesCount += sock->mHandler->ByteCountReceived();
// cleanup
sock->mFD = nullptr;

View File

@ -74,9 +74,11 @@ public:
return mActiveCount + mIdleCount < gMaxCount;
}
// Called by the networking dashboard
// Called by the networking dashboard on the socket thread only
// Fills the passed array with socket information
void GetSocketConnections(nsTArray<mozilla::net::SocketInfo> *);
uint64_t GetSentBytes() { return mSentBytesCount; }
uint64_t GetReceivedBytes() { return mReceivedBytesCount; }
protected:
virtual ~nsSocketTransportService();
@ -154,7 +156,10 @@ private:
bool GrowActiveList();
bool GrowIdleList();
void InitMaxCount();
// Total bytes number transfered through all the sockets except active ones
uint64_t mSentBytesCount;
uint64_t mReceivedBytesCount;
//-------------------------------------------------------------------------
// poll list (socket thread only)
//