Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef nsDashboard_h__ |
michael@0 | 6 | #define nsDashboard_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "mozilla/Mutex.h" |
michael@0 | 9 | #include "mozilla/net/DashboardTypes.h" |
michael@0 | 10 | #include "nsIDashboard.h" |
michael@0 | 11 | #include "nsIDashboardEventNotifier.h" |
michael@0 | 12 | #include "nsIDNSListener.h" |
michael@0 | 13 | #include "nsIServiceManager.h" |
michael@0 | 14 | #include "nsITimer.h" |
michael@0 | 15 | #include "nsITransport.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsIDNSService; |
michael@0 | 18 | class nsISocketTransport; |
michael@0 | 19 | class nsIThread; |
michael@0 | 20 | |
michael@0 | 21 | namespace mozilla { |
michael@0 | 22 | namespace net { |
michael@0 | 23 | |
michael@0 | 24 | class SocketData; |
michael@0 | 25 | class HttpData; |
michael@0 | 26 | class DnsData; |
michael@0 | 27 | class WebSocketRequest; |
michael@0 | 28 | class ConnectionData; |
michael@0 | 29 | |
michael@0 | 30 | class Dashboard |
michael@0 | 31 | : public nsIDashboard |
michael@0 | 32 | , public nsIDashboardEventNotifier |
michael@0 | 33 | { |
michael@0 | 34 | public: |
michael@0 | 35 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 36 | NS_DECL_NSIDASHBOARD |
michael@0 | 37 | NS_DECL_NSIDASHBOARDEVENTNOTIFIER |
michael@0 | 38 | |
michael@0 | 39 | Dashboard(); |
michael@0 | 40 | static const char *GetErrorString(nsresult rv); |
michael@0 | 41 | nsresult GetConnectionStatus(ConnectionData *aConnectionData); |
michael@0 | 42 | |
michael@0 | 43 | private: |
michael@0 | 44 | |
michael@0 | 45 | struct LogData |
michael@0 | 46 | { |
michael@0 | 47 | LogData(nsCString host, uint32_t serial, bool encryption): |
michael@0 | 48 | mHost(host), |
michael@0 | 49 | mSerial(serial), |
michael@0 | 50 | mMsgSent(0), |
michael@0 | 51 | mMsgReceived(0), |
michael@0 | 52 | mSizeSent(0), |
michael@0 | 53 | mSizeReceived(0), |
michael@0 | 54 | mEncrypted(encryption) |
michael@0 | 55 | { } |
michael@0 | 56 | nsCString mHost; |
michael@0 | 57 | uint32_t mSerial; |
michael@0 | 58 | uint32_t mMsgSent; |
michael@0 | 59 | uint32_t mMsgReceived; |
michael@0 | 60 | uint64_t mSizeSent; |
michael@0 | 61 | uint64_t mSizeReceived; |
michael@0 | 62 | bool mEncrypted; |
michael@0 | 63 | bool operator==(const LogData& a) const |
michael@0 | 64 | { |
michael@0 | 65 | return mHost.Equals(a.mHost) && (mSerial == a.mSerial); |
michael@0 | 66 | } |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | struct WebSocketData |
michael@0 | 70 | { |
michael@0 | 71 | WebSocketData():lock("Dashboard.webSocketData") |
michael@0 | 72 | { |
michael@0 | 73 | } |
michael@0 | 74 | uint32_t IndexOf(nsCString hostname, uint32_t mSerial) |
michael@0 | 75 | { |
michael@0 | 76 | LogData temp(hostname, mSerial, false); |
michael@0 | 77 | return data.IndexOf(temp); |
michael@0 | 78 | } |
michael@0 | 79 | nsTArray<LogData> data; |
michael@0 | 80 | mozilla::Mutex lock; |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | bool mEnableLogging; |
michael@0 | 85 | WebSocketData mWs; |
michael@0 | 86 | |
michael@0 | 87 | private: |
michael@0 | 88 | virtual ~Dashboard(); |
michael@0 | 89 | |
michael@0 | 90 | nsresult GetSocketsDispatch(SocketData *); |
michael@0 | 91 | nsresult GetHttpDispatch(HttpData *); |
michael@0 | 92 | nsresult GetDnsInfoDispatch(DnsData *); |
michael@0 | 93 | nsresult TestNewConnection(ConnectionData *); |
michael@0 | 94 | |
michael@0 | 95 | /* Helper methods that pass the JSON to the callback function. */ |
michael@0 | 96 | nsresult GetSockets(SocketData *); |
michael@0 | 97 | nsresult GetHttpConnections(HttpData *); |
michael@0 | 98 | nsresult GetDNSCacheEntries(DnsData *); |
michael@0 | 99 | nsresult GetWebSocketConnections(WebSocketRequest *); |
michael@0 | 100 | |
michael@0 | 101 | nsCOMPtr<nsIDNSService> mDnsService; |
michael@0 | 102 | }; |
michael@0 | 103 | |
michael@0 | 104 | } } // namespace mozilla::net |
michael@0 | 105 | #endif // nsDashboard_h__ |