diff --git a/content/media/MediaTaskQueue.h b/content/media/MediaTaskQueue.h index 3cf860c3c5a..08680e1fd48 100644 --- a/content/media/MediaTaskQueue.h +++ b/content/media/MediaTaskQueue.h @@ -23,13 +23,11 @@ class SharedThreadPool; // they're received, and are guaranteed to not be executed concurrently. // They may be executed on different threads, and a memory barrier is used // to make this threadsafe for objects that aren't already threadsafe. -class MediaTaskQueue MOZ_FINAL { - ~MediaTaskQueue(); - +class MediaTaskQueue : public AtomicRefCounted { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaTaskQueue) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(MediaTaskQueue) MediaTaskQueue(TemporaryRef aPool); + ~MediaTaskQueue(); nsresult Dispatch(nsIRunnable* aRunnable); diff --git a/content/media/fmp4/PlatformDecoderModule.h b/content/media/fmp4/PlatformDecoderModule.h index 3438c0d62d7..06e439cf47c 100644 --- a/content/media/fmp4/PlatformDecoderModule.h +++ b/content/media/fmp4/PlatformDecoderModule.h @@ -143,12 +143,10 @@ public: // MediaTaskQueue passed into the PlatformDecoderModules's Create*Decoder() // function. This may not be necessary for platforms with async APIs // for decoding. -class MediaDataDecoder { -protected: - virtual ~MediaDataDecoder() {}; - +class MediaDataDecoder : public AtomicRefCounted { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataDecoder) + MOZ_DECLARE_REFCOUNTED_TYPENAME(MediaDataDecoder) + virtual ~MediaDataDecoder() {}; // Initialize the decoder. The decoder should be ready to decode after // this returns. The decoder should do any initialization here, rather diff --git a/content/media/fmp4/wmf/MFTDecoder.h b/content/media/fmp4/wmf/MFTDecoder.h index 0451cbd4355..56c76ed9a86 100644 --- a/content/media/fmp4/wmf/MFTDecoder.h +++ b/content/media/fmp4/wmf/MFTDecoder.h @@ -14,13 +14,11 @@ namespace mozilla { -class MFTDecoder MOZ_FINAL { - ~MFTDecoder(); - +class MFTDecoder : public AtomicRefCounted { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MFTDecoder) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(MTFDecoder) MFTDecoder(); + ~MFTDecoder(); // Creates the MFT. First thing to do as part of setup. // diff --git a/dom/bluetooth/BluetoothProfileController.h b/dom/bluetooth/BluetoothProfileController.h index faf5131572a..fac94151e4c 100644 --- a/dom/bluetooth/BluetoothProfileController.h +++ b/dom/bluetooth/BluetoothProfileController.h @@ -8,7 +8,7 @@ #define mozilla_dom_bluetooth_bluetoothprofilecontroller_h__ #include "BluetoothUuid.h" -#include "nsISupportsImpl.h" +#include "mozilla/RefPtr.h" #include "nsAutoPtr.h" #include "nsITimer.h" @@ -57,12 +57,10 @@ class BluetoothProfileManagerBase; class BluetoothReplyRunnable; typedef void (*BluetoothProfileControllerCallback)(); -class BluetoothProfileController MOZ_FINAL +class BluetoothProfileController : public RefCounted { - ~BluetoothProfileController(); - public: - NS_INLINE_DECL_REFCOUNTING(BluetoothProfileController) + MOZ_DECLARE_REFCOUNTED_TYPENAME(BluetoothProfileController) /** * @param aConnect: If it's a connect request, the value should be set * to true. For disconnect request, set it to false. @@ -85,6 +83,7 @@ public: BluetoothProfileControllerCallback aCallback, uint16_t aServiceUuid, uint32_t aCod = 0); + ~BluetoothProfileController(); /** * The controller starts connecting/disconnecting profiles one by one diff --git a/dom/camera/CameraControlImpl.h b/dom/camera/CameraControlImpl.h index 76887813e80..8aaff7e4a4d 100644 --- a/dom/camera/CameraControlImpl.h +++ b/dom/camera/CameraControlImpl.h @@ -19,6 +19,8 @@ #include "DeviceStorageFileDescriptor.h" #include "CameraControlListener.h" +class DeviceStorageFileDescriptor; + namespace mozilla { namespace layers { diff --git a/dom/camera/ICameraControl.h b/dom/camera/ICameraControl.h index 17768cad2e2..76aa07f1692 100644 --- a/dom/camera/ICameraControl.h +++ b/dom/camera/ICameraControl.h @@ -10,7 +10,7 @@ #include "nsAutoPtr.h" #include "nsISupportsImpl.h" -struct DeviceStorageFileDescriptor; +class DeviceStorageFileDescriptor; class nsIFile; diff --git a/dom/devicestorage/DeviceStorage.h b/dom/devicestorage/DeviceStorage.h index 04ec4af5e75..3fe4ee00f26 100644 --- a/dom/devicestorage/DeviceStorage.h +++ b/dom/devicestorage/DeviceStorage.h @@ -321,7 +321,13 @@ private: friend class WatchFileEvent; friend class DeviceStorageRequest; - static mozilla::StaticAutoPtr> sVolumeNameCache; + class VolumeNameCache : public mozilla::RefCounted + { + public: + MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeNameCache) + nsTArray mVolumeNames; + }; + static mozilla::StaticRefPtr sVolumeNameCache; #ifdef MOZ_WIDGET_GONK nsString mLastStatus; diff --git a/dom/devicestorage/DeviceStorageFileDescriptor.h b/dom/devicestorage/DeviceStorageFileDescriptor.h index d9fed28d8c8..36749f4245c 100644 --- a/dom/devicestorage/DeviceStorageFileDescriptor.h +++ b/dom/devicestorage/DeviceStorageFileDescriptor.h @@ -9,9 +9,11 @@ #include "mozilla/ipc/FileDescriptor.h" -struct DeviceStorageFileDescriptor MOZ_FINAL +class DeviceStorageFileDescriptor MOZ_FINAL + : public mozilla::RefCounted { - NS_INLINE_DECL_REFCOUNTING(DeviceStorageFileDescriptor) +public: + MOZ_DECLARE_REFCOUNTED_TYPENAME(DeviceStorageFileDescriptor) nsRefPtr mDSFile; mozilla::ipc::FileDescriptor mFileDescriptor; }; diff --git a/dom/devicestorage/DeviceStorageRequestChild.h b/dom/devicestorage/DeviceStorageRequestChild.h index d0fcee80444..83eae6cbff2 100644 --- a/dom/devicestorage/DeviceStorageRequestChild.h +++ b/dom/devicestorage/DeviceStorageRequestChild.h @@ -9,7 +9,7 @@ #include "mozilla/dom/devicestorage/PDeviceStorageRequestChild.h" class DeviceStorageFile; -struct DeviceStorageFileDescriptor; +class DeviceStorageFileDescriptor; namespace mozilla { namespace dom { diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index 3d4e0d0e676..228afef8a5e 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -115,16 +115,15 @@ DeviceStorageUsedSpaceCache::CreateOrGet() return sDeviceStorageUsedSpaceCache; } -already_AddRefed +TemporaryRef DeviceStorageUsedSpaceCache::GetCacheEntry(const nsAString& aStorageName) { - nsTArray>::size_type numEntries = mCacheEntries.Length(); - nsTArray>::index_type i; + nsTArray >::size_type numEntries = mCacheEntries.Length(); + nsTArray >::index_type i; for (i = 0; i < numEntries; i++) { - nsRefPtr& cacheEntry = mCacheEntries[i]; + RefPtr cacheEntry = mCacheEntries[i]; if (cacheEntry->mStorageName.Equals(aStorageName)) { - nsRefPtr addRefedCacheEntry = cacheEntry; - return addRefedCacheEntry.forget(); + return cacheEntry; } } return nullptr; @@ -150,7 +149,7 @@ DeviceStorageUsedSpaceCache::AccumUsedSizes(const nsAString& aStorageName, uint64_t* aMusicSoFar, uint64_t* aTotalSoFar) { - nsRefPtr cacheEntry = GetCacheEntry(aStorageName); + RefPtr cacheEntry = GetCacheEntry(aStorageName); if (!cacheEntry || cacheEntry->mDirty) { return NS_ERROR_NOT_AVAILABLE; } @@ -175,7 +174,7 @@ DeviceStorageUsedSpaceCache::SetUsedSizes(const nsAString& aStorageName, uint64_t aMusicSize, uint64_t aTotalUsedSize) { - nsRefPtr cacheEntry = GetCacheEntry(aStorageName); + RefPtr cacheEntry = GetCacheEntry(aStorageName); if (!cacheEntry) { cacheEntry = new CacheEntry; cacheEntry->mStorageName = aStorageName; @@ -190,10 +189,10 @@ DeviceStorageUsedSpaceCache::SetUsedSizes(const nsAString& aStorageName, cacheEntry->mDirty = false; } -class GlobalDirs +class GlobalDirs : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(GlobalDirs) + MOZ_DECLARE_REFCOUNTED_TYPENAME(GlobalDirs) #if !defined(MOZ_WIDGET_GONK) nsCOMPtr pictures; nsCOMPtr videos; @@ -3180,15 +3179,16 @@ nsDOMDeviceStorage::Shutdown() obs->RemoveObserver(this, "disk-space-watcher"); } -StaticAutoPtr> nsDOMDeviceStorage::sVolumeNameCache; +StaticRefPtr + nsDOMDeviceStorage::sVolumeNameCache; // static void nsDOMDeviceStorage::GetOrderedVolumeNames( nsDOMDeviceStorage::VolumeNameArray &aVolumeNames) { - if (sVolumeNameCache && sVolumeNameCache->Length() > 0) { - aVolumeNames.AppendElements(*sVolumeNameCache); + if (sVolumeNameCache && sVolumeNameCache->mVolumeNames.Length() > 0) { + aVolumeNames.AppendElements(sVolumeNameCache->mVolumeNames); return; } #ifdef MOZ_WIDGET_GONK @@ -3209,8 +3209,8 @@ nsDOMDeviceStorage::GetOrderedVolumeNames( if (aVolumeNames.IsEmpty()) { aVolumeNames.AppendElement(EmptyString()); } - sVolumeNameCache = new nsTArray; - sVolumeNameCache->AppendElements(aVolumeNames); + sVolumeNameCache = new VolumeNameCache; + sVolumeNameCache->mVolumeNames.AppendElements(aVolumeNames); } // static diff --git a/dom/devicestorage/nsDeviceStorage.h b/dom/devicestorage/nsDeviceStorage.h index 6623702060b..b77fbc780a1 100644 --- a/dom/devicestorage/nsDeviceStorage.h +++ b/dom/devicestorage/nsDeviceStorage.h @@ -29,6 +29,7 @@ class nsPIDOMWindow; #include "prtime.h" #include "DeviceStorage.h" #include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h" +#include "mozilla/RefPtr.h" #include "mozilla/StaticPtr.h" namespace mozilla { @@ -79,7 +80,7 @@ public: NS_IMETHOD Run() MOZ_OVERRIDE { - nsRefPtr cacheEntry; + mozilla::RefPtr cacheEntry; cacheEntry = mCache->GetCacheEntry(mStorageName); if (cacheEntry) { cacheEntry->mDirty = true; @@ -119,10 +120,10 @@ public: private: friend class InvalidateRunnable; - struct CacheEntry + class CacheEntry : public mozilla::RefCounted { - NS_INLINE_DECL_REFCOUNTING(DeviceStorageUsedSpaceCache::CacheEntry) - + public: + MOZ_DECLARE_REFCOUNTED_TYPENAME(DeviceStorageUsedSpaceCache::CacheEntry) bool mDirty; nsString mStorageName; int64_t mFreeBytes; @@ -131,9 +132,9 @@ private: uint64_t mMusicUsedSize; uint64_t mTotalUsedSize; }; - already_AddRefed GetCacheEntry(const nsAString& aStorageName); + mozilla::TemporaryRef GetCacheEntry(const nsAString& aStorageName); - nsTArray> mCacheEntries; + nsTArray > mCacheEntries; nsCOMPtr mIOThread; diff --git a/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl b/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl index aab63294300..25b14fe1a72 100644 --- a/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl +++ b/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl @@ -12,7 +12,7 @@ interface nsIDOMEventListener; interface nsIFile; %{C++ -struct DeviceStorageFileDescriptor; +class DeviceStorageFileDescriptor; %} [ptr] native DeviceStorageFdPtr(DeviceStorageFileDescriptor); diff --git a/dom/system/gonk/AutoMounter.cpp b/dom/system/gonk/AutoMounter.cpp index 9d4dc54b8fb..250fc1a0b41 100644 --- a/dom/system/gonk/AutoMounter.cpp +++ b/dom/system/gonk/AutoMounter.cpp @@ -163,12 +163,12 @@ private: /***************************************************************************/ -class AutoMounter +class AutoMounter : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(AutoMounter) + MOZ_DECLARE_REFCOUNTED_TYPENAME(AutoMounter) - typedef nsTArray> VolumeArray; + typedef nsTArray > VolumeArray; AutoMounter() : mResponseCallback(new AutoMounterResponseCallback), @@ -180,7 +180,7 @@ public: VolumeManager::VolumeArray::size_type numVolumes = VolumeManager::NumVolumes(); VolumeManager::VolumeArray::index_type i; for (i = 0; i < numVolumes; i++) { - nsRefPtr vol = VolumeManager::GetVolume(i); + RefPtr vol = VolumeManager::GetVolume(i); if (vol) { vol->RegisterObserver(&mVolumeEventObserver); // We need to pick up the intial value of the @@ -198,7 +198,7 @@ public: VolumeManager::VolumeArray::size_type numVolumes = VolumeManager::NumVolumes(); VolumeManager::VolumeArray::index_type volIndex; for (volIndex = 0; volIndex < numVolumes; volIndex++) { - nsRefPtr vol = VolumeManager::GetVolume(volIndex); + RefPtr vol = VolumeManager::GetVolume(volIndex); if (vol) { vol->UnregisterObserver(&mVolumeEventObserver); } @@ -252,7 +252,7 @@ public: void SetSharingMode(const nsACString& aVolumeName, bool aAllowSharing) { - nsRefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); + RefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); if (!vol) { return; } @@ -269,7 +269,7 @@ public: void FormatVolume(const nsACString& aVolumeName) { - nsRefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); + RefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); if (!vol) { return; } @@ -286,7 +286,7 @@ public: void MountVolume(const nsACString& aVolumeName) { - nsRefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); + RefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); if (!vol) { return; } @@ -302,7 +302,7 @@ public: void UnmountVolume(const nsACString& aVolumeName) { - nsRefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); + RefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); if (!vol) { return; } @@ -449,7 +449,7 @@ AutoMounter::UpdateState() VolumeArray::index_type volIndex; VolumeArray::size_type numVolumes = VolumeManager::NumVolumes(); for (volIndex = 0; volIndex < numVolumes; volIndex++) { - nsRefPtr vol = VolumeManager::GetVolume(volIndex); + RefPtr vol = VolumeManager::GetVolume(volIndex); Volume::STATE volState = vol->State(); if (vol->State() == nsIVolume::STATE_MOUNTED) { @@ -692,21 +692,21 @@ UsbCableEventIOThread() * **************************************************************************/ -class UsbCableObserver MOZ_FINAL : public SwitchObserver +class UsbCableObserver : public SwitchObserver, + public RefCounted { - ~UsbCableObserver() - { - UnregisterSwitchObserver(SWITCH_USB, this); - } - public: - NS_INLINE_DECL_REFCOUNTING(UsbCableObserver) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(UsbCableObserver) UsbCableObserver() { RegisterSwitchObserver(SWITCH_USB, this); } + ~UsbCableObserver() + { + UnregisterSwitchObserver(SWITCH_USB, this); + } + virtual void Notify(const SwitchEvent& aEvent) { DBG("UsbCable switch device: %d state: %s\n", diff --git a/dom/system/gonk/Volume.h b/dom/system/gonk/Volume.h index 7bb3d32bfe4..9eb5302c964 100644 --- a/dom/system/gonk/Volume.h +++ b/dom/system/gonk/Volume.h @@ -9,7 +9,7 @@ #include "nsIVolume.h" #include "nsString.h" #include "mozilla/Observer.h" -#include "nsISupportsImpl.h" +#include "mozilla/RefPtr.h" #include "nsWhitespaceTokenizer.h" namespace mozilla { @@ -24,11 +24,10 @@ namespace system { * ***************************************************************************/ -class Volume MOZ_FINAL +class Volume : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(Volume) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(Volume) Volume(const nsCSubstring& aVolumeName); typedef long STATE; // States are now defined in nsIVolume.idl diff --git a/dom/system/gonk/VolumeCommand.h b/dom/system/gonk/VolumeCommand.h index 574a60aba26..8041185fdb5 100644 --- a/dom/system/gonk/VolumeCommand.h +++ b/dom/system/gonk/VolumeCommand.h @@ -6,7 +6,6 @@ #define mozilla_system_volumecommand_h__ #include "nsString.h" -#include "nsISupportsImpl.h" #include "mozilla/RefPtr.h" #include #include @@ -33,16 +32,15 @@ class VolumeCommand; * ***************************************************************************/ -class VolumeResponseCallback +class VolumeResponseCallback : public RefCounted { -protected: - virtual ~VolumeResponseCallback() {} - public: - NS_INLINE_DECL_REFCOUNTED(VolumeResponseCallback) + MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeResponseCallback) VolumeResponseCallback() : mResponseCode(0), mPending(false) {} + virtual ~VolumeResponseCallback() {} + bool Done() const { // Response codes from the 200, 400, and 500 series all indicated that @@ -108,14 +106,10 @@ private: * ***************************************************************************/ -class VolumeCommand +class VolumeCommand : public RefCounted { -protected: - virtual ~VolumeCommand() {} - public: - NS_INLINE_DECL_REFCOUNTED(VolumeCommand) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeCommand) VolumeCommand(VolumeResponseCallback* aCallback) : mBytesConsumed(0), mCallback(aCallback) @@ -130,6 +124,8 @@ public: SetCmd(aCommand); } + virtual ~VolumeCommand() {} + void SetCmd(const nsACString& aCommand) { mCmd.Truncate(); diff --git a/dom/system/gonk/VolumeManager.h b/dom/system/gonk/VolumeManager.h index 6dd4ebda78b..c3f34316ada 100644 --- a/dom/system/gonk/VolumeManager.h +++ b/dom/system/gonk/VolumeManager.h @@ -11,7 +11,7 @@ #include "base/message_loop.h" #include "mozilla/FileUtils.h" #include "mozilla/Observer.h" -#include "nsISupportsImpl.h" +#include "mozilla/RefPtr.h" #include "nsString.h" #include "nsTArray.h" @@ -73,16 +73,16 @@ namespace system { * ***************************************************************************/ -class VolumeManager MOZ_FINAL : public MessageLoopForIO::LineWatcher +class VolumeManager : public MessageLoopForIO::LineWatcher, + public RefCounted { - virtual ~VolumeManager(); - public: - NS_INLINE_DECL_REFCOUNTING(VolumeManager) + MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeManager) - typedef nsTArray> VolumeArray; + typedef nsTArray > VolumeArray; VolumeManager(); + virtual ~VolumeManager(); //----------------------------------------------------------------------- // diff --git a/dom/system/gonk/VolumeServiceIOThread.h b/dom/system/gonk/VolumeServiceIOThread.h index 0c2a6a62f24..835ccf64be2 100644 --- a/dom/system/gonk/VolumeServiceIOThread.h +++ b/dom/system/gonk/VolumeServiceIOThread.h @@ -19,14 +19,13 @@ class nsVolumeService; * class, but whose methods are called from IOThread. */ class VolumeServiceIOThread : public VolumeManager::StateObserver, - public Volume::EventObserver + public Volume::EventObserver, + public RefCounted { - ~VolumeServiceIOThread(); - public: - NS_INLINE_DECL_REFCOUNTING(VolumeServiceIOThread) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeServiceIOThread) VolumeServiceIOThread(nsVolumeService* aVolumeService); + ~VolumeServiceIOThread(); private: void UpdateAllVolumes(); diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index d869d1c4f76..f255ea07651 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -137,12 +137,18 @@ enum SurfaceInitMode /** * A base class for a platform-dependent helper for use by TextureHost. */ -class CompositorBackendSpecificData +class CompositorBackendSpecificData : public RefCounted { - NS_INLINE_DECL_REFCOUNTING(CompositorBackendSpecificData) - -protected: - virtual ~CompositorBackendSpecificData() {} +public: + MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositorBackendSpecificData) + CompositorBackendSpecificData() + { + MOZ_COUNT_CTOR(CompositorBackendSpecificData); + } + virtual ~CompositorBackendSpecificData() + { + MOZ_COUNT_DTOR(CompositorBackendSpecificData); + } }; /** @@ -189,20 +195,21 @@ protected: * The target and viewport methods can be called before any DrawQuad call and * affect any subsequent DrawQuad calls. */ -class Compositor +class Compositor : public RefCounted { -protected: - virtual ~Compositor() {} - public: - NS_INLINE_DECL_REFCOUNTING(Compositor) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(Compositor) Compositor(PCompositorParent* aParent = nullptr) : mCompositorID(0) , mDiagnosticTypes(DIAGNOSTIC_NONE) , mParent(aParent) , mScreenRotation(ROTATION_0) { + MOZ_COUNT_CTOR(Compositor); + } + virtual ~Compositor() + { + MOZ_COUNT_DTOR(Compositor); } virtual TemporaryRef CreateDataTextureSource(TextureFlags aFlags = 0) = 0; diff --git a/gfx/layers/Effects.h b/gfx/layers/Effects.h index ebf20035caa..c46880393dc 100644 --- a/gfx/layers/Effects.h +++ b/gfx/layers/Effects.h @@ -37,18 +37,15 @@ namespace layers { * to the compositor by the compositable host as a parameter to DrawQuad. */ -struct Effect +struct Effect : public RefCounted { - NS_INLINE_DECL_REFCOUNTING(Effect) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(Effect) Effect(EffectTypes aType) : mType(aType) {} EffectTypes mType; - virtual void PrintInfo(nsACString& aTo, const char* aPrefix) = 0; - -protected: virtual ~Effect() {} + virtual void PrintInfo(nsACString& aTo, const char* aPrefix) =0; }; // Render from a texture diff --git a/gfx/layers/client/CompositableClient.h b/gfx/layers/client/CompositableClient.h index 16f58c0517f..4f915ae3cc8 100644 --- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -68,16 +68,14 @@ class TextureClientData; * where we have a different way of interfacing with the textures - in terms of * drawing into the compositable and/or passing its contents to the compostior. */ -class CompositableClient +class CompositableClient : public AtomicRefCounted { -protected: - virtual ~CompositableClient(); - public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositableClient) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableClient) CompositableClient(CompositableForwarder* aForwarder, TextureFlags aFlags = 0); + virtual ~CompositableClient(); + virtual TextureInfo GetTextureInfo() const = 0; LayersBackend GetCompositorBackendType() const; diff --git a/gfx/layers/client/SimpleTextureClientPool.h b/gfx/layers/client/SimpleTextureClientPool.h index ccdf2295a4e..fb402718e19 100644 --- a/gfx/layers/client/SimpleTextureClientPool.h +++ b/gfx/layers/client/SimpleTextureClientPool.h @@ -19,8 +19,14 @@ namespace layers { class ISurfaceAllocator; -class SimpleTextureClientPool +class SimpleTextureClientPool : public RefCounted { +public: + MOZ_DECLARE_REFCOUNTED_TYPENAME(SimpleTextureClientPool) + + SimpleTextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize, + ISurfaceAllocator *aAllocator); + ~SimpleTextureClientPool() { for (auto it = mOutstandingTextureClients.begin(); it != mOutstandingTextureClients.end(); ++it) { @@ -28,12 +34,6 @@ class SimpleTextureClientPool } } -public: - NS_INLINE_DECL_REFCOUNTING(SimpleTextureClientPool) - - SimpleTextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize, - ISurfaceAllocator *aAllocator); - /** * If a TextureClient is AutoRecycled, when the last reference is * released this object will be automatically return to the pool as diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 28163507d1d..35173c827c1 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -75,17 +75,23 @@ namespace layers { * TextureClient's data until the compositor side confirmed that it is safe to * deallocte or recycle the it. */ -class TextureChild MOZ_FINAL : public PTextureChild +class TextureChild : public PTextureChild + , public AtomicRefCounted { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureChild) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureChild) TextureChild() : mForwarder(nullptr) , mTextureData(nullptr) , mTextureClient(nullptr) , mIPCOpen(false) { + MOZ_COUNT_CTOR(TextureChild); + } + + ~TextureChild() + { + MOZ_COUNT_DTOR(TextureChild); } bool Recv__delete__() MOZ_OVERRIDE; diff --git a/gfx/layers/client/TextureClientPool.h b/gfx/layers/client/TextureClientPool.h index ff2c707bce6..a9ebbe0433c 100644 --- a/gfx/layers/client/TextureClientPool.h +++ b/gfx/layers/client/TextureClientPool.h @@ -18,15 +18,13 @@ namespace layers { class ISurfaceAllocator; -class TextureClientPool MOZ_FINAL +class TextureClientPool : public RefCounted { - ~TextureClientPool(); - public: - NS_INLINE_DECL_REFCOUNTING(TextureClientPool) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureClientPool) TextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize, ISurfaceAllocator *aAllocator); + ~TextureClientPool(); /** * Gets an allocated TextureClient of size and format that are determined diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index 732b0724184..8b02d4b13d7 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -47,12 +47,10 @@ class ClientLayerManager; // A class to help implement copy-on-write semantics for shared tiles. -class gfxSharedReadLock { -protected: - virtual ~gfxSharedReadLock() {} - +class gfxSharedReadLock : public AtomicRefCounted { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxSharedReadLock) + MOZ_DECLARE_REFCOUNTED_TYPENAME(gfxSharedReadLock) + virtual ~gfxSharedReadLock() {} virtual int32_t ReadLock() = 0; virtual int32_t ReadUnlock() = 0; diff --git a/gfx/layers/composite/AsyncCompositionManager.h b/gfx/layers/composite/AsyncCompositionManager.h index 0ce44feef8d..6e60ac3e8c4 100644 --- a/gfx/layers/composite/AsyncCompositionManager.h +++ b/gfx/layers/composite/AsyncCompositionManager.h @@ -61,21 +61,22 @@ struct ViewTransform { * short circuit that stuff to directly affect layers as they are composited, * for example, off-main thread animation, async video, async pan/zoom. */ -class AsyncCompositionManager MOZ_FINAL +class AsyncCompositionManager MOZ_FINAL : public RefCounted { friend class AutoResolveRefLayers; public: - NS_INLINE_DECL_REFCOUNTING(AsyncCompositionManager) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(AsyncCompositionManager) AsyncCompositionManager(LayerManagerComposite* aManager) : mLayerManager(aManager) , mIsFirstPaint(false) , mLayersUpdated(false) , mReadyForCompose(true) { + MOZ_COUNT_CTOR(AsyncCompositionManager); } ~AsyncCompositionManager() { + MOZ_COUNT_DTOR(AsyncCompositionManager); } /** diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 10c42745dcf..f43ffb9f2fc 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -56,18 +56,18 @@ struct EffectChain; /** * A base class for doing CompositableHost and platform dependent task on TextureHost. */ -class CompositableBackendSpecificData +class CompositableBackendSpecificData : public RefCounted { -protected: - virtual ~CompositableBackendSpecificData() { } - public: - NS_INLINE_DECL_REFCOUNTING(CompositableBackendSpecificData) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableBackendSpecificData) CompositableBackendSpecificData() { + MOZ_COUNT_CTOR(CompositableBackendSpecificData); + } + virtual ~CompositableBackendSpecificData() + { + MOZ_COUNT_DTOR(CompositableBackendSpecificData); } - virtual void SetCompositor(Compositor* aCompositor) {} virtual void ClearData() { @@ -124,15 +124,14 @@ protected: * will use its TextureHost(s) and call Compositor::DrawQuad to do the actual * rendering. */ -class CompositableHost +class CompositableHost : public RefCounted { -protected: - virtual ~CompositableHost(); - public: - NS_INLINE_DECL_REFCOUNTING(CompositableHost) + MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableHost) CompositableHost(const TextureInfo& aTextureInfo); + virtual ~CompositableHost(); + static TemporaryRef Create(const TextureInfo& aTextureInfo); virtual CompositableType GetType() = 0; diff --git a/gfx/layers/composite/TextRenderer.h b/gfx/layers/composite/TextRenderer.h index 530fbe5bd95..eddcb2e78b8 100644 --- a/gfx/layers/composite/TextRenderer.h +++ b/gfx/layers/composite/TextRenderer.h @@ -7,7 +7,6 @@ #define GFX_TextRenderer_H #include "mozilla/gfx/2D.h" -#include "nsISupportsImpl.h" #include namespace mozilla { @@ -15,11 +14,10 @@ namespace layers { class Compositor; -class TextRenderer +class TextRenderer : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(TextRenderer) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(TextRenderer) TextRenderer(Compositor *aCompositor) : mCompositor(aCompositor) { diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index ea50d114a7e..e9392498240 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -80,15 +80,12 @@ public: * * This class is used on the compositor side. */ -class TextureSource +class TextureSource : public RefCounted { -protected: - virtual ~TextureSource(); - public: - NS_INLINE_DECL_REFCOUNTING(TextureSource) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureSource) TextureSource(); + virtual ~TextureSource(); /** * Return the size of the texture in texels. diff --git a/gfx/layers/ipc/LayerTransactionChild.h b/gfx/layers/ipc/LayerTransactionChild.h index 22d57abd4c3..eeaee444cf4 100644 --- a/gfx/layers/ipc/LayerTransactionChild.h +++ b/gfx/layers/ipc/LayerTransactionChild.h @@ -23,9 +23,10 @@ class RenderFrameChild; namespace layers { class LayerTransactionChild : public PLayerTransactionChild + , public AtomicRefCounted { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(LayerTransactionChild) + MOZ_DECLARE_REFCOUNTED_TYPENAME(LayerTransactionChild) /** * Clean this up, finishing with Send__delete__(). * @@ -42,6 +43,8 @@ protected: : mIPCOpen(false) {} ~LayerTransactionChild() { } + friend class AtomicRefCounted; + friend class detail::RefCounted; virtual PGrallocBufferChild* AllocPGrallocBufferChild(const IntSize&, diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 1793f63d136..1f3863a3f42 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -64,13 +64,12 @@ struct EffectChain; * This is primarily intended for direct texturing APIs that need to attach * shared objects (such as an EGLImage) to a gl texture. */ -class CompositorTexturePoolOGL +class CompositorTexturePoolOGL : public RefCounted { -protected: - virtual ~CompositorTexturePoolOGL() {} - public: - NS_INLINE_DECL_REFCOUNTING(CompositorTexturePoolOGL) + MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositorTexturePoolOGL) + + virtual ~CompositorTexturePoolOGL() {} virtual void Clear() = 0; diff --git a/gfx/src/FilterSupport.cpp b/gfx/src/FilterSupport.cpp index 62e2d75b56f..d4c12965f9a 100644 --- a/gfx/src/FilterSupport.cpp +++ b/gfx/src/FilterSupport.cpp @@ -230,10 +230,10 @@ namespace FilterWrappers { // Internally, this is achieved by wrapping the original FilterNode with // conversion FilterNodes. These filter nodes are cached in such a way that no // repeated or back-and-forth conversions happen. -class FilterCachedColorModels +class FilterCachedColorModels : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(FilterCachedColorModels) + MOZ_DECLARE_REFCOUNTED_TYPENAME(FilterCachedColorModels) // aFilter can be null. In that case, ForColorModel will return a non-null // completely transparent filter for all color models. FilterCachedColorModels(DrawTarget* aDT, diff --git a/hal/gonk/GonkHal.cpp b/hal/gonk/GonkHal.cpp index ea56e8646d1..92875335b42 100644 --- a/hal/gonk/GonkHal.cpp +++ b/hal/gonk/GonkHal.cpp @@ -294,11 +294,11 @@ public: } // anonymous namespace -class BatteryObserver : public IUeventObserver +class BatteryObserver : public IUeventObserver, + public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(BatteryObserver) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(BatteryObserver) BatteryObserver() :mUpdater(new BatteryUpdater()) { diff --git a/hal/gonk/GonkSwitch.cpp b/hal/gonk/GonkSwitch.cpp index 1b2f6d4ee11..38494f3c102 100644 --- a/hal/gonk/GonkSwitch.cpp +++ b/hal/gonk/GonkSwitch.cpp @@ -51,11 +51,10 @@ namespace hal_impl { * SWITCH_STATE=0 * SEQNUM=5038 */ -class SwitchHandler +class SwitchHandler : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(SwitchHandler) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(SwitchHandler) SwitchHandler(const char* aDevPath, SwitchDevice aDevice) : mDevPath(aDevPath), mState(SWITCH_STATE_UNKNOWN), @@ -231,20 +230,21 @@ private: SwitchEvent mEvent; }; -class SwitchEventObserver MOZ_FINAL : public IUeventObserver +class SwitchEventObserver : public IUeventObserver, + public RefCounted { - ~SwitchEventObserver() - { - mHandler.Clear(); - } - public: - NS_INLINE_DECL_REFCOUNTING(SwitchEventObserver) + MOZ_DECLARE_REFCOUNTED_TYPENAME(SwitchEventObserver) SwitchEventObserver() : mEnableCount(0) { Init(); } + ~SwitchEventObserver() + { + mHandler.Clear(); + } + int GetEnableCount() { return mEnableCount; diff --git a/image/src/SurfaceCache.cpp b/image/src/SurfaceCache.cpp index a27ded36698..2a8ff1dffaa 100644 --- a/image/src/SurfaceCache.cpp +++ b/image/src/SurfaceCache.cpp @@ -110,11 +110,10 @@ private: * A CachedSurface associates a surface with a key that uniquely identifies that * surface. */ -class CachedSurface +class CachedSurface : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(CachedSurface) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(CachedSurface) CachedSurface(DrawTarget* aTarget, const IntSize aTargetSize, const Cost aCost, @@ -157,11 +156,10 @@ private: * destroyed or invalidated. Since this will happen frequently, it makes sense * to make it cheap by storing the surfaces for each image separately. */ -class ImageSurfaceCache +class ImageSurfaceCache : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(ImageSurfaceCache) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(ImageSurfaceCache) typedef nsRefPtrHashtable, CachedSurface> SurfaceTable; bool IsEmpty() const { return mSurfaces.Count() == 0; } diff --git a/ipc/netd/Netd.h b/ipc/netd/Netd.h index 31d0dc03cc1..d9481b81500 100644 --- a/ipc/netd/Netd.h +++ b/ipc/netd/Netd.h @@ -5,7 +5,7 @@ #ifndef mozilla_system_netd_h__ #define mozilla_system_netd_h__ -#include "nsISupportsImpl.h" +#include "mozilla/RefPtr.h" #include "nsAutoPtr.h" #include "base/message_loop.h" #include "mozilla/FileUtils.h" @@ -26,14 +26,11 @@ struct NetdCommand size_t mSize; }; -class NetdConsumer +class NetdConsumer : public mozilla::RefCounted { -protected: - virtual ~NetdConsumer() { } - public: - NS_INLINE_DECL_REFCOUNTING(NetdConsumer) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(NetdConsumer) + virtual ~NetdConsumer() { } virtual void MessageReceived(NetdCommand* aMessage) = 0; }; @@ -42,15 +39,15 @@ class NetdWriteTask : public Task virtual void Run(); }; -class NetdClient : public MessageLoopForIO::LineWatcher +class NetdClient : public MessageLoopForIO::LineWatcher, + public RefCounted { - virtual ~NetdClient(); - public: - NS_INLINE_DECL_REFCOUNTING(NetdClient) + MOZ_DECLARE_REFCOUNTED_TYPENAME(NetdClient) typedef std::queue NetdCommandQueue; NetdClient(); + virtual ~NetdClient(); static void Start(); static void SendNetdCommandIOThread(NetdCommand* aMessage); diff --git a/ipc/unixsocket/UnixSocket.h b/ipc/unixsocket/UnixSocket.h index 7e643906fc2..46b3553803f 100644 --- a/ipc/unixsocket/UnixSocket.h +++ b/ipc/unixsocket/UnixSocket.h @@ -135,16 +135,14 @@ enum SocketConnectionStatus { SOCKET_CONNECTED = 3 }; -class UnixSocketConsumer +class UnixSocketConsumer : public AtomicRefCounted { -protected: - virtual ~UnixSocketConsumer(); - public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UnixSocketConsumer) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(UnixSocketConsumer) UnixSocketConsumer(); + virtual ~UnixSocketConsumer(); + SocketConnectionStatus GetConnectionStatus() const { MOZ_ASSERT(NS_IsMainThread()); diff --git a/layout/base/FrameLayerBuilder.h b/layout/base/FrameLayerBuilder.h index 1581557da12..e9e6ce865dd 100644 --- a/layout/base/FrameLayerBuilder.h +++ b/layout/base/FrameLayerBuilder.h @@ -46,10 +46,9 @@ enum LayerState { LAYER_SVG_EFFECTS }; -class RefCountedRegion { +class RefCountedRegion : public RefCounted { public: - NS_INLINE_DECL_REFCOUNTING(RefCountedRegion) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(RefCountedRegion) RefCountedRegion() : mIsInfinite(false) {} nsRegion mRegion; bool mIsInfinite; diff --git a/security/manager/ssl/src/SharedCertVerifier.h b/security/manager/ssl/src/SharedCertVerifier.h index 32a92a3eb68..4e7e3510b5c 100644 --- a/security/manager/ssl/src/SharedCertVerifier.h +++ b/security/manager/ssl/src/SharedCertVerifier.h @@ -11,14 +11,11 @@ namespace mozilla { namespace psm { -class SharedCertVerifier : public mozilla::psm::CertVerifier +class SharedCertVerifier : public mozilla::psm::CertVerifier, + public mozilla::AtomicRefCounted { -protected: - ~SharedCertVerifier(); - public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedCertVerifier) - + MOZ_DECLARE_REFCOUNTED_TYPENAME(SharedCertVerifier) SharedCertVerifier(implementation_config ic, #ifndef NSS_NO_LIBPKIX missing_cert_download_config ac, crl_download_config cdc, @@ -32,6 +29,7 @@ public: odc, osc, ogc) { } + ~SharedCertVerifier(); }; } } // namespace mozilla::psm diff --git a/xpcom/threads/BackgroundHangMonitor.cpp b/xpcom/threads/BackgroundHangMonitor.cpp index 694974bf541..0f380ba7ccd 100644 --- a/xpcom/threads/BackgroundHangMonitor.cpp +++ b/xpcom/threads/BackgroundHangMonitor.cpp @@ -28,7 +28,7 @@ namespace mozilla { * BackgroundHangManager is the global object that * manages all instances of BackgroundHangThread. */ -class BackgroundHangManager +class BackgroundHangManager : public AtomicRefCounted { private: // Background hang monitor thread function @@ -62,7 +62,7 @@ private: void RunMonitorThread(); public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BackgroundHangManager) + MOZ_DECLARE_REFCOUNTED_TYPENAME(BackgroundHangManager) static StaticRefPtr sInstance; // Lock for access to members of this class