michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsDashboard_h__ michael@0: #define nsDashboard_h__ michael@0: michael@0: #include "mozilla/Mutex.h" michael@0: #include "mozilla/net/DashboardTypes.h" michael@0: #include "nsIDashboard.h" michael@0: #include "nsIDashboardEventNotifier.h" michael@0: #include "nsIDNSListener.h" michael@0: #include "nsIServiceManager.h" michael@0: #include "nsITimer.h" michael@0: #include "nsITransport.h" michael@0: michael@0: class nsIDNSService; michael@0: class nsISocketTransport; michael@0: class nsIThread; michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: class SocketData; michael@0: class HttpData; michael@0: class DnsData; michael@0: class WebSocketRequest; michael@0: class ConnectionData; michael@0: michael@0: class Dashboard michael@0: : public nsIDashboard michael@0: , public nsIDashboardEventNotifier michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIDASHBOARD michael@0: NS_DECL_NSIDASHBOARDEVENTNOTIFIER michael@0: michael@0: Dashboard(); michael@0: static const char *GetErrorString(nsresult rv); michael@0: nsresult GetConnectionStatus(ConnectionData *aConnectionData); michael@0: michael@0: private: michael@0: michael@0: struct LogData michael@0: { michael@0: LogData(nsCString host, uint32_t serial, bool encryption): michael@0: mHost(host), michael@0: mSerial(serial), michael@0: mMsgSent(0), michael@0: mMsgReceived(0), michael@0: mSizeSent(0), michael@0: mSizeReceived(0), michael@0: mEncrypted(encryption) michael@0: { } michael@0: nsCString mHost; michael@0: uint32_t mSerial; michael@0: uint32_t mMsgSent; michael@0: uint32_t mMsgReceived; michael@0: uint64_t mSizeSent; michael@0: uint64_t mSizeReceived; michael@0: bool mEncrypted; michael@0: bool operator==(const LogData& a) const michael@0: { michael@0: return mHost.Equals(a.mHost) && (mSerial == a.mSerial); michael@0: } michael@0: }; michael@0: michael@0: struct WebSocketData michael@0: { michael@0: WebSocketData():lock("Dashboard.webSocketData") michael@0: { michael@0: } michael@0: uint32_t IndexOf(nsCString hostname, uint32_t mSerial) michael@0: { michael@0: LogData temp(hostname, mSerial, false); michael@0: return data.IndexOf(temp); michael@0: } michael@0: nsTArray data; michael@0: mozilla::Mutex lock; michael@0: }; michael@0: michael@0: michael@0: bool mEnableLogging; michael@0: WebSocketData mWs; michael@0: michael@0: private: michael@0: virtual ~Dashboard(); michael@0: michael@0: nsresult GetSocketsDispatch(SocketData *); michael@0: nsresult GetHttpDispatch(HttpData *); michael@0: nsresult GetDnsInfoDispatch(DnsData *); michael@0: nsresult TestNewConnection(ConnectionData *); michael@0: michael@0: /* Helper methods that pass the JSON to the callback function. */ michael@0: nsresult GetSockets(SocketData *); michael@0: nsresult GetHttpConnections(HttpData *); michael@0: nsresult GetDNSCacheEntries(DnsData *); michael@0: nsresult GetWebSocketConnections(WebSocketRequest *); michael@0: michael@0: nsCOMPtr mDnsService; michael@0: }; michael@0: michael@0: } } // namespace mozilla::net michael@0: #endif // nsDashboard_h__