Bug 1845134 - Part 4: Update existing ui-icons to use the latest source from acorn...
[gecko.git] / netwerk / base / Dashboard.h
blob1112a013e9d89b5abd788ee03a55620988378e03
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsDashboard_h__
6 #define nsDashboard_h__
8 #include "mozilla/Mutex.h"
9 #include "mozilla/net/DashboardTypes.h"
10 #include "nsIDashboard.h"
11 #include "nsIDashboardEventNotifier.h"
13 class nsIDNSService;
15 namespace mozilla {
16 namespace net {
18 class SocketData;
19 class HttpData;
20 class DnsData;
21 class WebSocketRequest;
22 class ConnectionData;
23 class RcwnData;
25 class Dashboard final : public nsIDashboard, public nsIDashboardEventNotifier {
26 public:
27 NS_DECL_THREADSAFE_ISUPPORTS
28 NS_DECL_NSIDASHBOARD
29 NS_DECL_NSIDASHBOARDEVENTNOTIFIER
31 Dashboard();
32 static const char* GetErrorString(nsresult rv);
33 nsresult GetConnectionStatus(ConnectionData* aConnectionData);
35 private:
36 struct LogData {
37 LogData(nsCString host, uint32_t serial, bool encryption)
38 : mHost(host),
39 mSerial(serial),
40 mMsgSent(0),
41 mMsgReceived(0),
42 mSizeSent(0),
43 mSizeReceived(0),
44 mEncrypted(encryption) {}
45 nsCString mHost;
46 uint32_t mSerial;
47 uint32_t mMsgSent;
48 uint32_t mMsgReceived;
49 uint64_t mSizeSent;
50 uint64_t mSizeReceived;
51 bool mEncrypted;
52 bool operator==(const LogData& a) const {
53 return mHost.Equals(a.mHost) && (mSerial == a.mSerial);
57 struct WebSocketData {
58 WebSocketData() : lock("Dashboard.webSocketData") {}
59 uint32_t IndexOf(const nsCString& hostname, uint32_t mSerial) {
60 LogData temp(hostname, mSerial, false);
61 return data.IndexOf(temp);
63 nsTArray<LogData> data;
64 mozilla::Mutex lock MOZ_UNANNOTATED;
67 bool mEnableLogging;
68 WebSocketData mWs;
70 private:
71 virtual ~Dashboard() = default;
73 nsresult GetSocketsDispatch(SocketData*);
74 nsresult GetHttpDispatch(HttpData*);
75 nsresult GetDnsInfoDispatch(DnsData*);
76 nsresult TestNewConnection(ConnectionData*);
78 /* Helper methods that pass the JSON to the callback function. */
79 nsresult GetSockets(SocketData*);
80 nsresult GetHttpConnections(HttpData*);
81 nsresult GetDNSCacheEntries(DnsData*);
82 nsresult GetWebSocketConnections(WebSocketRequest*);
83 nsresult GetRcwnData(RcwnData*);
85 nsCOMPtr<nsIDNSService> mDnsService;
88 } // namespace net
89 } // namespace mozilla
91 #endif // nsDashboard_h__