Bug 935778 - Part 0.2: Spray some MOZ_DECLARE_REFCOUNTED_TYPENAME across the tree
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 20 Feb 2014 21:33:49 -0500
changeset 169803 a29b5994e73ad65f69755456dea4749eaca6de04
parent 169802 0f5f58d5d410c8d39da35cdcaa10a081a237e287
child 169804 4a83d046db8260973511456ab191d2566ee272c7
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs935778
milestone30.0a1
Bug 935778 - Part 0.2: Spray some MOZ_DECLARE_REFCOUNTED_TYPENAME across the tree
content/html/content/src/nsTextEditorState.h
content/media/webaudio/PannerNode.h
content/media/webspeech/recognition/SpeechRecognition.h
docshell/base/nsDocShell.h
gfx/2d/2D.h
gfx/2d/Filters.h
gfx/2d/MacIOSurface.h
gfx/2d/QuartzSupport.h
gfx/layers/Compositor.h
gfx/layers/Effects.h
gfx/layers/client/CompositableClient.h
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/composite/AsyncCompositionManager.h
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/TextureHost.h
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/LayerTransactionChild.h
gfx/src/FilterSupport.cpp
image/src/RasterImage.h
image/src/imgRequestProxy.h
image/src/imgStatusTracker.h
ipc/glue/MessageLink.h
mfbt/RefPtr.h
mfbt/WeakPtr.h
netwerk/sctp/datachannel/DataChannel.h
uriloader/prefetch/nsOfflineCacheUpdate.h
xpcom/base/nsMessageLoop.cpp
--- a/content/html/content/src/nsTextEditorState.h
+++ b/content/html/content/src/nsTextEditorState.h
@@ -115,16 +115,17 @@ class nsITextControlElement;
  *     transferred to the mValue member variable, and will be managed there until a new
  *     frame is bound to the text editor state object.
  */
 
 class RestoreSelectionState;
 
 class nsTextEditorState : public mozilla::SupportsWeakPtr<nsTextEditorState> {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(nsTextEditorState)
   explicit nsTextEditorState(nsITextControlElement* aOwningElement);
   ~nsTextEditorState();
 
   void Traverse(nsCycleCollectionTraversalCallback& cb);
   void Unlink();
 
   nsIEditor* GetEditor();
   nsISelectionController* GetSelectionController() const;
--- a/content/media/webaudio/PannerNode.h
+++ b/content/media/webaudio/PannerNode.h
@@ -20,16 +20,17 @@ namespace dom {
 
 class AudioContext;
 class AudioBufferSourceNode;
 
 class PannerNode : public AudioNode,
                    public SupportsWeakPtr<PannerNode>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(PannerNode)
   explicit PannerNode(AudioContext* aContext);
   virtual ~PannerNode();
 
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   virtual void DestroyMediaStream() MOZ_OVERRIDE;
--- a/content/media/webspeech/recognition/SpeechRecognition.h
+++ b/content/media/webspeech/recognition/SpeechRecognition.h
@@ -53,16 +53,17 @@ PRLogModuleInfo* GetSpeechRecognitionLog
 #define SR_LOG(...)
 #endif
 
 class SpeechRecognition MOZ_FINAL : public nsDOMEventTargetHelper,
                                     public nsIObserver,
                                     public SupportsWeakPtr<SpeechRecognition>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(SpeechRecognition)
   SpeechRecognition(nsPIDOMWindow* aOwnerWindow);
   virtual ~SpeechRecognition() {};
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIOBSERVER
 
   nsISupports* GetParentObject() const;
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -138,16 +138,17 @@ class nsDocShell : public nsDocLoader,
                    public nsILinkHandler,
                    public nsIClipboardCommands,
                    public nsIDOMStorageManager,
                    public mozilla::SupportsWeakPtr<nsDocShell>
 {
     friend class nsDSURIContentListener;
 
 public:
+    MOZ_DECLARE_REFCOUNTED_TYPENAME(nsDocShell)
     // Object Management
     nsDocShell();
 
     NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
 
     virtual nsresult Init();
 
     NS_DECL_ISUPPORTS_INHERITED
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -159,16 +159,17 @@ struct DrawSurfaceOptions {
 /*
  * This class is used to store gradient stops, it can only be used with a
  * matching DrawTarget. Not adhering to this condition will make a draw call
  * fail.
  */
 class GradientStops : public RefCounted<GradientStops>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(GradientStops)
   virtual ~GradientStops() {}
 
   virtual BackendType GetBackendType() const = 0;
 
 protected:
   GradientStops() {}
 };
 
@@ -311,16 +312,17 @@ public:
 /*
  * This is the base class for source surfaces. These objects are surfaces
  * which may be used as a source in a SurfacePattern or a DrawSurface call.
  * They cannot be drawn to directly.
  */
 class SourceSurface : public RefCounted<SourceSurface>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(SourceSurface)
   virtual ~SourceSurface() {}
 
   virtual SurfaceType GetType() const = 0;
   virtual IntSize GetSize() const = 0;
   virtual SurfaceFormat GetFormat() const = 0;
 
   /* This returns false if some event has made this source surface invalid for
    * usage with current DrawTargets. For example in the case of Direct2D this
@@ -391,16 +393,17 @@ public:
 
   DebugOnly<bool> mIsMapped;
 };
 
 /* This is an abstract object that accepts path segments. */
 class PathSink : public RefCounted<PathSink>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(PathSink)
   virtual ~PathSink() {}
 
   /* Move the current point in the path, any figure currently being drawn will
    * be considered closed during fill operations, however when stroking the
    * closing line segment will not be drawn.
    */
   virtual void MoveTo(const Point &aPoint) = 0;
   /* Add a linesegment to the current figure */
@@ -429,16 +432,17 @@ class PathBuilder;
 class FlattenedPath;
 
 /* The path class is used to create (sets of) figures of any shape that can be
  * filled or stroked to a DrawTarget
  */
 class Path : public RefCounted<Path>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(Path)
   virtual ~Path();
   
   virtual BackendType GetBackendType() const = 0;
 
   /* This returns a PathBuilder object that contains a copy of the contents of
    * this path and is still writable.
    */
   virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
@@ -528,16 +532,17 @@ struct GlyphBuffer
 
 /* This class is an abstraction of a backend/platform specific font object
  * at a particular size. It is passed into text drawing calls to describe
  * the font used for the drawing call.
  */
 class ScaledFont : public RefCounted<ScaledFont>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(ScaledFont)
   virtual ~ScaledFont() {}
 
   typedef void (*FontFileDataOutput)(const uint8_t *aData, uint32_t aLength, uint32_t aIndex, Float aGlyphSize, void *aBaton);
 
   virtual FontType GetType() const = 0;
 
   /* This allows getting a path that describes the outline of a set of glyphs.
    * A target is passed in so that the guarantee is made the returned path
@@ -586,32 +591,34 @@ struct FontOptions
  * parameters to the glyph drawing functions. This is an empty wrapper class
  * merely used to allow holding on to and passing around platform specific
  * parameters. This is because different platforms have unique rendering
  * parameters.
  */
 class GlyphRenderingOptions : public RefCounted<GlyphRenderingOptions>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(GlyphRenderingOptions)
   virtual ~GlyphRenderingOptions() {}
 
   virtual FontType GetType() const = 0;
 
 protected:
   GlyphRenderingOptions() {}
 };
 
 /* This is the main class used for all the drawing. It is created through the
  * factory and accepts drawing commands. The results of drawing to a target
  * may be used either through a Snapshot or by flushing the target and directly
  * accessing the backing store a DrawTarget was created with.
  */
 class DrawTarget : public RefCounted<DrawTarget>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(DrawTarget)
   DrawTarget() : mTransformDirty(false), mPermitSubpixelAA(false) {}
   virtual ~DrawTarget() {}
 
   virtual BackendType GetType() const = 0;
   /**
    * Returns a SourceSurface which is a snapshot of the current contents of the DrawTarget.
    * Multiple calls to Snapshot() without any drawing operations in between will
    * normally return the same SourceSurface object.
@@ -984,16 +991,17 @@ protected:
   bool mPermitSubpixelAA : 1;
 
   SurfaceFormat mFormat;
 };
 
 class DrawEventRecorder : public RefCounted<DrawEventRecorder>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(DrawEventRecorder)
   virtual ~DrawEventRecorder() { }
 };
 
 class GFX2D_API Factory
 {
 public:
   static bool HasSSE2();
 
--- a/gfx/2d/Filters.h
+++ b/gfx/2d/Filters.h
@@ -461,16 +461,17 @@ enum PremultiplyInputs
 enum UnpremultiplyInputs
 {
   IN_UNPREMULTIPLY_IN = 0
 };
 
 class FilterNode : public RefCounted<FilterNode>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(FilterMode)
   virtual ~FilterNode() {}
 
   virtual FilterBackend GetBackendType() = 0;
 
   virtual void SetInput(uint32_t aIndex, SourceSurface *aSurface) { MOZ_CRASH(); }
   virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) { MOZ_CRASH(); }
 
   virtual void SetAttribute(uint32_t aIndex, bool) { MOZ_CRASH(); }
--- a/gfx/2d/MacIOSurface.h
+++ b/gfx/2d/MacIOSurface.h
@@ -57,16 +57,17 @@ enum CGContextType {
   CG_CONTEXT_TYPE_BITMAP = 4,
   CG_CONTEXT_TYPE_IOSURFACE = 8
 };
 
 CGContextType GetContextType(CGContextRef ref);
 
 class MacIOSurface : public mozilla::RefCounted<MacIOSurface> {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(MacIOSurface)
   typedef mozilla::gfx::SourceSurface SourceSurface;
 
   static mozilla::TemporaryRef<MacIOSurface> CreateIOSurface(int aWidth, int aHeight,
                                                              double aContentsScaleFactor = 1.0,
                                                              bool aHasAlpha = true);
   static void ReleaseIOSurface(MacIOSurface *aIOSurface);
   static mozilla::TemporaryRef<MacIOSurface> LookupSurface(IOSurfaceID aSurfaceID,
                                                            double aContentsScaleFactor = 1.0,
--- a/gfx/2d/QuartzSupport.h
+++ b/gfx/2d/QuartzSupport.h
@@ -22,16 +22,17 @@ CGColorSpaceRef CreateSystemColorSpace()
 // Manages a CARenderer
 struct _CGLPBufferObject;
 struct _CGLContextObject;
 
 enum AllowOfflineRendererEnum { ALLOW_OFFLINE_RENDERER, DISALLOW_OFFLINE_RENDERER };
 
 class nsCARenderer : public mozilla::RefCounted<nsCARenderer> {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(nsCARenderer)
   nsCARenderer() : mCARenderer(nullptr), mWrapperCALayer(nullptr), mFBOTexture(0),
                    mOpenGLContext(nullptr), mCGImage(nullptr), mCGData(nullptr),
                    mIOSurface(nullptr), mFBO(0), mIOTexture(0),
                    mUnsupportedWidth(UINT32_MAX), mUnsupportedHeight(UINT32_MAX),
                    mAllowOfflineRenderer(DISALLOW_OFFLINE_RENDERER),
                    mContentsScaleFactor(1.0) {}
   ~nsCARenderer();
   // aWidth and aHeight are in "display pixels".  A "display pixel" is the
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -174,16 +174,17 @@ enum SurfaceInitMode
  * by CreateRenderTarget or CreateRenderTargetFromSource.
  *
  * The target and viewport methods can be called before any DrawQuad call and
  * affect any subsequent DrawQuad calls.
  */
 class Compositor : public RefCounted<Compositor>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(Compositor)
   Compositor(PCompositorParent* aParent = nullptr)
     : mCompositorID(0)
     , mDiagnosticTypes(DIAGNOSTIC_NONE)
     , mParent(aParent)
   {
     MOZ_COUNT_CTOR(Compositor);
   }
   virtual ~Compositor()
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -34,16 +34,17 @@ namespace layers {
  * During the rendering process, an effect chain is created by the layer being
  * rendered and the primary effect is added by the compositable host. Secondary
  * effects may be added by the layer or compositable. The effect chain is passed
  * to the compositor by the compositable host as a parameter to DrawQuad.
  */
 
 struct Effect : public RefCounted<Effect>
 {
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(Effect)
   Effect(EffectTypes aType) : mType(aType) {}
 
   EffectTypes mType;
 
   virtual ~Effect() {}
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix) =0;
 };
 
--- a/gfx/layers/client/CompositableClient.h
+++ b/gfx/layers/client/CompositableClient.h
@@ -67,16 +67,17 @@ class TextureClientData;
  * Subclasses: Thebes layers use ContentClients, ImageLayers use ImageClients,
  * Canvas layers use CanvasClients (but ImageHosts). We have a different subclass
  * 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 : public AtomicRefCounted<CompositableClient>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableClient)
   CompositableClient(CompositableForwarder* aForwarder);
 
   virtual ~CompositableClient();
 
   virtual TextureInfo GetTextureInfo() const = 0;
 
   LayersBackend GetCompositorBackendType() const;
 
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -50,16 +50,17 @@ namespace layers {
  * During the deallocation phase, a TextureChild may hold its recently destroyed
  * TextureClient's data until the compositor side confirmed that it is safe to
  * deallocte or recycle the it.
  */
 class TextureChild : public PTextureChild
                    , public AtomicRefCounted<TextureChild>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureChild)
   TextureChild()
   : mForwarder(nullptr)
   , mTextureData(nullptr)
   , mTextureClient(nullptr)
   , mIPCOpen(false)
   {
     MOZ_COUNT_CTOR(TextureChild);
   }
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -505,16 +505,17 @@ struct TextureClientAutoUnlock
  * same semantics.
  *
  * Ownership of the surface descriptor depends on how the DeprecatedTextureClient/Host is
  * used by the CompositableClient/Host.
  */
 class DeprecatedTextureClient : public RefCounted<DeprecatedTextureClient>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(DeprecatedTextureClient)
   typedef gl::SharedTextureHandle SharedTextureHandle;
   typedef gl::GLContext GLContext;
   typedef gl::TextureImage TextureImage;
 
   virtual ~DeprecatedTextureClient();
 
   /* This will return an identifier that can be sent accross a process or
    * thread boundary and used to construct a DeprecatedTextureHost object
--- a/gfx/layers/composite/AsyncCompositionManager.h
+++ b/gfx/layers/composite/AsyncCompositionManager.h
@@ -61,16 +61,17 @@ struct ViewTransform {
  * usually dealt with by dom or layout when main thread rendering, but which can
  * 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 : public RefCounted<AsyncCompositionManager>
 {
   friend class AutoResolveRefLayers;
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(AsyncCompositionManager)
   AsyncCompositionManager(LayerManagerComposite* aManager)
     : mLayerManager(aManager)
     , mIsFirstPaint(false)
     , mLayersUpdated(false)
     , mReadyForCompose(true)
   {
     MOZ_COUNT_CTOR(AsyncCompositionManager);
   }
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -55,16 +55,17 @@ class TiledLayerComposer;
 struct EffectChain;
 
 /**
  * A base class for doing CompositableHost and platform dependent task on TextureHost.
  */
 class CompositableBackendSpecificData : public RefCounted<CompositableBackendSpecificData>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableBackendSpecificData)
   CompositableBackendSpecificData()
   {
     MOZ_COUNT_CTOR(CompositableBackendSpecificData);
   }
   virtual ~CompositableBackendSpecificData()
   {
     MOZ_COUNT_DTOR(CompositableBackendSpecificData);
   }
