Bug 1238404 - Use 'using' directive instead of having separate Dispatch impl in subclasses of nsIEventTarget. r=froydnj
authorXidorn Quan <quanxunzhen@gmail.com>
Tue, 12 Jan 2016 15:18:47 +1100
changeset 301699 05b4771bed8f59c6521be22718f0d7cfd0cd06c4
parent 301698 faef1a1e29ba76f3c399cae84b4b50a3c37c7db1
child 301700 f521bf0274c7c7a5d6bc6c24428e0b15166ca7eb
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1238404
milestone46.0a1
Bug 1238404 - Use 'using' directive instead of having separate Dispatch impl in subclasses of nsIEventTarget. r=froydnj
dom/base/WebSocket.cpp
netwerk/base/nsSocketTransportService2.h
netwerk/base/nsStreamTransportService.h
xpcom/threads/LazyIdleThread.h
xpcom/threads/SharedThreadPool.h
xpcom/threads/nsIEventTarget.idl
xpcom/threads/nsIThread.idl
xpcom/threads/nsIThreadInternal.idl
xpcom/threads/nsIThreadPool.idl
xpcom/threads/nsThread.h
xpcom/threads/nsThreadPool.h
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -75,20 +75,17 @@ class WebSocketImpl final : public nsIIn
 {
 public:
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSIWEBSOCKETLISTENER
   NS_DECL_NSIOBSERVER
   NS_DECL_NSIREQUEST
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
-  // missing from NS_DECL_NSIEVENTTARGET because MSVC
-  nsresult Dispatch(nsIRunnable* aEvent, uint32_t aFlags) {
-    return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
-  }
+  using nsIEventTarget::Dispatch;
 
   explicit WebSocketImpl(WebSocket* aWebSocket)
   : mWebSocket(aWebSocket)
   , mOnCloseScheduled(false)
   , mFailed(false)
   , mDisconnectingOrDisconnected(false)
   , mCloseEventWasClean(false)
   , mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL)
--- a/netwerk/base/nsSocketTransportService2.h
+++ b/netwerk/base/nsSocketTransportService2.h
@@ -76,20 +76,17 @@ public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSPISOCKETTRANSPORTSERVICE
     NS_DECL_NSISOCKETTRANSPORTSERVICE
     NS_DECL_NSIROUTEDSOCKETTRANSPORTSERVICE
     NS_DECL_NSIEVENTTARGET
     NS_DECL_NSITHREADOBSERVER
     NS_DECL_NSIRUNNABLE
     NS_DECL_NSIOBSERVER 
-    // missing from NS_DECL_NSIEVENTTARGET because MSVC
-    nsresult Dispatch(nsIRunnable* aEvent, uint32_t aFlags) {
-      return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
-    }
+    using nsIEventTarget::Dispatch;
 
     nsSocketTransportService();
 
     // Max Socket count may need to get initialized/used by nsHttpHandler
     // before this class is initialized.
     static uint32_t gMaxCount;
     static PRCallOnceType gMaxCountInitOnce;
     static PRStatus DiscoverMaxCount();
