2012-12-10 18:13:55 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef nsDashboard_h__
|
|
|
|
#define nsDashboard_h__
|
|
|
|
|
2013-09-06 00:12:38 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "mozilla/net/DashboardTypes.h"
|
2012-12-10 18:13:55 +04:00
|
|
|
#include "nsIDashboard.h"
|
2013-09-23 07:35:05 +04:00
|
|
|
#include "nsIDashboardEventNotifier.h"
|
2013-09-06 00:12:38 +04:00
|
|
|
#include "nsIDNSListener.h"
|
2012-12-10 18:13:55 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2013-07-31 17:16:44 +04:00
|
|
|
#include "nsITimer.h"
|
2013-09-06 00:12:38 +04:00
|
|
|
#include "nsITransport.h"
|
|
|
|
|
|
|
|
class nsIDNSService;
|
2012-12-10 18:13:55 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2014-03-11 20:59:50 +04:00
|
|
|
class SocketData;
|
|
|
|
class HttpData;
|
|
|
|
class DnsData;
|
|
|
|
class WebSocketRequest;
|
|
|
|
class ConnectionData;
|
2017-05-10 20:23:54 +03:00
|
|
|
class RcwnData;
|
2014-03-11 20:59:50 +04:00
|
|
|
|
|
|
|
class Dashboard final : public nsIDashboard, public nsIDashboardEventNotifier {
|
2012-12-10 18:13:55 +04:00
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-12-10 18:13:55 +04:00
|
|
|
NS_DECL_NSIDASHBOARD
|
|
|
|
NS_DECL_NSIDASHBOARDEVENTNOTIFIER
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-10 18:13:55 +04:00
|
|
|
Dashboard();
|
2019-05-01 11:47:10 +03:00
|
|
|
static const char* GetErrorString(nsresult rv);
|
|
|
|
nsresult GetConnectionStatus(ConnectionData* aConnectionData);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-10 18:13:55 +04:00
|
|
|
private:
|
|
|
|
struct LogData {
|
|
|
|
LogData(nsCString host, uint32_t serial, bool encryption)
|
|
|
|
: mHost(host),
|
|
|
|
mSerial(serial),
|
|
|
|
mMsgSent(0),
|
|
|
|
mMsgReceived(0),
|
|
|
|
mSizeSent(0),
|
|
|
|
mSizeReceived(0),
|
|
|
|
mEncrypted(encryption) {}
|
|
|
|
nsCString mHost;
|
|
|
|
uint32_t mSerial;
|
|
|
|
uint32_t mMsgSent;
|
|
|
|
uint32_t mMsgReceived;
|
|
|
|
uint64_t mSizeSent;
|
|
|
|
uint64_t mSizeReceived;
|
|
|
|
bool mEncrypted;
|
2019-05-01 11:47:10 +03:00
|
|
|
bool operator==(const LogData& a) const {
|
2012-12-10 18:13:55 +04:00
|
|
|
return mHost.Equals(a.mHost) && (mSerial == a.mSerial);
|
|
|
|
}
|
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-12-10 18:13:55 +04:00
|
|
|
struct WebSocketData {
|
|
|
|
WebSocketData() : lock("Dashboard.webSocketData") {}
|
2019-05-01 11:47:10 +03:00
|
|
|
uint32_t IndexOf(const nsCString& hostname, uint32_t mSerial) {
|
2012-12-10 18:13:55 +04:00
|
|
|
LogData temp(hostname, mSerial, false);
|
|
|
|
return data.IndexOf(temp);
|
|
|
|
}
|
|
|
|
nsTArray<LogData> data;
|
|
|
|
mozilla::Mutex lock;
|
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-03-11 20:59:50 +04:00
|
|
|
bool mEnableLogging;
|
|
|
|
WebSocketData mWs;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-03-11 20:59:50 +04:00
|
|
|
private:
|
2018-04-30 19:46:04 +03:00
|
|
|
virtual ~Dashboard() = default;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult GetSocketsDispatch(SocketData*);
|
|
|
|
nsresult GetHttpDispatch(HttpData*);
|
|
|
|
nsresult GetDnsInfoDispatch(DnsData*);
|
|
|
|
nsresult TestNewConnection(ConnectionData*);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-03-11 20:59:50 +04:00
|
|
|
/* Helper methods that pass the JSON to the callback function. */
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult GetSockets(SocketData*);
|
|
|
|
nsresult GetHttpConnections(HttpData*);
|
|
|
|
nsresult GetDNSCacheEntries(DnsData*);
|
|
|
|
nsresult GetWebSocketConnections(WebSocketRequest*);
|
|
|
|
nsresult GetRcwnData(RcwnData*);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-03-11 20:59:50 +04:00
|
|
|
nsCOMPtr<nsIDNSService> mDnsService;
|
2013-07-31 17:16:44 +04:00
|
|
|
};
|
2012-12-10 18:13:55 +04:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-12-10 18:13:55 +04:00
|
|
|
#endif // nsDashboard_h__
|