netwerk/base/src/Dashboard.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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"
    12 #include "nsIDNSListener.h"
    13 #include "nsIServiceManager.h"
    14 #include "nsITimer.h"
    15 #include "nsITransport.h"
    17 class nsIDNSService;
    18 class nsISocketTransport;
    19 class nsIThread;
    21 namespace mozilla {
    22 namespace net {
    24 class SocketData;
    25 class HttpData;
    26 class DnsData;
    27 class WebSocketRequest;
    28 class ConnectionData;
    30 class Dashboard
    31     : public nsIDashboard
    32     , public nsIDashboardEventNotifier
    33 {
    34 public:
    35     NS_DECL_THREADSAFE_ISUPPORTS
    36     NS_DECL_NSIDASHBOARD
    37     NS_DECL_NSIDASHBOARDEVENTNOTIFIER
    39     Dashboard();
    40     static const char *GetErrorString(nsresult rv);
    41     nsresult GetConnectionStatus(ConnectionData *aConnectionData);
    43 private:
    45     struct LogData
    46     {
    47         LogData(nsCString host, uint32_t serial, bool encryption):
    48             mHost(host),
    49             mSerial(serial),
    50             mMsgSent(0),
    51             mMsgReceived(0),
    52             mSizeSent(0),
    53             mSizeReceived(0),
    54             mEncrypted(encryption)
    55         { }
    56         nsCString mHost;
    57         uint32_t  mSerial;
    58         uint32_t  mMsgSent;
    59         uint32_t  mMsgReceived;
    60         uint64_t  mSizeSent;
    61         uint64_t  mSizeReceived;
    62         bool      mEncrypted;
    63         bool operator==(const LogData& a) const
    64         {
    65             return mHost.Equals(a.mHost) && (mSerial == a.mSerial);
    66         }
    67     };
    69     struct WebSocketData
    70     {
    71         WebSocketData():lock("Dashboard.webSocketData")
    72         {
    73         }
    74         uint32_t IndexOf(nsCString hostname, uint32_t mSerial)
    75         {
    76             LogData temp(hostname, mSerial, false);
    77             return data.IndexOf(temp);
    78         }
    79         nsTArray<LogData> data;
    80         mozilla::Mutex lock;
    81     };
    84     bool mEnableLogging;
    85     WebSocketData mWs;
    87 private:
    88     virtual ~Dashboard();
    90     nsresult GetSocketsDispatch(SocketData *);
    91     nsresult GetHttpDispatch(HttpData *);
    92     nsresult GetDnsInfoDispatch(DnsData *);
    93     nsresult TestNewConnection(ConnectionData *);
    95     /* Helper methods that pass the JSON to the callback function. */
    96     nsresult GetSockets(SocketData *);
    97     nsresult GetHttpConnections(HttpData *);
    98     nsresult GetDNSCacheEntries(DnsData *);
    99     nsresult GetWebSocketConnections(WebSocketRequest *);
   101     nsCOMPtr<nsIDNSService> mDnsService;
   102 };
   104 } } // namespace mozilla::net
   105 #endif // nsDashboard_h__

mercurial