netwerk/base/src/Dashboard.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/src/Dashboard.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,105 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef nsDashboard_h__
     1.9 +#define nsDashboard_h__
    1.10 +
    1.11 +#include "mozilla/Mutex.h"
    1.12 +#include "mozilla/net/DashboardTypes.h"
    1.13 +#include "nsIDashboard.h"
    1.14 +#include "nsIDashboardEventNotifier.h"
    1.15 +#include "nsIDNSListener.h"
    1.16 +#include "nsIServiceManager.h"
    1.17 +#include "nsITimer.h"
    1.18 +#include "nsITransport.h"
    1.19 +
    1.20 +class nsIDNSService;
    1.21 +class nsISocketTransport;
    1.22 +class nsIThread;
    1.23 +
    1.24 +namespace mozilla {
    1.25 +namespace net {
    1.26 +
    1.27 +class SocketData;
    1.28 +class HttpData;
    1.29 +class DnsData;
    1.30 +class WebSocketRequest;
    1.31 +class ConnectionData;
    1.32 +
    1.33 +class Dashboard
    1.34 +    : public nsIDashboard
    1.35 +    , public nsIDashboardEventNotifier
    1.36 +{
    1.37 +public:
    1.38 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.39 +    NS_DECL_NSIDASHBOARD
    1.40 +    NS_DECL_NSIDASHBOARDEVENTNOTIFIER
    1.41 +
    1.42 +    Dashboard();
    1.43 +    static const char *GetErrorString(nsresult rv);
    1.44 +    nsresult GetConnectionStatus(ConnectionData *aConnectionData);
    1.45 +
    1.46 +private:
    1.47 +
    1.48 +    struct LogData
    1.49 +    {
    1.50 +        LogData(nsCString host, uint32_t serial, bool encryption):
    1.51 +            mHost(host),
    1.52 +            mSerial(serial),
    1.53 +            mMsgSent(0),
    1.54 +            mMsgReceived(0),
    1.55 +            mSizeSent(0),
    1.56 +            mSizeReceived(0),
    1.57 +            mEncrypted(encryption)
    1.58 +        { }
    1.59 +        nsCString mHost;
    1.60 +        uint32_t  mSerial;
    1.61 +        uint32_t  mMsgSent;
    1.62 +        uint32_t  mMsgReceived;
    1.63 +        uint64_t  mSizeSent;
    1.64 +        uint64_t  mSizeReceived;
    1.65 +        bool      mEncrypted;
    1.66 +        bool operator==(const LogData& a) const
    1.67 +        {
    1.68 +            return mHost.Equals(a.mHost) && (mSerial == a.mSerial);
    1.69 +        }
    1.70 +    };
    1.71 +
    1.72 +    struct WebSocketData
    1.73 +    {
    1.74 +        WebSocketData():lock("Dashboard.webSocketData")
    1.75 +        {
    1.76 +        }
    1.77 +        uint32_t IndexOf(nsCString hostname, uint32_t mSerial)
    1.78 +        {
    1.79 +            LogData temp(hostname, mSerial, false);
    1.80 +            return data.IndexOf(temp);
    1.81 +        }
    1.82 +        nsTArray<LogData> data;
    1.83 +        mozilla::Mutex lock;
    1.84 +    };
    1.85 +
    1.86 +
    1.87 +    bool mEnableLogging;
    1.88 +    WebSocketData mWs;
    1.89 +
    1.90 +private:
    1.91 +    virtual ~Dashboard();
    1.92 +
    1.93 +    nsresult GetSocketsDispatch(SocketData *);
    1.94 +    nsresult GetHttpDispatch(HttpData *);
    1.95 +    nsresult GetDnsInfoDispatch(DnsData *);
    1.96 +    nsresult TestNewConnection(ConnectionData *);
    1.97 +
    1.98 +    /* Helper methods that pass the JSON to the callback function. */
    1.99 +    nsresult GetSockets(SocketData *);
   1.100 +    nsresult GetHttpConnections(HttpData *);
   1.101 +    nsresult GetDNSCacheEntries(DnsData *);
   1.102 +    nsresult GetWebSocketConnections(WebSocketRequest *);
   1.103 +
   1.104 +    nsCOMPtr<nsIDNSService> mDnsService;
   1.105 +};
   1.106 +
   1.107 +} } // namespace mozilla::net
   1.108 +#endif // nsDashboard_h__

mercurial