Bug 984786 part 4: Give NS_INLINE_DECL_*REFCOUNTING classes private/protected destructor & MOZ_FINAL annotation where appropriate, in /dom. r=smaug
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 02 Apr 2014 09:21:03 -0700
changeset 176650 ed66b2c115a5142d50c5788d6c2bafd2df24c95e
parent 176649 e5572fc5c75471f801c6623cd222b2eaab3a5cd0
child 176651 91a6fdfb2ad13dc0ffd378c5444764e7c879ea86
push id41825
push userdholbert@mozilla.com
push dateWed, 02 Apr 2014 16:21:55 +0000
treeherdermozilla-inbound@793324f7c684 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs984786
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 984786 part 4: Give NS_INLINE_DECL_*REFCOUNTING classes private/protected destructor & MOZ_FINAL annotation where appropriate, in /dom. r=smaug
dom/base/nsDOMNavigationTiming.h
dom/camera/CameraControlListener.h
dom/camera/DOMCameraControl.h
dom/events/TextComposition.h
dom/file/MetadataHelper.h
dom/filesystem/FileSystemRequestParent.h
dom/indexedDB/DatabaseInfo.h
dom/indexedDB/FileManager.h
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/quota/QuotaObject.h
dom/smil/nsSMILInstanceTime.h
dom/src/storage/DOMStorageCache.h
dom/workers/FileReaderSync.h
dom/workers/URL.cpp
dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
dom/xslt/xslt/txStylesheet.h
dom/xslt/xslt/txStylesheetCompiler.h
--- a/dom/base/nsDOMNavigationTiming.h
+++ b/dom/base/nsDOMNavigationTiming.h
@@ -22,17 +22,17 @@ namespace PerformanceNavigation {
 static const nsDOMPerformanceNavigationType TYPE_NAVIGATE = 0;
 static const nsDOMPerformanceNavigationType TYPE_RELOAD = 1;
 static const nsDOMPerformanceNavigationType TYPE_BACK_FORWARD = 2;
 static const nsDOMPerformanceNavigationType TYPE_RESERVED = 255;
 }
 }
 }
 
