Bug 1545821 - nsI-ify NetDashboardCallback. r=mayhemer
authorAndrew McCreight <continuation@gmail.com>
Tue, 23 Apr 2019 15:33:57 +0000
changeset 470507 c510cf43416cbd8be32987ebee55b88107e94415
parent 470506 9e9812ed59a5f2a79ee0376cc5dcc0dbc7c54910
child 470508 7f72db694e4f7a582e836e77eb4f32e373ade2b5
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1545821
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1545821 - nsI-ify NetDashboardCallback. r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D28284
netwerk/base/Dashboard.cpp
netwerk/base/nsIDashboard.idl
--- a/netwerk/base/Dashboard.cpp
+++ b/netwerk/base/Dashboard.cpp
@@ -38,17 +38,17 @@ class SocketData : public nsISupports {
     mTotalSent = 0;
     mTotalRecv = 0;
     mEventTarget = nullptr;
   }
 
   uint64_t mTotalSent;
   uint64_t mTotalRecv;
   nsTArray<SocketInfo> mData;
-  nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
+  nsMainThreadPtrHandle<nsINetDashboardCallback> mCallback;
   nsIEventTarget *mEventTarget;
 
  private:
   virtual ~SocketData() = default;
 };
 
 static void GetErrorString(nsresult rv, nsAString &errorString);
 