--- a/netwerk/base/nsStreamTransportService.h
+++ b/netwerk/base/nsStreamTransportService.h
@@ -16,20 +16,17 @@ class nsStreamTransportService final : p
                                      , public nsIEventTarget
                                      , public nsIObserver
 {
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSISTREAMTRANSPORTSERVICE
     NS_DECL_NSIEVENTTARGET
     NS_DECL_NSIOBSERVER
-    // missing from NS_DECL_NSIEVENTTARGET because MSVC
-    nsresult Dispatch(nsIRunnable* aEvent, uint32_t aFlags) {
-      return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
-    }
+    using nsIEventTarget::Dispatch;
 
     nsresult Init();
 
     nsStreamTransportService() : mShutdownLock("nsStreamTransportService.mShutdownLock"),
                                  mIsShutdown(false) {}
 
 private:
     ~nsStreamTransportService();
--- a/xpcom/threads/LazyIdleThread.h
+++ b/xpcom/threads/LazyIdleThread.h
@@ -40,20 +40,17 @@ class LazyIdleThread final
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
   NS_DECL_NSITHREAD
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_NSITHREADOBSERVER
   NS_DECL_NSIOBSERVER
-  // missing from NS_DECL_NSIEVENTTARGET because MSVC
-  nsresult Dispatch(nsIRunnable* aEvent, uint32_t aFlags) {
-    return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
-  }
+  using nsIEventTarget::Dispatch;
 
   enum ShutdownMethod
   {
     AutomaticShutdown = 0,
     ManualShutdown
   };
 
   /**
--- a/xpcom/threads/SharedThreadPool.h
+++ b/xpcom/threads/SharedThreadPool.h
@@ -50,27 +50,25 @@ public:
   // in a tight loop.
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
   NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
   NS_IMETHOD_(MozExternalRefCountType) Release(void) override;
 
   // Forward behaviour to wrapped thread pool implementation.
   NS_FORWARD_SAFE_NSITHREADPOOL(mPool);
 
-  // See bug 1155059 - MSVC forces us to not declare Dispatch normally in idl
-  //  NS_FORWARD_SAFE_NSIEVENTTARGET(mEventTarget);
-  nsresult Dispatch(nsIRunnable *event, uint32_t flags) { return !mEventTarget ? NS_ERROR_NULL_POINTER : mEventTarget->Dispatch(event, flags); }
- 
   NS_IMETHOD DispatchFromScript(nsIRunnable *event, uint32_t flags) override {
       return Dispatch(event, flags);
   }
 
   NS_IMETHOD Dispatch(already_AddRefed<nsIRunnable>&& event, uint32_t flags) override
     { return !mEventTarget ? NS_ERROR_NULL_POINTER : mEventTarget->Dispatch(Move(event), flags); }
 
+  using nsIEventTarget::Dispatch;
+
   NS_IMETHOD IsOnCurrentThread(bool *_retval) override { return !mEventTarget ? NS_ERROR_NULL_POINTER : mEventTarget->IsOnCurrentThread(_retval); }
 
   // Creates necessary statics. Called once at startup.
   static void InitStatics();
 
   // Spins the event loop until all thread pools are shutdown.
   // *Must* be called on the main thread.
   static void SpinUntilEmpty();
--- a/xpcom/threads/nsIEventTarget.idl
+++ b/xpcom/threads/nsIEventTarget.idl
@@ -8,25 +8,20 @@
 #include "nsIRunnable.idl"
 %{C++
 #include "nsCOMPtr.h"
 #include "mozilla/AlreadyAddRefed.h"
 %}
 
 native alreadyAddRefed_nsIRunnable(already_AddRefed<nsIRunnable>&&);
 
-[scriptable, uuid(f9d60700-e6dc-4a72-9537-689058655472)]
+[scriptable, uuid(88145945-3278-424e-9f37-d874cbdd9f6f)]
 interface nsIEventTarget : nsISupports
 {
   /* until we can get rid of all uses, keep the non-alreadyAddRefed<> version */
-  /**
-   * This must be non-virtual due to issues with MSVC 2013's ordering of
-   * vtbls for overloads.  With other platforms we can leave this virtual
-   * and avoid adding lots of Dispatch() methods to classes inheriting this.
-   */
 %{C++
     nsresult Dispatch(nsIRunnable* aEvent, uint32_t aFlags) {
       return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
     }
 %}
 
   /**
    * This flag specifies the default mode of event dispatch, whereby the event
--- a/xpcom/threads/nsIThread.idl
+++ b/xpcom/threads/nsIThread.idl
@@ -12,17 +12,17 @@
  * This interface provides a high-level abstraction for an operating system
  * thread.
  *
  * Threads have a built-in event queue, and a thread is an event target that
  * can receive nsIRunnable objects (events) to be processed on the thread.
  *
  * See nsIThreadManager for the API used to create and locate threads.
  */
-[scriptable, uuid(594feb13-6164-4054-b5a1-ad62e10ea15d)]
+[scriptable, uuid(5801d193-29d1-4964-a6b7-70eb697ddf2b)]
 interface nsIThread : nsIEventTarget
 {
   /**
    * @returns
    *   The NSPR thread object corresponding to this nsIThread.
    */
   [noscript] readonly attribute PRThread PRThread;
 
--- a/xpcom/threads/nsIThreadInternal.idl
+++ b/xpcom/threads/nsIThreadInternal.idl
@@ -8,17 +8,17 @@
 
 interface nsIRunnable;
 interface nsIThreadObserver;
 
 /**
  * The XPCOM thread object implements this interface, which allows a consumer
  * to observe dispatch activity on the thread.
  */
-[scriptable, uuid(9cc51754-2eb3-4b46-ae99-38a61881c622)]
+[scriptable, uuid(a3a72e5f-71d9-4add-8f30-59a78fb6d5eb)]
 interface nsIThreadInternal : nsIThread
 {
   /**
    * Get/set the current thread observer (may be null).  This attribute may be
    * read from any thread, but must only be set on the thread corresponding to
    * this thread object.  The observer will be released on the thread
    * corresponding to this thread object after all other events have been
    * processed during a call to Shutdown.
--- a/xpcom/threads/nsIThreadPool.idl
+++ b/xpcom/threads/nsIThreadPool.idl
@@ -22,17 +22,17 @@ interface nsIThreadPoolListener : nsISup
   void onThreadShuttingDown();
 };
 
 /**
  * An interface to a thread pool.  A thread pool creates a limited number of
  * anonymous (unnamed) worker threads.  An event dispatched to the thread pool
  * will be run on the next available worker thread.
  */
-[scriptable, uuid(cacd4a2e-2655-4ff8-894c-10c15883cd0a)]
+[scriptable, uuid(76ce99c9-8e43-489a-9789-f27cc4424965)]
 interface nsIThreadPool : nsIEventTarget
 {
   /**
    * Shutdown the thread pool.  This method may not be executed from any thread
    * in the thread pool.  Instead, it is meant to be executed from another
    * thread (usually the thread that created this thread pool).  When this
    * function returns, the thread pool and all of its threads will be shutdown,
    * and it will no longer be possible to dispatch tasks to the thread pool.
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -28,20 +28,17 @@ class nsThread
   , public nsISupportsPriority
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
   NS_DECL_NSITHREAD
   NS_DECL_NSITHREADINTERNAL
   NS_DECL_NSISUPPORTSPRIORITY
-  // missing from NS_DECL_NSIEVENTTARGET because MSVC
-  nsresult Dispatch(nsIRunnable* aEvent, uint32_t aFlags) {
-    return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
-  }
+  using nsIEventTarget::Dispatch;
 
   enum MainThreadFlag
   {
     MAIN_THREAD,
     NOT_MAIN_THREAD
   };
 
   nsThread(MainThreadFlag aMainThread, uint32_t aStackSize);
--- a/xpcom/threads/nsThreadPool.h
+++ b/xpcom/threads/nsThreadPool.h
@@ -23,20 +23,17 @@ class nsThreadPool final
   : public nsIThreadPool
   , public nsIRunnable
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
   NS_DECL_NSITHREADPOOL
   NS_DECL_NSIRUNNABLE
-  // missing from NS_DECL_NSIEVENTTARGET because MSVC
-  nsresult Dispatch(nsIRunnable* aEvent, uint32_t aFlags) {
-    return Dispatch(nsCOMPtr<nsIRunnable>(aEvent).forget(), aFlags);
-  }
+  using nsIEventTarget::Dispatch;
 
   nsThreadPool();
 
 private:
   ~nsThreadPool();
 
   void ShutdownThread(nsIThread* aThread);
   nsresult PutEvent(nsIRunnable* aEvent);