-class nsDOMNavigationTiming
+class nsDOMNavigationTiming MOZ_FINAL
 {
 public:
   nsDOMNavigationTiming();
 
   NS_INLINE_DECL_REFCOUNTING(nsDOMNavigationTiming)
 
   nsDOMPerformanceNavigationType GetType() const {
     return mNavigationType;
--- a/dom/camera/CameraControlListener.h
+++ b/dom/camera/CameraControlListener.h
@@ -17,21 +17,24 @@ namespace layers {
 class CameraControlListener
 {
 public:
   CameraControlListener()
   {
     MOZ_COUNT_CTOR(CameraControlListener);
   }
 
+protected:
+  // Protected destructor, to discourage deletion outside of Release():
   virtual ~CameraControlListener()
   {
     MOZ_COUNT_DTOR(CameraControlListener);
   }
 
+public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CameraControlListener);
 
   enum HardwareState
   {
     kHardwareOpen,
     kHardwareClosed
   };
   virtual void OnHardwareStateChange(HardwareState aState) { }
--- a/dom/camera/DOMCameraControl.h
+++ b/dom/camera/DOMCameraControl.h
@@ -116,29 +116,30 @@ public:
                        const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError,
                        ErrorResult& aRv);
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
 protected:
   virtual ~nsDOMCameraControl();
 
-  class DOMCameraConfiguration : public dom::CameraConfiguration
+  class DOMCameraConfiguration MOZ_FINAL : public dom::CameraConfiguration
   {
   public:
     NS_INLINE_DECL_REFCOUNTING(DOMCameraConfiguration)
 
     DOMCameraConfiguration();
     DOMCameraConfiguration(const dom::CameraConfiguration& aConfiguration);
 
     // Additional configuration options that aren't exposed to the DOM
     uint32_t mMaxFocusAreas;
     uint32_t mMaxMeteringAreas;
 
-  protected:
+  private:
+    // Private destructor, to discourage deletion outside of Release():
     ~DOMCameraConfiguration();
   };
 
   friend class DOMCameraControlListener;
   friend class mozilla::StartRecordingHelper;
 
   void OnCreatedFileDescriptor(bool aSucceeded);
 
--- a/dom/events/TextComposition.h
+++ b/dom/events/TextComposition.h
@@ -37,21 +37,16 @@ class TextComposition MOZ_FINAL
 
   NS_INLINE_DECL_REFCOUNTING(TextComposition)
 
 public:
   TextComposition(nsPresContext* aPresContext,
                   nsINode* aNode,
                   WidgetGUIEvent* aEvent);
 
-  ~TextComposition()
-  {
-    // WARNING: mPresContext may be destroying, so, be careful if you touch it.
-  }
-
   bool Destroyed() const { return !mPresContext; }
   nsPresContext* GetPresContext() const { return mPresContext; }
   nsINode* GetEventTargetNode() const { return mNode; }
   // The latest CompositionEvent.data value except compositionstart event.
   // This value is modified at dispatching compositionupdate.
   const nsString& LastData() const { return mLastData; }
   // The composition string which is already handled by the focused editor.
   // I.e., this value must be same as the composition string on the focused
@@ -139,16 +134,22 @@ public:
 
   private:
     nsRefPtr<TextComposition> mComposition;
     TextEventHandlingMarker();
     TextEventHandlingMarker(const TextEventHandlingMarker& aOther);
   };
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~TextComposition()
+  {
+    // WARNING: mPresContext may be destroying, so, be careful if you touch it.
+  }
+
   // This class holds nsPresContext weak.  This instance shouldn't block
   // destroying it.  When the presContext is being destroyed, it's notified to
   // IMEStateManager::OnDestroyPresContext(), and then, it destroy
   // this instance.
   nsPresContext* mPresContext;
   nsCOMPtr<nsINode> mNode;
 
   // This is the clause and caret range information which is managed by
--- a/dom/file/MetadataHelper.h
+++ b/dom/file/MetadataHelper.h
@@ -16,17 +16,17 @@
 #include "FileHelper.h"
 
 class nsIFileStream;
 
 BEGIN_FILE_NAMESPACE
 
 class MetadataHelper;
 
-class MetadataParameters
+class MetadataParameters MOZ_FINAL
 {
   friend class MetadataHelper;
 
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MetadataParameters)
 
   MetadataParameters(bool aSizeRequested, bool aLastModifiedRequested)
     : mSizeRequested(aSizeRequested)
@@ -60,16 +60,21 @@ public:
 
   int64_t
   LastModified() const
   {
     return mLastModified;
   }
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~MetadataParameters()
+  {
+  }
+
   uint64_t mSize;
   int64_t mLastModified;
   bool mSizeRequested;
   bool mLastModifiedRequested;
 };
 
 class MetadataHelper : public FileHelper
 {
--- a/dom/filesystem/FileSystemRequestParent.h
+++ b/dom/filesystem/FileSystemRequestParent.h
@@ -11,37 +11,39 @@
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 
 namespace mozilla {
 namespace dom {
 
 class FileSystemBase;
 
-class FileSystemRequestParent
+class FileSystemRequestParent MOZ_FINAL
   : public PFileSystemRequestParent
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemRequestParent)
 public:
   FileSystemRequestParent();
 
-  virtual
-  ~FileSystemRequestParent();
-
   bool
   IsRunning()
   {
     return state() == PFileSystemRequest::__Start;
   }
 
   bool
   Dispatch(ContentParent* aParent, const FileSystemParams& aParams);
 
   virtual void
   ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
+
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  virtual
+  ~FileSystemRequestParent();
+
   nsRefPtr<FileSystemBase> mFileSystem;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_FileSystemRequestParent_h
--- a/dom/indexedDB/DatabaseInfo.h
+++ b/dom/indexedDB/DatabaseInfo.h
@@ -49,24 +49,27 @@ struct DatabaseInfoGuts
   nsCString group;
   nsCString origin;
   uint64_t version;
   PersistenceType persistenceType;
   int64_t nextObjectStoreId;
   int64_t nextIndexId;
 };
 
-struct DatabaseInfo : public DatabaseInfoGuts
+struct DatabaseInfo MOZ_FINAL : public DatabaseInfoGuts
 {
   DatabaseInfo()
   : cloned(false)
   { }
 
+private:
+  // Private destructor, to discourage deletion outside of Release():
   ~DatabaseInfo();
 
+public:
   static bool Get(const nsACString& aId,
                   DatabaseInfo** aInfo);
 
   static bool Put(DatabaseInfo* aInfo);
 
   static void Remove(const nsACString& aId);
 
   bool GetObjectStoreNames(nsTArray<nsString>& aNames);
@@ -137,28 +140,29 @@ struct ObjectStoreInfoGuts
   KeyPath keyPath;
   bool autoIncrement;
 
   // Main-thread only members. This must *not* be touched on the database
   // thread.
   nsTArray<IndexInfo> indexes;
 };
 
-struct ObjectStoreInfo : public ObjectStoreInfoGuts
+struct ObjectStoreInfo MOZ_FINAL : public ObjectStoreInfoGuts
 {
 #ifdef NS_BUILD_REFCNT_LOGGING
   ObjectStoreInfo();
 #else
   ObjectStoreInfo()
   : nextAutoIncrementId(0), comittedAutoIncrementId(0) { }
 #endif
 
   ObjectStoreInfo(ObjectStoreInfo& aOther);
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
 #ifdef NS_BUILD_REFCNT_LOGGING
   ~ObjectStoreInfo();
 #else
   ~ObjectStoreInfo() {}
 #endif
 public:
 
   // Database-thread members. After the ObjectStoreInfo has been initialized,
--- a/dom/indexedDB/FileManager.h
+++ b/dom/indexedDB/FileManager.h
@@ -17,35 +17,32 @@
 #include "nsDataHashtable.h"
 
 class mozIStorageConnection;
 
 BEGIN_INDEXEDDB_NAMESPACE
 
 class FileInfo;
 
-class FileManager
+class FileManager MOZ_FINAL
 {
   friend class FileInfo;
 
   typedef mozilla::dom::quota::PersistenceType PersistenceType;
   typedef mozilla::dom::quota::StoragePrivilege StoragePrivilege;
 
 public:
   FileManager(PersistenceType aPersistenceType, const nsACString& aGroup,
               const nsACString& aOrigin, StoragePrivilege aPrivilege,
               const nsAString& aDatabaseName)
   : mPersistenceType(aPersistenceType), mGroup(aGroup), mOrigin(aOrigin),
     mPrivilege(aPrivilege), mDatabaseName(aDatabaseName), mLastFileId(0),
     mInvalidated(false)
   { }
 
-  ~FileManager()
-  { }
-
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileManager)
 
   PersistenceType Type()
   {
     return mPersistenceType;
   }
 
   const nsACString& Group() const
@@ -95,16 +92,21 @@ public:
                                 nsIFile* aDatabaseFile,
                                 PersistenceType aPersistenceType,
                                 const nsACString& aGroup,
                                 const nsACString& aOrigin);
 
   static nsresult GetUsage(nsIFile* aDirectory, uint64_t* aUsage);
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~FileManager()
+  {
+  }
+
   PersistenceType mPersistenceType;
   nsCString mGroup;
   nsCString mOrigin;
   StoragePrivilege mPrivilege;
   nsString mDatabaseName;
 
   nsString mDirectoryPath;
   nsString mJournalDirectoryPath;
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -90,28 +90,24 @@ static bool EnsureGLContext()
     gfxIntSize dummySize(16, 16);
     sPluginContext = GLContextProvider::CreateOffscreen(dummySize,
                                                         GLContext::SurfaceCaps::Any());
   }
 
   return sPluginContext != nullptr;
 }
 