@@ -58,46 +58,46 @@ class HttpData : public nsISupports {
   virtual ~HttpData() = default;
 
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   HttpData() { mEventTarget = nullptr; }
 
   nsTArray<HttpRetParams> mData;
-  nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
+  nsMainThreadPtrHandle<nsINetDashboardCallback> mCallback;
   nsIEventTarget *mEventTarget;
 };
 
 NS_IMPL_ISUPPORTS0(HttpData)
 
 class WebSocketRequest : public nsISupports {
   virtual ~WebSocketRequest() = default;
 
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   WebSocketRequest() { mEventTarget = nullptr; }
 
-  nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
+  nsMainThreadPtrHandle<nsINetDashboardCallback> mCallback;
   nsIEventTarget *mEventTarget;
 };
 
 NS_IMPL_ISUPPORTS0(WebSocketRequest)
 
 class DnsData : public nsISupports {
   virtual ~DnsData() = default;
 
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   DnsData() { mEventTarget = nullptr; }
 
   nsTArray<DNSCacheEntries> mData;
-  nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
+  nsMainThreadPtrHandle<nsINetDashboardCallback> mCallback;
   nsIEventTarget *mEventTarget;
 };
 
 NS_IMPL_ISUPPORTS0(DnsData)
 
 class ConnectionData : public nsITransportEventSink,
                        public nsITimerCallback,
                        public nsINamed {
@@ -124,17 +124,17 @@ class ConnectionData : public nsITranspo
       : mPort(0), mProtocol(nullptr), mTimeout(0) {
     mEventTarget = nullptr;
     mDashboard = target;
   }
 
   nsCOMPtr<nsISocketTransport> mSocket;
   nsCOMPtr<nsIInputStream> mStreamIn;
   nsCOMPtr<nsITimer> mTimer;
-  nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
+  nsMainThreadPtrHandle<nsINetDashboardCallback> mCallback;
   nsIEventTarget *mEventTarget;
   Dashboard *mDashboard;
 
   nsCString mHost;
   uint32_t mPort;
   const char *mProtocol;
   uint32_t mTimeout;
 
@@ -147,17 +147,17 @@ NS_IMPL_ISUPPORTS(ConnectionData, nsITra
 class RcwnData : public nsISupports {
   virtual ~RcwnData() = default;
 
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   RcwnData() { mEventTarget = nullptr; }
 
-  nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
+  nsMainThreadPtrHandle<nsINetDashboardCallback> mCallback;
   nsIEventTarget *mEventTarget;
 };
 
 NS_IMPL_ISUPPORTS0(RcwnData)
 
 NS_IMETHODIMP
 ConnectionData::OnTransportStatus(nsITransport *aTransport, nsresult aStatus,
                                   int64_t aProgress, int64_t aProgressMax) {
@@ -241,17 +241,17 @@ class LookupHelper final : public nsIDNS
   NS_DECL_NSIDNSLISTENER
 
   LookupHelper() : mEventTarget{nullptr}, mStatus{NS_ERROR_NOT_INITIALIZED} {}
 
   nsresult ConstructAnswer(LookupArgument *aArgument);
 
  public:
   nsCOMPtr<nsICancelable> mCancel;
-  nsMainThreadPtrHandle<NetDashboardCallback> mCallback;
+  nsMainThreadPtrHandle<nsINetDashboardCallback> mCallback;
   nsIEventTarget *mEventTarget;
   nsresult mStatus;
 };
 
 NS_IMPL_ISUPPORTS(LookupHelper, nsIDNSListener)
 
 NS_IMETHODIMP
 LookupHelper::OnLookupComplete(nsICancelable *aRequest, nsIDNSRecord *aRecord,
@@ -315,20 +315,20 @@ nsresult LookupHelper::ConstructAnswer(L
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(Dashboard, nsIDashboard, nsIDashboardEventNotifier)
 
 Dashboard::Dashboard() { mEnableLogging = false; }
 
 NS_IMETHODIMP
-Dashboard::RequestSockets(NetDashboardCallback *aCallback) {
+Dashboard::RequestSockets(nsINetDashboardCallback *aCallback) {
   RefPtr<SocketData> socketData = new SocketData();
-  socketData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(
-      "NetDashboardCallback", aCallback, true);
+  socketData->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
+      "nsINetDashboardCallback", aCallback, true);
   socketData->mEventTarget = GetCurrentThreadEventTarget();
   gSocketTransportService->Dispatch(
       NewRunnableMethod<RefPtr<SocketData>>(
           "net::Dashboard::GetSocketsDispatch", this,
           &Dashboard::GetSocketsDispatch, socketData),
       NS_DISPATCH_NORMAL);
   return NS_OK;
 }
@@ -381,20 +381,20 @@ nsresult Dashboard::GetSockets(SocketDat
   JS::RootedValue val(cx);
   if (!ToJSValue(cx, dict, &val)) return NS_ERROR_FAILURE;
   socketData->mCallback->OnDashboardDataAvailable(val);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-Dashboard::RequestHttpConnections(NetDashboardCallback *aCallback) {
+Dashboard::RequestHttpConnections(nsINetDashboardCallback *aCallback) {
   RefPtr<HttpData> httpData = new HttpData();
-  httpData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(
-      "NetDashboardCallback", aCallback, true);
+  httpData->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
+      "nsINetDashboardCallback", aCallback, true);
   httpData->mEventTarget = GetCurrentThreadEventTarget();
 
   gSocketTransportService->Dispatch(NewRunnableMethod<RefPtr<HttpData>>(
                                         "net::Dashboard::GetHttpDispatch", this,
                                         &Dashboard::GetHttpDispatch, httpData),
                                     NS_DISPATCH_NORMAL);
   return NS_OK;
 }
@@ -546,20 +546,20 @@ Dashboard::NewMsgReceived(const nsACStri
     mWs.data[index].mMsgReceived++;
     mWs.data[index].mSizeReceived += aLength;
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-Dashboard::RequestWebsocketConnections(NetDashboardCallback *aCallback) {
+Dashboard::RequestWebsocketConnections(nsINetDashboardCallback *aCallback) {
   RefPtr<WebSocketRequest> wsRequest = new WebSocketRequest();
-  wsRequest->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(
-      "NetDashboardCallback", aCallback, true);
+  wsRequest->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
+      "nsINetDashboardCallback", aCallback, true);
   wsRequest->mEventTarget = GetCurrentThreadEventTarget();
 
   wsRequest->mEventTarget->Dispatch(
       NewRunnableMethod<RefPtr<WebSocketRequest>>(
           "net::Dashboard::GetWebSocketConnections", this,
           &Dashboard::GetWebSocketConnections, wsRequest),
       NS_DISPATCH_NORMAL);
   return NS_OK;
@@ -596,20 +596,20 @@ nsresult Dashboard::GetWebSocketConnecti
     return NS_ERROR_FAILURE;
   }
   wsRequest->mCallback->OnDashboardDataAvailable(val);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-Dashboard::RequestDNSInfo(NetDashboardCallback *aCallback) {
+Dashboard::RequestDNSInfo(nsINetDashboardCallback *aCallback) {
   RefPtr<DnsData> dnsData = new DnsData();
-  dnsData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(
-      "NetDashboardCallback", aCallback, true);
+  dnsData->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
+      "nsINetDashboardCallback", aCallback, true);
 
   nsresult rv;
   dnsData->mData.Clear();
   dnsData->mEventTarget = GetCurrentThreadEventTarget();
 
   if (!mDnsService) {
     mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv);
     if (NS_FAILED(rv)) {
@@ -687,43 +687,43 @@ nsresult Dashboard::GetDNSCacheEntries(D
   }
   dnsData->mCallback->OnDashboardDataAvailable(val);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Dashboard::RequestDNSLookup(const nsACString &aHost,
-                            NetDashboardCallback *aCallback) {
+                            nsINetDashboardCallback *aCallback) {
   nsresult rv;
 
   if (!mDnsService) {
     mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv);
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
   RefPtr<LookupHelper> helper = new LookupHelper();
-  helper->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(
-      "NetDashboardCallback", aCallback, true);
+  helper->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
+      "nsINetDashboardCallback", aCallback, true);
   helper->mEventTarget = GetCurrentThreadEventTarget();
   OriginAttributes attrs;
   rv = mDnsService->AsyncResolveNative(aHost, 0, helper.get(),
                                        NS_GetCurrentThread(), attrs,
                                        getter_AddRefs(helper->mCancel));
   return rv;
 }
 
 NS_IMETHODIMP
-Dashboard::RequestRcwnStats(NetDashboardCallback *aCallback) {
+Dashboard::RequestRcwnStats(nsINetDashboardCallback *aCallback) {
   RefPtr<RcwnData> rcwnData = new RcwnData();
   rcwnData->mEventTarget = GetCurrentThreadEventTarget();
-  rcwnData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(
-      "NetDashboardCallback", aCallback, true);
+  rcwnData->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
+      "nsINetDashboardCallback", aCallback, true);
 
   return rcwnData->mEventTarget->Dispatch(
       NewRunnableMethod<RefPtr<RcwnData>>("net::Dashboard::GetRcwnData", this,
                                           &Dashboard::GetRcwnData, rcwnData),
       NS_DISPATCH_NORMAL);
 }
 
 nsresult Dashboard::GetRcwnData(RcwnData *aData) {
@@ -798,26 +798,27 @@ Dashboard::GetLogPath(nsACString &aLogPa
   uint32_t len = LogModule::GetLogFile(aLogPath.BeginWriting(), 2048);
   aLogPath.SetLength(len);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Dashboard::RequestConnection(const nsACString &aHost, uint32_t aPort,
                              const char *aProtocol, uint32_t aTimeout,
-                             NetDashboardCallback *aCallback) {
+                             nsINetDashboardCallback *aCallback) {
   nsresult rv;
   RefPtr<ConnectionData> connectionData = new ConnectionData(this);
   connectionData->mHost = aHost;
   connectionData->mPort = aPort;
   connectionData->mProtocol = aProtocol;
   connectionData->mTimeout = aTimeout;
 
-  connectionData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(
-      "NetDashboardCallback", aCallback, true);
+  connectionData->mCallback =
+      new nsMainThreadPtrHolder<nsINetDashboardCallback>(
+          "nsINetDashboardCallback", aCallback, true);
   connectionData->mEventTarget = GetCurrentThreadEventTarget();
 
   rv = TestNewConnection(connectionData);
   if (NS_FAILED(rv)) {
     mozilla::net::GetErrorString(rv, connectionData->mStatus);
     connectionData->mEventTarget->Dispatch(
         NewRunnableMethod<RefPtr<ConnectionData>>(
             "net::Dashboard::GetConnectionStatus", this,
--- a/netwerk/base/nsIDashboard.idl
+++ b/netwerk/base/nsIDashboard.idl
@@ -3,57 +3,57 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 /* A JavaScript callback function that takes a JSON as its parameter.
  * The returned JSON contains arrays with data
  */
 [scriptable, function, uuid(19d7f24f-a95a-4fd9-87e2-d96e9e4b1f6d)]
-interface NetDashboardCallback : nsISupports
+interface nsINetDashboardCallback : nsISupports
 {
     void onDashboardDataAvailable(in jsval data);
 };
 
 /* The dashboard service.
  * The async API returns JSONs, which hold arrays with the required info.
  * Only one request of each type may be pending at any time.
  */
 [scriptable, uuid(c79eb3c6-091a-45a6-8544-5a8d1ab79537)]
 interface nsIDashboard : nsISupports
 {
     /* Arrays: host, port, tcp, active, socksent, sockreceived
      * Values: sent, received  */
-    void requestSockets(in NetDashboardCallback cb);
+    void requestSockets(in nsINetDashboardCallback cb);
 
     /* Arrays: host, port, spdy, ssl
      * Array of arrays: active, idle */
-    void requestHttpConnections(in NetDashboardCallback cb);
+    void requestHttpConnections(in nsINetDashboardCallback cb);
 
     /* Arrays: hostport, encrypted, msgsent, msgreceived, sentsize, receivedsize */
-    void requestWebsocketConnections(in NetDashboardCallback cb);
+    void requestWebsocketConnections(in nsINetDashboardCallback cb);
 
     /* Arrays: hostname, family, hostaddr, expiration */
-    void requestDNSInfo(in NetDashboardCallback cb);
+    void requestDNSInfo(in nsINetDashboardCallback cb);
 
     /* aProtocol: a transport layer protocol:
      *      ex: "ssl", "tcp", default is "tcp".
      * aHost: the host's name
      * aPort: the port which the connection will open on
      * aTimeout: the timespan before the connection will be timed out */
     void requestConnection(in ACString aHost, in unsigned long aPort,
                            in string aProtocol, in unsigned long aTimeout,
-                           in NetDashboardCallback cb);
+                           in nsINetDashboardCallback cb);
 
     /* When true, the service will log websocket events */
     attribute boolean enableLogging;
 
     /* DNS resolver for host name
      * aHost: host name */
-    void requestDNSLookup(in ACString aHost, in NetDashboardCallback cb);
+    void requestDNSLookup(in ACString aHost, in nsINetDashboardCallback cb);
 
     /**
      * Asyncly returns stats regarding the "Race Cache With Network" feature.
      */
-    void requestRcwnStats(in NetDashboardCallback cb);
+    void requestRcwnStats(in nsINetDashboardCallback cb);
 
     AUTF8String getLogPath();
 };