Bug 1312319 - Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro and replace existing pure-virtual AddRef/Release declarations. r?froydnj draft
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 25 Jan 2017 14:51:34 -0500
changeset 466288 6606c7983885a0b54a8184aeb8403f052d9bddfc
parent 466286 24d9eb148461bb4789848b9880867c63c783a2ca
child 543389 1474ec6e830ea5d56b5cb5b8965ebfda9423760d
push id42861
push userkgupta@mozilla.com
push dateWed, 25 Jan 2017 19:52:10 +0000
reviewersfroydnj
bugs1312319
milestone54.0a1
Bug 1312319 - Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro and replace existing pure-virtual AddRef/Release declarations. r?froydnj MozReview-Commit-ID: 5yt3O4Hoois
dom/cache/Action.h
dom/cache/ReadStream.h
dom/file/MutableBlobStorage.h
dom/filehandle/FileHandleCommon.h
dom/flyweb/HttpServer.h
dom/media/eme/CDMProxy.h
dom/quota/Client.h
dom/quota/QuotaManager.h
dom/workers/ServiceWorkerEvents.h
dom/workers/ServiceWorkerJob.h
dom/workers/ServiceWorkerPrivate.cpp
dom/workers/ServiceWorkerRegistration.h
dom/workers/ServiceWorkerScriptCache.h
dom/xslt/xslt/txStylesheetCompiler.h
gfx/layers/apz/public/CompositorController.h
gfx/layers/apz/public/MetricsSharingController.h
gfx/layers/ipc/KnowsCompositor.h
gfx/layers/ipc/TextureForwarder.h
image/IProgressObserver.h
image/ISurfaceProvider.h
image/SourceBuffer.h
layout/base/nsRefreshDriver.h
layout/style/CounterStyleManager.h
media/mtransport/nr_socket_prsock.h
netwerk/base/ARefBase.h
xpcom/base/nsISupportsImpl.h
--- a/dom/cache/Action.h
+++ b/dom/cache/Action.h
@@ -23,21 +23,17 @@ public:
   class Resolver
   {
   public:
     // Note: Action must drop Resolver ref after calling Resolve()!
     // Note: Must be called on the same thread used to execute
     //       Action::RunOnTarget().
     virtual void Resolve(nsresult aRv) = 0;
 
-    NS_IMETHOD_(MozExternalRefCountType)
-    AddRef(void) = 0;
-
-    NS_IMETHOD_(MozExternalRefCountType)
-    Release(void) = 0;
+    NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
   };
 
   // Class containing data that can be opportunistically shared between
   // multiple Actions running on the same thread/Context.  In theory
   // this could be abstracted to a generic key/value map, but for now
   // just explicitly provide accessors for the data we need.
   class Data
   {
--- a/dom/cache/ReadStream.h
+++ b/dom/cache/ReadStream.h
@@ -62,21 +62,17 @@ public:
     CloseStreamWithoutReporting() = 0;
 
     virtual bool
     MatchId(const nsID& aId) const = 0;
 
     virtual bool
     HasEverBeenRead() const = 0;
 
-    NS_IMETHOD_(MozExternalRefCountType)
-    AddRef(void) = 0;
-
-    NS_IMETHOD_(MozExternalRefCountType)
-    Release(void) = 0;
+    NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
   };
 
   static already_AddRefed<ReadStream>
   Create(const CacheReadStreamOrVoid& aReadStreamOrVoid);
 
   static already_AddRefed<ReadStream>
   Create(const CacheReadStream& aReadStream);
 
