Skip to content

Commit

Permalink
Bug 1312319 - Add a NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING macro and…
Browse files Browse the repository at this point in the history
… replace existing pure-virtual AddRef/Release declarations. r=froydnj

MozReview-Commit-ID: 5yt3O4Hoois
  • Loading branch information
staktrace committed Jan 25, 2017
1 parent 8a18829 commit 385a566
Show file tree
Hide file tree
Showing 26 changed files with 40 additions and 80 deletions.
6 changes: 1 addition & 5 deletions dom/cache/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ class Action
// 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
Expand Down
6 changes: 1 addition & 5 deletions dom/cache/ReadStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ class ReadStream final : public nsIInputStream
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>
Expand Down
4 changes: 1 addition & 3 deletions dom/file/MutableBlobStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ 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,
Expand Down
7 changes: 2 additions & 5 deletions dom/filehandle/FileHandleCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define mozilla_dom_FileHandleCommon_h

#include "nscore.h"
#include "nsISupportsImpl.h"

#ifdef DEBUG
#define DEBUGONLY(...) __VA_ARGS__
Expand All @@ -21,11 +22,7 @@ namespace dom {
class RefCountedObject
{
public:
NS_IMETHOD_(MozExternalRefCountType)
AddRef() = 0;

NS_IMETHOD_(MozExternalRefCountType)
Release() = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING

protected:
virtual ~RefCountedObject()
Expand Down
4 changes: 1 addition & 3 deletions dom/flyweb/HttpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ 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;
Expand Down
3 changes: 1 addition & 2 deletions dom/media/eme/CDMProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class CDMProxy {
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;

Expand Down
6 changes: 1 addition & 5 deletions dom/quota/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ class UsageInfo;
class Client
{
public:
NS_IMETHOD_(MozExternalRefCountType)
AddRef() = 0;

NS_IMETHOD_(MozExternalRefCountType)
Release() = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING

enum Type {
IDB = 0,
Expand Down
6 changes: 1 addition & 5 deletions dom/quota/QuotaManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ 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
Expand Down
6 changes: 1 addition & 5 deletions dom/workers/ServiceWorkerEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ class ExtendableEvent : public Event
virtual bool
WaitOnPromise(Promise& aPromise) = 0;

NS_IMETHOD_(MozExternalRefCountType)
AddRef() = 0;

NS_IMETHOD_(MozExternalRefCountType)
Release() = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
};

private:
Expand Down
6 changes: 1 addition & 5 deletions dom/workers/ServiceWorkerJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class ServiceWorkerJob
// 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
Expand Down
6 changes: 1 addition & 5 deletions dom/workers/ServiceWorkerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,7 @@ class ExtendableEventCallback {
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
Expand Down
3 changes: 1 addition & 2 deletions dom/workers/ServiceWorkerRegistration.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class WorkerPrivate;
class ServiceWorkerRegistrationListener
{
public:
NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING

virtual void
UpdateFound() = 0;
Expand Down
3 changes: 1 addition & 2 deletions dom/workers/ServiceWorkerScriptCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class CompareCallback
virtual void
SaveLoadFlags(nsLoadFlags aLoadFlags) = 0;

NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
};

nsresult
Expand Down
3 changes: 1 addition & 2 deletions dom/xslt/xslt/txStylesheetCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class txElementContext : public txObject
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,
Expand Down
6 changes: 2 additions & 4 deletions gfx/layers/apz/public/CompositorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
#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;
Expand Down
6 changes: 2 additions & 4 deletions gfx/layers/apz/public/MetricsSharingController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@
#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,
Expand Down
3 changes: 1 addition & 2 deletions gfx/layers/ipc/KnowsCompositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class LayersIPCActor;
*/
class KnowsCompositor {
public:
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING

KnowsCompositor();
~KnowsCompositor();
Expand Down
3 changes: 1 addition & 2 deletions gfx/layers/ipc/TextureForwarder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class LayersIPCActor {
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;

Expand Down
3 changes: 1 addition & 2 deletions image/IProgressObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class IProgressObserver : public SupportsWeakPtr<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;
Expand Down
3 changes: 1 addition & 2 deletions image/ISurfaceProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ 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.
Expand Down
3 changes: 1 addition & 2 deletions image/SourceBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ struct 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;

Expand Down
3 changes: 1 addition & 2 deletions layout/base/nsRefreshDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class nsARefreshObserver {
//
// 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;
};
Expand Down
3 changes: 1 addition & 2 deletions layout/style/CounterStyleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ class CounterStyle

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;
Expand Down
3 changes: 1 addition & 2 deletions media/mtransport/nr_socket_prsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ class NrSocketBase {
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_;
Expand Down
3 changes: 1 addition & 2 deletions netwerk/base/ARefBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class ARefBase
ARefBase() {}
virtual ~ARefBase() {}

NS_IMETHOD_ (MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_ (MozExternalRefCountType) Release() = 0;
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
};

} // namespace net
Expand Down
12 changes: 12 additions & 0 deletions xpcom/base/nsISupportsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,18 @@ NS_INLINE_DECL_THREADSAFE_REFCOUNTING_META(_class, NS_METHOD_, __VA_ARGS__)
#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
Expand Down

0 comments on commit 385a566

Please sign in to comment.