@@ -84,16 +85,17 @@ public:
  *
  * Composite is called by the owning layer when it is composited. CompositableHost
  * will use its TextureHost(s) and call Compositor::DrawQuad to do the actual
  * rendering.
  */
 class CompositableHost : public RefCounted<CompositableHost>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableHost)
   CompositableHost(const TextureInfo& aTextureInfo);
 
   virtual ~CompositableHost();
 
   static TemporaryRef<CompositableHost> Create(const TextureInfo& aTextureInfo);
 
   virtual CompositableType GetType() = 0;
 
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -76,16 +76,17 @@ public:
  * interfaces (TextureSourceOGL, etc.), and TextureSource mostly provide
  * access to these interfaces.
  *
  * This class is used on the compositor side.
  */
 class TextureSource : public RefCounted<TextureSource>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureSource)
   TextureSource();
   virtual ~TextureSource();
 
   /**
    * Return the size of the texture in texels.
    * If this is a tile iterator, GetSize must return the size of the current tile.
    */
   virtual gfx::IntSize GetSize() const = 0;
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -71,16 +71,17 @@ bool ReleaseOwnedSurfaceDescriptor(const
  * Most of the methods here correspond to methods that are implemented by IPDL
  * actors without a common polymorphic interface.
  * These methods should be only called in the ipdl implementor's thread, unless
  * specified otherwise in the implementing class.
  */
 class ISurfaceAllocator : public AtomicRefCounted<ISurfaceAllocator>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(ISurfaceAllocator)
   ISurfaceAllocator() {}
 
   /**
    * Allocate shared memory that can be accessed by only one process at a time.
    * Ownership of this memory is passed when the memory is sent in an IPDL
    * message.
    */
   virtual bool AllocShmem(size_t aSize,
--- a/gfx/layers/ipc/LayerTransactionChild.h
+++ b/gfx/layers/ipc/LayerTransactionChild.h
@@ -21,16 +21,17 @@ class RenderFrameChild;
 }
 
 namespace layers {
 
 class LayerTransactionChild : public PLayerTransactionChild
                             , public AtomicRefCounted<LayerTransactionChild>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(LayerTransactionChild)
   /**
    * Clean this up, finishing with Send__delete__().
    *
    * It is expected (checked with an assert) that all shadow layers
    * created by this have already been destroyed and
    * Send__delete__()d by the time this method is called.
    */
   void Destroy();
--- a/gfx/src/FilterSupport.cpp
+++ b/gfx/src/FilterSupport.cpp
@@ -228,16 +228,17 @@ namespace FilterWrappers {
 // ->ForColorModel(colorModel) in order to get a FilterNode which outputs to
 // the specified colorModel.
 // 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 : public RefCounted<FilterCachedColorModels>
 {
 public:
+  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,
                           FilterNode* aFilter,
                           ColorModel aOriginalColorModel);
 
   // Get a FilterNode for the specified color model, guaranteed to be non-null.
   TemporaryRef<FilterNode> ForColorModel(ColorModel aColorModel);
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -139,16 +139,17 @@ class FrameAnimator;
 class RasterImage : public ImageResource
                   , public nsIProperties
                   , public SupportsWeakPtr<RasterImage>
 #ifdef DEBUG
                   , public imgIContainerDebug
 #endif
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(RasterImage)
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIPROPERTIES
   NS_DECL_IMGICONTAINER
 #ifdef DEBUG
   NS_DECL_IMGICONTAINERDEBUG
 #endif
 
   // (no public constructor - use ImageFactory)
--- a/image/src/imgRequestProxy.h
+++ b/image/src/imgRequestProxy.h
@@ -43,16 +43,17 @@ class ImageURL;
 
 class imgRequestProxy : public imgIRequest,
                         public nsISupportsPriority,
                         public nsISecurityInfoProvider,
                         public nsITimedChannel,
                         public mozilla::SupportsWeakPtr<imgRequestProxy>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(imgRequestProxy)
   typedef mozilla::image::ImageURL ImageURL;
   NS_DECL_ISUPPORTS
   NS_DECL_IMGIREQUEST
   NS_DECL_NSIREQUEST
   NS_DECL_NSISUPPORTSPRIORITY
   NS_DECL_NSISECURITYINFOPROVIDER
   // nsITimedChannel declared below
 
--- a/image/src/imgStatusTracker.h
+++ b/image/src/imgStatusTracker.h
@@ -104,16 +104,17 @@ enum {
  * the Notify() method on this class with the relevant proxy as its argument,
  * and the notifications will be replayed to the proxy asynchronously.
  */
 
 
 class imgStatusTracker : public mozilla::SupportsWeakPtr<imgStatusTracker>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(imgStatusTracker)
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(imgStatusTracker)
 
   // aImage is the image that this status tracker will pass to the
   // imgRequestProxys in SyncNotify() and EmulateRequestFinished(), and must be
   // alive as long as this instance is, because we hold a weak reference to it.
   imgStatusTracker(mozilla::image::Image* aImage);
   virtual ~imgStatusTracker();
 
--- a/ipc/glue/MessageLink.h
+++ b/ipc/glue/MessageLink.h
@@ -55,16 +55,17 @@ enum RacyInterruptPolicy {
     RIPParentWins
 };
 
 class MessageListener
   : protected HasResultCodes,
     public mozilla::SupportsWeakPtr<MessageListener>
 {
   public:
+    MOZ_DECLARE_REFCOUNTED_TYPENAME(MessageListener)
     typedef IPC::Message Message;
 
     virtual ~MessageListener() { }
 
     virtual void OnChannelClose() = 0;
     virtual void OnChannelError() = 0;
     virtual Result OnMessageReceived(const Message& aMessage) = 0;
     virtual Result OnMessageReceived(const Message& aMessage, Message *& aReply) = 0;
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -37,16 +37,20 @@ template<typename T> OutParamRef<T> byRe
  *
  * Live RefCounted<T> have refcount > 0.  The lifetime (refcounts) of
  * live RefCounted<T> are controlled by RefPtr<T> and
  * RefPtr<super/subclass of T>.  Upon a transition from refcounted==1
  * to 0, the RefCounted<T> "dies" and is destroyed.  The "destroyed"
  * state is represented in DEBUG builds by refcount==0xffffdead.  This
  * state distinguishes use-before-ref (refcount==0) from
  * use-after-destroy (refcount==0xffffdead).
+ *
+ * Note that when deriving from RefCounted or AtomicRefCounted, you
+ * should add MOZ_DECLARE_REFCOUNTED_TYPENAME(ClassName) to the public
+ * section of your class, where ClassName is the name of your class.
  */
 namespace detail {
 #ifdef DEBUG
 static const int DEAD = 0xffffdead;
 #endif
 
 // This is used WeakPtr.h as well as this file.
 enum RefCountAtomicity
@@ -91,16 +95,19 @@ class RefCounted
       MOZ_ASSERT(refCnt > 0);
       return refCnt == 1;
     }
 
   private:
     mutable typename Conditional<Atomicity == AtomicRefCount, Atomic<int>, int>::Type refCnt;
 };
 
+#define MOZ_DECLARE_REFCOUNTED_TYPENAME(T) \
+  const char* typeName() const { return #T; }
+
 }
 
 template<typename T>
 class RefCounted : public detail::RefCounted<T, detail::NonAtomicRefCount>
 {
   public:
     ~RefCounted() {
       static_assert(IsBaseOf<RefCounted, T>::value,
@@ -296,16 +303,17 @@ byRef(RefPtr<T>& ptr)
 // Command line that builds these tests
 //
 //   cp RefPtr.h test.cc && g++ -g -Wall -pedantic -DDEBUG -o test test.cc && ./test
 
 using namespace mozilla;
 
 struct Foo : public RefCounted<Foo>
 {
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(Foo)
   Foo() : dead(false) { }
   ~Foo() {
     MOZ_ASSERT(!dead);
     dead = true;
     numDestroyed++;
   }
 
   bool dead;
--- a/mfbt/WeakPtr.h
+++ b/mfbt/WeakPtr.h
@@ -9,26 +9,31 @@
 /**
  * SupportsWeakPtr lets you have a pointer to an object 'Foo' without affecting
  * its lifetime. It works by creating a single shared reference counted object
  * (WeakReference) that each WeakPtr will access 'Foo' through. This lets 'Foo'
  * clear the pointer in the WeakReference without having to know about all of
  * the WeakPtrs to it and allows the WeakReference to live beyond the lifetime
  * of 'Foo'.
  *
+ * Note that when deriving from SupportsWeakPtr you should add
+ * MOZ_DECLARE_REFCOUNTED_TYPENAME(ClassName) to the public section of your
+ * class, where ClassName is the name of your class.
+ *
  * The overhead of WeakPtr is that accesses to 'Foo' becomes an additional
  * dereference, and an additional heap allocated pointer sized object shared
  * between all of the WeakPtrs.
  *
  * Example of usage:
  *
  *   // To have a class C support weak pointers, inherit from SupportsWeakPtr<C>.
  *   class C : public SupportsWeakPtr<C>
  *   {
  *    public:
+ *      MOZ_DECLARE_REFCOUNTED_TYPENAME(C)
  *      int num;
  *      void act();
  *   };
  *
  *   C* ptr =  new C();
  *
  *   // Get weak pointers to ptr. The first time asWeakPtr is called
  *   // a reference counted WeakReference object is created that
--- a/netwerk/sctp/datachannel/DataChannel.h
+++ b/netwerk/sctp/datachannel/DataChannel.h
@@ -100,16 +100,17 @@ class DataChannelConnection: public nsIT
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
 
   class DataConnectionListener : public SupportsWeakPtr<DataConnectionListener>
   {
   public:
+    MOZ_DECLARE_REFCOUNTED_TYPENAME(DataChannelConnection::DataConnectionListener)
     virtual ~DataConnectionListener() {}
 
     // Called when a the connection is open
     virtual void NotifyConnection() = 0;
 
     // Called when a the connection is lost/closed
     virtual void NotifyClosedConnection() = 0;
 
--- a/uriloader/prefetch/nsOfflineCacheUpdate.h
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.h
@@ -184,26 +184,28 @@ private:
     nsCString mManifestHashValue;
     nsCString mOldManifestHashValue;
 };
 
 class nsOfflineCacheUpdateOwner
   : public mozilla::SupportsWeakPtr<nsOfflineCacheUpdateOwner>
 {
 public:
+    MOZ_DECLARE_REFCOUNTED_TYPENAME(nsOfflineCacheUpdateOwner)
     virtual ~nsOfflineCacheUpdateOwner() {}
     virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) = 0;
 };
 
 class nsOfflineCacheUpdate MOZ_FINAL : public nsIOfflineCacheUpdate
                                      , public nsIOfflineCacheUpdateObserver
                                      , public nsIRunnable
                                      , public nsOfflineCacheUpdateOwner
 {
 public:
+    MOZ_DECLARE_REFCOUNTED_TYPENAME(nsOfflineCacheUpdate)
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOFFLINECACHEUPDATE
     NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
     NS_DECL_NSIRUNNABLE
 
     nsOfflineCacheUpdate();
     ~nsOfflineCacheUpdate();
 
--- a/xpcom/base/nsMessageLoop.cpp
+++ b/xpcom/base/nsMessageLoop.cpp
@@ -26,16 +26,17 @@ namespace {
  * Note that the MessageLoop owns this object and will delete it after it calls
  * Run().  Tread lightly.
  */
 class MessageLoopIdleTask
   : public Task
   , public SupportsWeakPtr<MessageLoopIdleTask>
 {
 public:
+  MOZ_DECLARE_REFCOUNTED_TYPENAME(MessageLoopIdleTask)
   MessageLoopIdleTask(nsIRunnable* aTask, uint32_t aEnsureRunsAfterMS);
   virtual ~MessageLoopIdleTask() {}
   virtual void Run();
 
 private:
   nsresult Init(uint32_t aEnsureRunsAfterMS);
 
   nsCOMPtr<nsIRunnable> mTask;