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"
21 class WebSocketRequest
;
25 class Dashboard final
: public nsIDashboard
, public nsIDashboardEventNotifier
{
27 NS_DECL_THREADSAFE_ISUPPORTS
29 NS_DECL_NSIDASHBOARDEVENTNOTIFIER
32 static const char* GetErrorString(nsresult rv
);
33 nsresult
GetConnectionStatus(ConnectionData
* aConnectionData
);
37 LogData(nsCString host
, uint32_t serial
, bool encryption
)
44 mEncrypted(encryption
) {}
48 uint32_t mMsgReceived
;
50 uint64_t mSizeReceived
;
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
;
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
;
89 } // namespace mozilla
91 #endif // nsDashboard_h__