--- a/dom/file/MutableBlobStorage.h
+++ b/dom/file/MutableBlobStorage.h
@@ -15,19 +15,17 @@ namespace dom {
 
 class Blob;
 class BlobImpl;
 class MutableBlobStorage;
 
 class MutableBlobStorageCallback
 {
 public:
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void BlobStoreCompleted(MutableBlobStorage* aBlobStorage,
                                   Blob* aBlob,
                                   nsresult aRv) = 0;
 };
 
 // This class is main-thread only.
 class MutableBlobStorage final
--- a/dom/filehandle/FileHandleCommon.h
+++ b/dom/filehandle/FileHandleCommon.h
@@ -1,36 +1,33 @@
 /* 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 mozilla_dom_FileHandleCommon_h
 #define mozilla_dom_FileHandleCommon_h
 
 #include "nscore.h"
+#include "nsISupportsImpl.h"
 
 #ifdef DEBUG
 #define DEBUGONLY(...)  __VA_ARGS__
 #else
 #define DEBUGONLY(...)  /* nothing */
 #endif
 
 struct PRThread;
 
 namespace mozilla {
 namespace dom {
 
 class RefCountedObject
 {
 public:
-  NS_IMETHOD_(MozExternalRefCountType)
-  AddRef() = 0;
-
-  NS_IMETHOD_(MozExternalRefCountType)
-  Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
 protected:
   virtual ~RefCountedObject()
   { }
 };
 
 class ThreadObject
 {
--- a/dom/flyweb/HttpServer.h
+++ b/dom/flyweb/HttpServer.h
@@ -30,19 +30,17 @@ extern bool
 ContainsToken(const nsCString& aList, const nsCString& aToken);
 
 class InternalRequest;
 class InternalResponse;
 
 class HttpServerListener
 {
 public:
-  // switch to NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING when that lands
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void OnServerStarted(nsresult aStatus) = 0;
   virtual void OnRequest(InternalRequest* aRequest) = 0;
   virtual void OnWebSocket(InternalRequest* aConnectRequest) = 0;
   virtual void OnServerClose() = 0;
 };
 
 class HttpServer final : public nsIServerSocketListener,
--- a/dom/media/eme/CDMProxy.h
+++ b/dom/media/eme/CDMProxy.h
@@ -68,18 +68,17 @@ typedef int64_t UnixTime;
 // passed via IPC to the CDM, which can then signal when to reject or
 // resolve the promise using its PromiseId.
 class CDMProxy {
 protected:
   typedef dom::PromiseId PromiseId;
   typedef dom::MediaKeySessionType MediaKeySessionType;
 public:
 
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   typedef MozPromise<DecryptResult, DecryptResult, /* IsExclusive = */ true> DecryptPromise;
 
   // Main thread only.
   CDMProxy(dom::MediaKeys* aKeys,
            const nsAString& aKeySystem,
            bool aDistinctiveIdentifierRequired,
            bool aPersistentStateRequired)
--- a/dom/quota/Client.h
+++ b/dom/quota/Client.h
@@ -25,21 +25,17 @@ class QuotaManager;
 class UsageInfo;
 
 // An abstract interface for quota manager clients.
 // Each storage API must provide an implementation of this interface in order
 // to participate in centralized quota and storage handling.
 class Client
 {
 public:
-  NS_IMETHOD_(MozExternalRefCountType)
-  AddRef() = 0;
-
-  NS_IMETHOD_(MozExternalRefCountType)
-  Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   enum Type {
     IDB = 0,
     //LS,
     //APPCACHE,
     ASMJS,
     DOMCACHE,
     TYPE_MAX
--- a/dom/quota/QuotaManager.h
+++ b/dom/quota/QuotaManager.h
@@ -39,21 +39,17 @@ class GroupInfo;
 class GroupInfoPair;
 class OriginInfo;
 class OriginScope;
 class QuotaObject;
 
 class NS_NO_VTABLE RefCountedObject
 {
 public:
-  NS_IMETHOD_(MozExternalRefCountType)
-  AddRef() = 0;
-
-  NS_IMETHOD_(MozExternalRefCountType)
-  Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 };
 
 class DirectoryLock
   : public RefCountedObject
 {
   friend class DirectoryLockImpl;
 
 private:
--- a/dom/workers/ServiceWorkerEvents.h
+++ b/dom/workers/ServiceWorkerEvents.h
@@ -52,21 +52,17 @@ public:
 class ExtendableEvent : public Event
 {
 public:
   class ExtensionsHandler {
   public:
     virtual bool
     WaitOnPromise(Promise& aPromise) = 0;
 
-    NS_IMETHOD_(MozExternalRefCountType)
-    AddRef() = 0;
-
-    NS_IMETHOD_(MozExternalRefCountType)
-    Release() = 0;
+    NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
   };
 
 private:
   RefPtr<ExtensionsHandler> mExtensionsHandler;
 
 protected:
   bool
   WaitOnPromise(Promise& aPromise);
--- a/dom/workers/ServiceWorkerJob.h
+++ b/dom/workers/ServiceWorkerJob.h
@@ -28,21 +28,17 @@ public:
   {
   public:
     // Called once when the job completes.  If the job is started, then this
     // will be called.  If a job is never executed due to browser shutdown,
     // then this method will never be called.  This method is always called
     // on the main thread asynchronously after Start() completes.
     virtual void JobFinished(ServiceWorkerJob* aJob, ErrorResult& aStatus) = 0;
 
-    NS_IMETHOD_(MozExternalRefCountType)
-    AddRef(void) = 0;
-
-    NS_IMETHOD_(MozExternalRefCountType)
-    Release(void) = 0;
+    NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
   };
 
   enum class Type
   {
     Register,
     Update,
     Unregister
   };
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -206,21 +206,17 @@ enum ExtendableEventResult {
     Resolved
 };
 
 class ExtendableEventCallback {
 public:
   virtual void
   FinishedWithResult(ExtendableEventResult aResult) = 0;
 
-  NS_IMETHOD_(MozExternalRefCountType)
-  AddRef() = 0;
-
-  NS_IMETHOD_(MozExternalRefCountType)
-  Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 };
 
 class KeepAliveHandler final : public WorkerHolder
                              , public ExtendableEvent::ExtensionsHandler
                              , public PromiseNativeHandler
 {
   // This class manages lifetime extensions added by calling WaitUntil()
   // or RespondWith(). We allow new extensions as long as we still hold
--- a/dom/workers/ServiceWorkerRegistration.h
+++ b/dom/workers/ServiceWorkerRegistration.h
@@ -30,18 +30,17 @@ class ServiceWorker;
 class WorkerPrivate;
 } // namespace workers
 
 // Used by ServiceWorkerManager to notify ServiceWorkerRegistrations of
 // updatefound event and invalidating ServiceWorker instances.
 class ServiceWorkerRegistrationListener
 {
 public:
-  NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void
   UpdateFound() = 0;
 
   virtual void
   InvalidateWorkers(WhichServiceWorker aWhichOnes) = 0;
 
   virtual void
--- a/dom/workers/ServiceWorkerScriptCache.h
+++ b/dom/workers/ServiceWorkerScriptCache.h
@@ -45,18 +45,17 @@ public:
    * Right before fetching the main script from the network, we check whether
    * the script expiration timer has expired. Via this method, we can save the
    * result of the check, and propogate it to the new ServiceWorkerInfo if there
    * is one, so the imported scripts can be affected by the result as well.
    */
   virtual void
   SaveLoadFlags(nsLoadFlags aLoadFlags) = 0;
 
-  NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 };
 
 nsresult
 Compare(ServiceWorkerRegistrationInfo* aRegistration,
         nsIPrincipal* aPrincipal, const nsAString& aCacheName,
         const nsAString& aURL, CompareCallback* aCallback, nsILoadGroup* aLoadGroup);
 
 } // namespace serviceWorkerScriptCache
--- a/dom/xslt/xslt/txStylesheetCompiler.h
+++ b/dom/xslt/xslt/txStylesheetCompiler.h
@@ -41,18 +41,17 @@ public:
     RefPtr<txNamespaceMap> mMappings;
     nsTArray<int32_t> mInstructionNamespaces;
     int32_t mDepth;
 };
 
 class txACompileObserver
 {
 public:
-    NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
-    NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
+    NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
     virtual nsresult loadURI(const nsAString& aUri,
                              const nsAString& aReferrerUri,
                              mozilla::net::ReferrerPolicy aReferrerPolicy,
                              txStylesheetCompiler* aCompiler) = 0;
     virtual void onDoneCompiling(txStylesheetCompiler* aCompiler,
                                  nsresult aResult,
                                  const char16_t *aErrorText = nullptr,
--- a/gfx/layers/apz/public/CompositorController.h
+++ b/gfx/layers/apz/public/CompositorController.h
@@ -2,27 +2,25 @@
 /* vim: set sw=4 ts=8 et tw=80 : */
 /* 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 mozilla_layers_CompositorController_h
 #define mozilla_layers_CompositorController_h
 
-#include "mozilla/RefCountType.h" // for MozExternalRefCountType
-#include "nscore.h" // for NS_IMETHOD_
+#include "nsISupportsImpl.h" // for NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
 namespace mozilla {
 namespace layers {
 
 class CompositorController
 {
 public:
-  NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void ScheduleRenderOnCompositorThread() = 0;
   virtual void ScheduleHideAllPluginWindows() = 0;
   virtual void ScheduleShowAllPluginWindows() = 0;
 
 protected:
   virtual ~CompositorController() {}
 };
--- a/gfx/layers/apz/public/MetricsSharingController.h
+++ b/gfx/layers/apz/public/MetricsSharingController.h
@@ -5,27 +5,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layers_MetricsSharingController_h
 #define mozilla_layers_MetricsSharingController_h
 
 #include "FrameMetrics.h" // for FrameMetrics
 #include "mozilla/ipc/CrossProcessMutex.h" // for CrossProcessMutexHandle
 #include "mozilla/ipc/SharedMemoryBasic.h" // for SharedMemoryBasic
-#include "mozilla/RefCountType.h" // for MozExternalRefCountType
-#include "nscore.h" // for NS_IMETHOD_
+#include "nsISupportsImpl.h" // for NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
 namespace mozilla {
 namespace layers {
 
 class MetricsSharingController
 {
 public:
-  NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual base::ProcessId RemotePid() = 0;
   virtual bool StartSharingMetrics(mozilla::ipc::SharedMemoryBasic::Handle aHandle,
                                    CrossProcessMutexHandle aMutexHandle,
                                    uint64_t aLayersId,
                                    uint32_t aApzcId) = 0;
   virtual bool StopSharingMetrics(FrameMetrics::ViewID aScrollId,
                                   uint32_t aApzcId) = 0;
--- a/gfx/layers/ipc/KnowsCompositor.h
+++ b/gfx/layers/ipc/KnowsCompositor.h
@@ -18,18 +18,17 @@ class TextureForwarder;
 class LayersIPCActor;
 
 /**
  * An abstract interface for classes that are tied to a specific Compositor across
  * IPDL and uses TextureFactoryIdentifier to describe this Compositor.
  */
 class KnowsCompositor {
 public:
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   KnowsCompositor();
   ~KnowsCompositor();
 
   void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
 
   SyncObject* GetSyncObject() { return mSyncObject; }
 
--- a/gfx/layers/ipc/TextureForwarder.h
+++ b/gfx/layers/ipc/TextureForwarder.h
@@ -32,18 +32,17 @@ public:
  * An abstract interface for LayersIPCActors that implement a top-level
  * IPDL protocol so also have their own channel.
  * Has their own MessageLoop for message dispatch, and can allocate
  * shmem.
  */
 class LayersIPCChannel : public LayersIPCActor
                        , public mozilla::ipc::IShmemAllocator {
 public:
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual bool IsSameProcess() const = 0;
 
   virtual bool UsesImageBridge() const { return false; }
 
   virtual base::ProcessId GetParentPid() const = 0;
 
   virtual MessageLoop* GetMessageLoop() const = 0;
--- a/image/IProgressObserver.h
+++ b/image/IProgressObserver.h
@@ -27,18 +27,17 @@ namespace image {
  */
 class IProgressObserver : public SupportsWeakPtr<IProgressObserver>
 {
 public:
   MOZ_DECLARE_WEAKREFERENCE_TYPENAME(IProgressObserver)
 
   // Subclasses may or may not be XPCOM classes, so we just require that they
   // implement AddRef and Release.
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   // imgINotificationObserver methods:
   virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) = 0;
   virtual void OnLoadComplete(bool aLastPart) = 0;
 
   // imgIOnloadBlocker methods:
   virtual void BlockOnload() = 0;
   virtual void UnblockOnload() = 0;
--- a/image/ISurfaceProvider.h
+++ b/image/ISurfaceProvider.h
@@ -32,18 +32,17 @@ class DrawableSurface;
  * An interface for objects which can either store a surface or dynamically
  * generate one.
  */
 class ISurfaceProvider
 {
 public:
   // Subclasses may or may not be XPCOM classes, so we just require that they
   // implement AddRef and Release.
-  NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   /// @return key data used for identifying which image this ISurfaceProvider is
   /// associated with in the surface cache.
   ImageKey GetImageKey() const { return mImageKey; }
 
   /// @return key data used to uniquely identify this ISurfaceProvider's cache
   /// entry in the surface cache.
   const SurfaceKey& GetSurfaceKey() const { return mSurfaceKey; }
--- a/image/SourceBuffer.h
+++ b/image/SourceBuffer.h
@@ -36,18 +36,17 @@ class SourceBuffer;
  * runnable to some event target which continues the work of the task.
  */
 struct IResumable
 {
   MOZ_DECLARE_REFCOUNTED_TYPENAME(IResumable)
 
   // Subclasses may or may not be XPCOM classes, so we just require that they
   // implement AddRef and Release.
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void Resume() = 0;
 
 protected:
   virtual ~IResumable() { }
 };
 
 /**
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -49,18 +49,17 @@ class VsyncChild;
 class nsARefreshObserver {
 public:
   // AddRef and Release signatures that match nsISupports.  Implementors
   // must implement reference counting, and those that do implement
   // nsISupports will already have methods with the correct signature.
   //
   // The refresh driver does NOT hold references to refresh observers
   // except while it is notifying them.
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
 };
 
 /**
  * An abstract base class to be implemented by callers wanting to be notified
  * that a refresh has occurred. Callers must ensure an observer is removed
  * before it is destroyed.
--- a/layout/style/CounterStyleManager.h
+++ b/layout/style/CounterStyleManager.h
@@ -91,18 +91,17 @@ public:
                                  bool& aIsRTL);
   virtual bool GetInitialCounterText(CounterValue aOrdinal,
                                      WritingMode aWritingMode,
                                      nsSubstring& aResult,
                                      bool& aIsRTL) = 0;
 
   virtual AnonymousCounterStyle* AsAnonymous() { return nullptr; }
 
-  NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
 protected:
   int32_t mStyle;
 };
 
 class AnonymousCounterStyle final : public CounterStyle
 {
 public:
--- a/media/mtransport/nr_socket_prsock.h
+++ b/media/mtransport/nr_socket_prsock.h
@@ -116,18 +116,17 @@ public:
   virtual int accept(nr_transport_addr *addrp, nr_socket **sockp) = 0;
 
    // Implementations of the async_event APIs
   virtual int async_wait(int how, NR_async_cb cb, void *cb_arg,
                          char *function, int line);
   virtual int cancel(int how);
 
   // nsISupport reference counted interface
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   uint32_t poll_flags() {
     return poll_flags_;
   }
 
   virtual nr_socket_vtbl *vtbl();  // To access in test classes.
 
   static TimeStamp short_term_violation_time();
--- a/netwerk/base/ARefBase.h
+++ b/netwerk/base/ARefBase.h
@@ -17,16 +17,15 @@ namespace mozilla { namespace net {
 // but it may or may not be xpcom.
 
 class ARefBase
 {
 public:
   ARefBase() {}
   virtual ~ARefBase() {}
 
-  NS_IMETHOD_ (MozExternalRefCountType) AddRef() = 0;
-  NS_IMETHOD_ (MozExternalRefCountType) Release() = 0;
+  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif
--- a/xpcom/base/nsISupportsImpl.h
+++ b/xpcom/base/nsISupportsImpl.h
@@ -538,16 +538,28 @@ NS_INLINE_DECL_THREADSAFE_REFCOUNTING_ME
 /**
  * Like NS_INLINE_DECL_THREADSAFE_REFCOUNTING with AddRef & Release declared
  * virtual.
  */
 #define NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING(_class, ...)            \
 NS_INLINE_DECL_THREADSAFE_REFCOUNTING_META(_class, NS_IMETHOD_, __VA_ARGS__)
 
 /**
+ * Use this macro in interface classes that you want to be able to reference
+ * using RefPtr, but don't want to provide a refcounting implemenation. The
+ * refcounting implementation can be provided by concrete subclasses that
+ * implement the interface.
+ */
+#define NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING                               \
+public:                                                                       \
+  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;                      \
+  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;                     \
+public:
+
+/**
  * Use this macro to implement the AddRef method for a given <i>_class</i>
  * @param _class The name of the class implementing the method
  */
 #define NS_IMPL_ADDREF(_class)                                                \
 NS_IMETHODIMP_(MozExternalRefCountType) _class::AddRef(void)                  \
 {                                                                             \
   MOZ_ASSERT_TYPE_OK_FOR_REFCOUNTING(_class)                                  \
   MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");                        \