-class SharedPluginTexture {
+class SharedPluginTexture MOZ_FINAL {
 public:
   NS_INLINE_DECL_REFCOUNTING(SharedPluginTexture)
 
   SharedPluginTexture() : mLock("SharedPluginTexture.mLock")
   {
   }
 
-  ~SharedPluginTexture()
-  {
-  }
-
   nsNPAPIPluginInstance::TextureInfo Lock()
   {
     if (!EnsureGLContext()) {
       mTextureInfo.mTexture = 0;
       return mTextureInfo;
     }
 
     if (!mTextureInfo.mTexture && sPluginContext->MakeCurrent()) {
@@ -148,16 +144,21 @@ public:
     // ensures that we create a new one in Lock()
     sPluginContext->fDeleteTextures(1, &mTextureInfo.mTexture);
     mTextureInfo.mTexture = 0;
     
     return handle;
   }
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~SharedPluginTexture()
+  {
+  }
+
   nsNPAPIPluginInstance::TextureInfo mTextureInfo;
  
   Mutex mLock;
 };
 
 static std::map<NPP, nsNPAPIPluginInstance*> sPluginNPPMap;
 
 #endif
--- a/dom/quota/QuotaObject.h
+++ b/dom/quota/QuotaObject.h
@@ -63,45 +63,46 @@ private:
 
   mozilla::ThreadSafeAutoRefCnt mRefCnt;
 
   OriginInfo* mOriginInfo;
   nsString mPath;
   int64_t mSize;
 };
 
-class OriginInfo
+class OriginInfo MOZ_FINAL
 {
   friend class GroupInfo;
   friend class QuotaManager;
   friend class QuotaObject;
 
 public:
   OriginInfo(GroupInfo* aGroupInfo, const nsACString& aOrigin, uint64_t aLimit,
              uint64_t aUsage, int64_t aAccessTime)
   : mGroupInfo(aGroupInfo), mOrigin(aOrigin), mLimit(aLimit), mUsage(aUsage),
     mAccessTime(aAccessTime)
   {
     MOZ_COUNT_CTOR(OriginInfo);
   }
 
-  ~OriginInfo()
-  {
-    MOZ_COUNT_DTOR(OriginInfo);
-  }
-
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(OriginInfo)
 
   int64_t
   AccessTime() const
   {
     return mAccessTime;
   }
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~OriginInfo()
+  {
+    MOZ_COUNT_DTOR(OriginInfo);
+  }
+
   void
   LockedDecreaseUsage(int64_t aSize);
 
   void
   LockedUpdateAccessTime(int64_t aAccessTime)
   {
     AssertCurrentThreadOwnsQuotaMutex();
 
@@ -141,50 +142,51 @@ public:
 
   bool
   LessThan(const OriginInfo* a, const OriginInfo* b) const
   {
     return a && b ? a->AccessTime() < b->AccessTime() : b ? true : false;
   }
 };
 
-class GroupInfo
+class GroupInfo MOZ_FINAL
 {
   friend class GroupInfoPair;
   friend class OriginInfo;
   friend class QuotaManager;
   friend class QuotaObject;
 
 public:
   GroupInfo(PersistenceType aPersistenceType, const nsACString& aGroup)
   : mPersistenceType(aPersistenceType), mGroup(aGroup), mUsage(0)
   {
     MOZ_COUNT_CTOR(GroupInfo);
   }
 
-  ~GroupInfo()
-  {
-    MOZ_COUNT_DTOR(GroupInfo);
-  }
-
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GroupInfo)
 
   bool
   IsForPersistentStorage() const
   {
     return mPersistenceType == PERSISTENCE_TYPE_PERSISTENT;
   }
 
   bool
   IsForTemporaryStorage() const
   {
     return mPersistenceType == PERSISTENCE_TYPE_TEMPORARY;
   }
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~GroupInfo()
+  {
+    MOZ_COUNT_DTOR(GroupInfo);
+  }
+
   already_AddRefed<OriginInfo>
   LockedGetOriginInfo(const nsACString& aOrigin);
 
   void
   LockedAddOriginInfo(OriginInfo* aOriginInfo);
 
   void
   LockedRemoveOriginInfo(const nsACString& aOrigin);
--- a/dom/smil/nsSMILInstanceTime.h
+++ b/dom/smil/nsSMILInstanceTime.h
@@ -28,17 +28,17 @@ class nsSMILTimeValueSpec;
 // a) nsSMILIntervals that belong to the same nsSMILTimedElement and which refer
 //    to the nsSMILInstanceTimes which form the interval endpoints; and/or
 // b) nsSMILIntervals that belong to other nsSMILTimedElements but which need to
 //    update dependent instance times when they change or are deleted.
 //    E.g. for begin='a.begin', 'a' needs to inform dependent
 //    nsSMILInstanceTimes if its begin time changes. This notification is
 //    performed by the nsSMILInterval.
 
-class nsSMILInstanceTime
+class nsSMILInstanceTime MOZ_FINAL
 {
 public:
   // Instance time source. Times generated by events, syncbase relationships,
   // and DOM calls behave differently in some circumstances such as when a timed
   // element is reset.
   enum nsSMILInstanceTimeSource {
     // No particularly significant source, e.g. offset time, 'indefinite'
     SOURCE_NONE,
@@ -49,17 +49,17 @@ public:
     // Generated by an event
     SOURCE_EVENT
   };
 
   nsSMILInstanceTime(const nsSMILTimeValue& aTime,
                      nsSMILInstanceTimeSource aSource = SOURCE_NONE,
                      nsSMILTimeValueSpec* aCreator = nullptr,
                      nsSMILInterval* aBaseInterval = nullptr);
-  ~nsSMILInstanceTime();
+
   void Unlink();
   void HandleChangedInterval(const nsSMILTimeContainer* aSrcContainer,
                              bool aBeginObjectChanged,
                              bool aEndObjectChanged);
   void HandleDeletedInterval();
   void HandleFilteredInterval();
 
   const nsSMILTimeValue& Time() const { return mTime; }
@@ -94,17 +94,20 @@ public:
 
   // Get and set a serial number which may be used by a containing class to
   // control the sort order of otherwise similar instance times.
   uint32_t Serial() const { return mSerial; }
   void SetSerial(uint32_t aIndex) { mSerial = aIndex; }
 
   NS_INLINE_DECL_REFCOUNTING(nsSMILInstanceTime)
 
-protected:
+private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~nsSMILInstanceTime();
+
   void SetBaseInterval(nsSMILInterval* aBaseInterval);
 
   nsSMILTimeValue mTime;
 
   // Internal flags used to represent the behaviour of different instance times
   enum {
     // Indicates that this instance time was generated by an event or a DOM
     // call. Such instance times require special handling when (i) the owning
--- a/dom/src/storage/DOMStorageCache.h
+++ b/dom/src/storage/DOMStorageCache.h
@@ -229,20 +229,22 @@ private:
 
 // DOMStorageUsage
 // Infrastructure to manage and check eTLD+1 quota
 class DOMStorageUsageBridge
 {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DOMStorageUsageBridge)
 
-  virtual ~DOMStorageUsageBridge() {}
-
   virtual const nsCString& Scope() = 0;
   virtual void LoadUsage(const int64_t aUsage) = 0;
+
+protected:
+  // Protected destructor, to discourage deletion outside of Release():
+  virtual ~DOMStorageUsageBridge() {}
 };
 
 class DOMStorageUsage : public DOMStorageUsageBridge
 {
 public:
   DOMStorageUsage(const nsACString& aScope);
 
   bool CheckAndSetETLD1UsageDelta(uint32_t aDataSetIndex, int64_t aUsageDelta);
--- a/dom/workers/FileReaderSync.h
+++ b/dom/workers/FileReaderSync.h
@@ -22,16 +22,22 @@ template<typename> class Optional;
 }
 
 BEGIN_WORKERS_NAMESPACE
 
 class FileReaderSync MOZ_FINAL
 {
   NS_INLINE_DECL_REFCOUNTING(FileReaderSync)
 
+private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~FileReaderSync()
+  {
+  }
+
   nsresult ConvertStream(nsIInputStream *aStream, const char *aCharset,
                          nsAString &aResult);
 
 public:
   static already_AddRefed<FileReaderSync>
   Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
 
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
--- a/dom/workers/URL.cpp
+++ b/dom/workers/URL.cpp
@@ -32,21 +32,16 @@ public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLProxy)
 
   URLProxy(mozilla::dom::URL* aURL)
     : mURL(aURL)
   {
     AssertIsOnMainThread();
   }
 
-  ~URLProxy()
-  {
-     MOZ_ASSERT(!mURL);
-  }
-
   mozilla::dom::URL* URL()
   {
     return mURL;
   }
 
   nsIURI* URI()
   {
     return mURL->GetURI();
@@ -54,16 +49,22 @@ public:
 
   void ReleaseURI()
   {
     AssertIsOnMainThread();
     mURL = nullptr;
   }
 
 private:
+  // Private destructor, to discourage deletion outside of Release():
+  ~URLProxy()
+  {
+     MOZ_ASSERT(!mURL);
+  }
+
   nsRefPtr<mozilla::dom::URL> mURL;
 };
 
 // Base class for the URL runnable objects.
 class URLRunnable : public nsRunnable
 {
 protected:
   WorkerPrivate* mWorkerPrivate;
--- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
+++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp
@@ -376,19 +376,23 @@ public:
     nsresult startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler,
                        nsIPrincipal* aSourcePrincipal);
 
 private:
     nsRefPtr<txMozillaXSLTProcessor> mProcessor;
     nsCOMPtr<nsILoadGroup> mLoadGroup;
     nsCOMPtr<nsIPrincipal> mCallerPrincipal;
 
-protected:
     // This exists solely to suppress a warning from nsDerivedSafe
     txCompileObserver();
+
+    // Private destructor, to discourage deletion outside of Release():
+    ~txCompileObserver()
+    {
+    }
 };
 
 txCompileObserver::txCompileObserver(txMozillaXSLTProcessor* aProcessor,
                                      nsILoadGroup* aLoadGroup)
     : mProcessor(aProcessor),
       mLoadGroup(aLoadGroup)
 {
 }
@@ -600,17 +604,22 @@ handleNode(nsINode* aNode, txStylesheetC
 class txSyncCompileObserver MOZ_FINAL : public txACompileObserver
 {
 public:
     txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor);
 
     TX_DECL_ACOMPILEOBSERVER
     NS_INLINE_DECL_REFCOUNTING(txSyncCompileObserver)
 
-protected:
+private:
+    // Private destructor, to discourage deletion outside of Release():
+    ~txSyncCompileObserver()
+    {
+    }
+
     nsRefPtr<txMozillaXSLTProcessor> mProcessor;
 };
 
 txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor)
   : mProcessor(aProcessor)
 {
 }
 
--- a/dom/xslt/xslt/txStylesheet.h
+++ b/dom/xslt/xslt/txStylesheet.h
@@ -17,27 +17,26 @@ class txToplevelItem;
 class txTemplateItem;
 class txVariableItem;
 class txStripSpaceItem;
 class txAttributeSetItem;
 class txDecimalFormat;
 class txStripSpaceTest;
 class txXSLKey;
 
-class txStylesheet
+class txStylesheet MOZ_FINAL
 {
 public:
     class ImportFrame;
     class GlobalVariable;
     friend class txStylesheetCompilerState;
     // To be able to do some cleaning up in destructor
     friend class ImportFrame;
 
     txStylesheet();
-    ~txStylesheet();
     nsresult init();
     
     NS_INLINE_DECL_REFCOUNTING(txStylesheet)
 
     txInstruction* findTemplate(const txXPathNode& aNode,
                                 const txExpandedName& aMode,
                                 txIMatchContext* aContext,
                                 ImportFrame* aImportedBy,
@@ -102,16 +101,19 @@ public:
                        bool aIsParam);
 
         nsAutoPtr<Expr> mExpr;
         nsAutoPtr<txInstruction> mFirstInstruction;
         bool mIsParam;
     };
 
 private:
+    // Private destructor, to discourage deletion outside of Release():
+    ~txStylesheet();
+
     nsresult addTemplate(txTemplateItem* aTemplate, ImportFrame* aImportFrame);
     nsresult addGlobalVariable(txVariableItem* aVariable);
     nsresult addFrames(txListIterator& aInsertIter);
     nsresult addStripSpace(txStripSpaceItem* aStripSpaceItem,
                            nsTArray<txStripSpaceTest*>& aFrameStripSpaceTests);
     nsresult addAttributeSet(txAttributeSetItem* aAttributeSetItem);
 
     // List of ImportFrames
--- a/dom/xslt/xslt/txStylesheetCompiler.h
+++ b/dom/xslt/xslt/txStylesheetCompiler.h
@@ -176,18 +176,18 @@ private:
 struct txStylesheetAttr
 {
     int32_t mNamespaceID;
     nsCOMPtr<nsIAtom> mLocalName;
     nsCOMPtr<nsIAtom> mPrefix;
     nsString mValue;
 };
 
-class txStylesheetCompiler : private txStylesheetCompilerState,
-                             public txACompileObserver
+class txStylesheetCompiler MOZ_FINAL : private txStylesheetCompilerState,
+                                       public txACompileObserver
 {
 public:
     friend class txStylesheetCompilerState;
     friend bool TX_XSLTFunctionAvailable(nsIAtom* aName,
                                            int32_t aNameSpaceID);
     txStylesheetCompiler(const nsAString& aStylesheetURI,
                          txACompileObserver* aObserver);
     txStylesheetCompiler(const nsAString& aStylesheetURI,
@@ -211,16 +211,21 @@ public:
                 const char16_t *aParam = nullptr);
 
     txStylesheet* getStylesheet();
 
     TX_DECL_ACOMPILEOBSERVER
     NS_INLINE_DECL_REFCOUNTING(txStylesheetCompiler)
 
 private:
+    // Private destructor, to discourage deletion outside of Release():
+    ~txStylesheetCompiler()
+    {
+    }
+
     nsresult startElementInternal(int32_t aNamespaceID, nsIAtom* aLocalName,
                                   nsIAtom* aPrefix,
                                   txStylesheetAttr* aAttributes,
                                   int32_t aAttrCount,
                                   int32_t aIDOffset = -1);
 
     nsresult flushCharacters();
     nsresult ensureNewElementContext();