Bug 1035394 - Fix dangerous public destructors in dom - r=ehsan
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 08 Jul 2014 17:23:17 -0400
changeset 206789 e5f8bd650ef1a7a0bfbee817a5e434b9fc5c62a0
parent 206788 15ea98d307c59f688d920387d04893afbc34d9be
child 206790 ad2e6df5024093e92e8d4befd34733b7f1b00066
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs1035394
milestone33.0a1
Bug 1035394 - Fix dangerous public destructors in dom - r=ehsan
dom/archivereader/ArchiveZipFile.h
dom/base/DOMCursor.h
dom/base/DOMRequest.h
dom/base/MessagePort.h
dom/base/PerformanceResourceTiming.h
dom/base/nsGlobalWindow.h
dom/crypto/HmacKeyAlgorithm.h
dom/crypto/RsaHashedKeyAlgorithm.h
dom/datastore/DataStore.h
dom/indexedDB/OpenDatabaseHelper.cpp
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/mobilemessage/src/DOMMobileMessageError.h
dom/mobilemessage/src/MobileMessageManager.h
dom/network/src/Connection.h
dom/promise/PromiseCallback.h
dom/quota/QuotaManager.cpp
dom/smil/TimeEvent.h
dom/src/jsurl/nsJSProtocolHandler.h
dom/src/offline/nsDOMOfflineResourceList.h
dom/workers/RuntimeService.cpp
dom/workers/ServiceWorkerEvents.h
dom/workers/WorkerPrivate.cpp
dom/xbl/XBLChildrenElement.h
dom/xslt/xpath/txNodeSetAdaptor.h
--- a/dom/archivereader/ArchiveZipFile.h
+++ b/dom/archivereader/ArchiveZipFile.h
@@ -49,33 +49,33 @@ public:
     mCentral(aCentral),
     mArchiveReader(aReader),
     mFilename(aName)
   {
     NS_ASSERTION(mArchiveReader, "must have a reader");
     MOZ_COUNT_CTOR(ArchiveZipFileImpl);
   }
 
-  virtual ~ArchiveZipFileImpl()
-  {
-    MOZ_COUNT_DTOR(ArchiveZipFileImpl);
-  }
-
   // Overrides:
   virtual nsresult GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;
 
   virtual void Unlink() MOZ_OVERRIDE;
   virtual void Traverse(nsCycleCollectionTraversalCallback &aCb) MOZ_OVERRIDE;
 
   virtual bool IsCCed() const MOZ_OVERRIDE
   {
     return true;
   }
 
 protected:
+  virtual ~ArchiveZipFileImpl()
+  {
+    MOZ_COUNT_DTOR(ArchiveZipFileImpl);
+  }
+
   virtual already_AddRefed<nsIDOMBlob> CreateSlice(uint64_t aStart,
                                                    uint64_t aLength,
                                                    const nsAString& aContentType) MOZ_OVERRIDE;
 
 private: // Data
   ZipCentral mCentral;
   nsRefPtr<ArchiveReader> mArchiveReader;
 
--- a/dom/base/DOMCursor.h
+++ b/dom/base/DOMCursor.h
@@ -33,16 +33,19 @@ public:
   {
     return mFinished;
   }
   virtual void Continue(ErrorResult& aRv);
 
   void Reset();
   void FireDone();
 
+protected:
+  ~DOMCursor() {}
+
 private:
   DOMCursor() MOZ_DELETE;
 
   nsCOMPtr<nsICursorContinueCallback> mCallback;
   bool mFinished;
 };
 
 } // namespace dom
--- a/dom/base/DOMRequest.h
+++ b/dom/base/DOMRequest.h
@@ -70,23 +70,23 @@ public:
 
   void FireSuccess(JS::Handle<JS::Value> aResult);
   void FireError(const nsAString& aError);
   void FireError(nsresult aError);
   void FireDetailedError(DOMError* aError);
 
   DOMRequest(nsPIDOMWindow* aWindow);
 
+protected:
   virtual ~DOMRequest()
   {
     mResult = JSVAL_VOID;
     mozilla::DropJSObjects(this);
   }
 
-protected:
   void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
 
   void RootResultVal();
 };
 
 class DOMRequestService MOZ_FINAL : public nsIDOMRequestService
 {
   ~DOMRequestService() {}
--- a/dom/base/MessagePort.h
+++ b/dom/base/MessagePort.h
@@ -57,17 +57,16 @@ class MessagePort MOZ_FINAL : public Mes
   friend class PostMessageRunnable;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MessagePort,
                                            DOMEventTargetHelper)
 
   MessagePort(nsPIDOMWindow* aWindow);
-  ~MessagePort();
 
   virtual JSObject*
   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   virtual void
   PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                  const Optional<Sequence<JS::Value>>& aTransferable,
                  ErrorResult& aRv) MOZ_OVERRIDE;
@@ -91,16 +90,18 @@ public:
   // new one.
   void
   Entangle(MessagePort* aMessagePort);
 
   virtual already_AddRefed<MessagePortBase>
   Clone() MOZ_OVERRIDE;
 
 private:
+  ~MessagePort();
+
   // Dispatch events from the Message Queue using a nsRunnable.
   void Dispatch();
 
   nsRefPtr<DispatchEventRunnable> mDispatchRunnable;
 
   nsRefPtr<MessagePort> mEntangledPort;
 
   nsTArray<nsRefPtr<PostMessageRunnable> > mMessageQueue;
--- a/dom/base/PerformanceResourceTiming.h
+++ b/dom/base/PerformanceResourceTiming.h
@@ -24,17 +24,16 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
       PerformanceResourceTiming,
       PerformanceEntry)
 
   PerformanceResourceTiming(nsPerformanceTiming* aPerformanceTiming,
                             nsPerformance* aPerformance);
-  virtual ~PerformanceResourceTiming();
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
 
   virtual DOMHighResTimeStamp StartTime() const;
 
   virtual DOMHighResTimeStamp Duration() const
   {
@@ -118,16 +117,18 @@ public:
   DOMHighResTimeStamp SecureConnectionStart() const
   {
     // This measurement is not available for Navigation Timing either.
     // There is a different bug submitted for it.
     return 0;
   }
 
 protected:
+  virtual ~PerformanceResourceTiming();
+
   nsString mInitiatorType;
   nsRefPtr<nsPerformanceTiming> mTiming;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_PerformanceResourceTiming_h___ */
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1677,32 +1677,34 @@ public:
                                 void* aUserArg)
   {
     if (aMM) {
       static_cast<nsFrameMessageManager*>(aMM)->Disconnect();
     }
     return PL_DHASH_NEXT;
   }
 
+protected:
   ~nsGlobalChromeWindow()
   {
     NS_ABORT_IF_FALSE(mCleanMessageManager,
                       "chrome windows may always disconnect the msg manager");
 
     mGroupMessageManagers.EnumerateRead(DisconnectGroupMessageManager, nullptr);
     mGroupMessageManagers.Clear();
 
     if (mMessageManager) {
       static_cast<nsFrameMessageManager *>(
         mMessageManager.get())->Disconnect();
     }
 
     mCleanMessageManager = false;
   }
 
+public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsGlobalChromeWindow,
                                            nsGlobalWindow)
 
   using nsGlobalWindow::GetBrowserDOMWindow;
   using nsGlobalWindow::SetBrowserDOMWindow;
   using nsGlobalWindow::GetAttention;
   using nsGlobalWindow::GetAttentionWithCycleCount;
   using nsGlobalWindow::SetCursor;
@@ -1731,16 +1733,19 @@ public:
   nsGlobalModalWindow(nsGlobalWindow *aOuterWindow)
     : nsGlobalWindow(aOuterWindow)
   {
     mIsModalContentWindow = true;
   }
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMMODALCONTENTWINDOW
+
+protected:
+  ~nsGlobalModalWindow() {}
 };
 
 /* factory function */
 inline already_AddRefed<nsGlobalWindow>
 NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow)
 {
   nsRefPtr<nsGlobalWindow> global;
 
--- a/dom/crypto/HmacKeyAlgorithm.h
+++ b/dom/crypto/HmacKeyAlgorithm.h
@@ -35,19 +35,16 @@ public:
       case CKM_SHA_1: mMechanism = CKM_SHA_1_HMAC; break;
       case CKM_SHA256: mMechanism = CKM_SHA256_HMAC; break;
       case CKM_SHA384: mMechanism = CKM_SHA384_HMAC; break;
       case CKM_SHA512: mMechanism = CKM_SHA512_HMAC; break;
       default: mMechanism = UNKNOWN_CK_MECHANISM; break;
     }
   }
 
-  ~HmacKeyAlgorithm()
-  {}
-
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   KeyAlgorithm* Hash() const
   {
     return mHash;
   }
 
   uint32_t Length() const
@@ -55,16 +52,19 @@ public:
     return mLength;
   }
 
   virtual bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const MOZ_OVERRIDE;
   static KeyAlgorithm* Create(nsIGlobalObject* aGlobal,
                               JSStructuredCloneReader* aReader);
 
 protected:
+  ~HmacKeyAlgorithm()
+  {}
+
   nsRefPtr<KeyAlgorithm> mHash;
   uint32_t mLength;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_HmacKeyAlgorithm_h
--- a/dom/crypto/RsaHashedKeyAlgorithm.h
+++ b/dom/crypto/RsaHashedKeyAlgorithm.h
@@ -23,29 +23,29 @@ public:
                         const nsString& aName,
                         uint32_t aModulusLength,
                         const CryptoBuffer& aPublicExponent,
                         const nsString& aHashName)
     : RsaKeyAlgorithm(aGlobal, aName, aModulusLength, aPublicExponent)
     , mHash(new KeyAlgorithm(aGlobal, aHashName))
   {}
 
-  ~RsaHashedKeyAlgorithm() {}
-
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   KeyAlgorithm* Hash() const
   {
     return mHash;
   }
 
   virtual bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const MOZ_OVERRIDE;
   static KeyAlgorithm* Create(nsIGlobalObject* aGlobal,
                               JSStructuredCloneReader* aReader);
 
 private:
+  ~RsaHashedKeyAlgorithm() {}
+
   nsRefPtr<KeyAlgorithm> mHash;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_RsaHashedKeyAlgorithm_h
--- a/dom/datastore/DataStore.h
+++ b/dom/datastore/DataStore.h
@@ -22,17 +22,16 @@ class OwningStringOrUnsignedLong;
 class DataStore MOZ_FINAL : public DOMEventTargetHelper
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DataStore,
                                            DOMEventTargetHelper)
 
   explicit DataStore(nsPIDOMWindow* aWindow);
-  ~DataStore();
 
   // WebIDL (internal functions)
 
   static already_AddRefed<DataStore> Constructor(GlobalObject& aGlobal,
                                                  ErrorResult& aRv);
 
   virtual JSObject* WrapObject(JSContext *aCx) MOZ_OVERRIDE;
 
@@ -79,15 +78,17 @@ public:
 
   // This internal function (ChromeOnly) is aimed to make the DataStore keep a
   // reference to the DataStoreImpl which really implements the API's logic in
   // JS. We also need to let the DataStoreImpl implementation keep the event
   // target of DataStore, so that it can know where to fire the events.
   void SetDataStoreImpl(DataStoreImpl& aStore, ErrorResult& aRv);
 
 private:
+  ~DataStore();
+
   nsRefPtr<DataStoreImpl> mStore;
 };
 
 } //namespace dom
 } //namespace mozilla
 
 #endif
--- a/dom/indexedDB/OpenDatabaseHelper.cpp
+++ b/dom/indexedDB/OpenDatabaseHelper.cpp
@@ -1497,16 +1497,18 @@ public:
 
   virtual nsresult GetSuccessResult(JSContext* aCx,
                                     JS::MutableHandle<JS::Value> aVal) MOZ_OVERRIDE;
 
   virtual nsresult
   OnExclusiveAccessAcquired() MOZ_OVERRIDE;
 
 protected:
+  virtual ~SetVersionHelper() {}
+
   virtual nsresult Init() MOZ_OVERRIDE;
 
   virtual nsresult DoDatabaseWork(mozIStorageConnection* aConnection)
                                   MOZ_OVERRIDE;
 
   // SetVersionHelper never fires an error event at the request.  It hands that
   // responsibility back to the OpenDatabaseHelper
   virtual void OnError() MOZ_OVERRIDE
@@ -1578,16 +1580,18 @@ public:
 
     AsyncConnectionHelper::ReleaseMainThreadObjects();
   }
 
   virtual nsresult
   OnExclusiveAccessAcquired() MOZ_OVERRIDE;
 
 protected:
+  virtual ~DeleteDatabaseHelper() {}
+
   nsresult DoDatabaseWork(mozIStorageConnection* aConnection);
   nsresult Init();
 
   // DeleteDatabaseHelper never fires events at the request.  It hands that
   // responsibility back to the OpenDatabaseHelper
   void OnError()
   {
     mOpenHelper->NotifyDeleteFinished();
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2831,16 +2831,20 @@ TabChild::RecvUIResolutionChanged()
   return true;
 }
 
 TabChildGlobal::TabChildGlobal(TabChildBase* aTabChild)
 : mTabChild(aTabChild)
 {
 }
 
+TabChildGlobal::~TabChildGlobal()
+{
+}
+
 void
 TabChildGlobal::Init()
 {
   NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
   mMessageManager = new nsFrameMessageManager(mTabChild,
                                               nullptr,
                                               MM_CHILD);
 }
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -134,16 +134,19 @@ public:
   }
 
   virtual JSContext* GetJSContextForEventHandlers() MOZ_OVERRIDE;
   virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE;
   virtual JSObject* GetGlobalJSObject() MOZ_OVERRIDE;
 
   nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
   nsRefPtr<TabChildBase> mTabChild;
+
+protected:
+  ~TabChildGlobal();
 };
 
 class ContentListener MOZ_FINAL : public nsIDOMEventListener
 {
 public:
   ContentListener(TabChild* aTabChild) : mTabChild(aTabChild) {}
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
@@ -252,18 +255,16 @@ public:
      * on the critical path.
      */
     static void PreloadSlowThings();
 
     /** Return a TabChild with the given attributes. */
     static already_AddRefed<TabChild>
     Create(nsIContentChild* aManager, const TabContext& aContext, uint32_t aChromeFlags);
 
-    virtual ~TabChild();
-
     bool IsRootContentDocument();
 
     const uint64_t Id() const {
         return mUniqueId;
     }
 
     static uint64_t
     GetTabChildId(TabChild* aTabChild)
@@ -477,16 +478,18 @@ public:
       nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
       nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(webNav);
       return GetFrom(docShell);
     }
 
     virtual bool RecvUIResolutionChanged() MOZ_OVERRIDE;
 
 protected:
+    virtual ~TabChild();
+
     virtual PRenderFrameChild* AllocPRenderFrameChild(ScrollingBehavior* aScrolling,
                                                       TextureFactoryIdentifier* aTextureFactoryIdentifier,
                                                       uint64_t* aLayersId,
                                                       bool* aSuccess) MOZ_OVERRIDE;
     virtual bool DeallocPRenderFrameChild(PRenderFrameChild* aFrame) MOZ_OVERRIDE;
     virtual bool RecvDestroy() MOZ_OVERRIDE;
     virtual bool RecvSetUpdateHitRegion(const bool& aEnabled) MOZ_OVERRIDE;
     virtual bool RecvSetIsDocShellActive(const bool& aIsActive) MOZ_OVERRIDE;
--- a/dom/mobilemessage/src/DOMMobileMessageError.h
+++ b/dom/mobilemessage/src/DOMMobileMessageError.h
@@ -30,16 +30,18 @@ public:
                         nsIDOMMozMmsMessage* aMms);
 
   virtual JSObject*
   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   void GetData(OwningMozSmsMessageOrMozMmsMessage& aRetVal) const;
 
 private:
+  ~DOMMobileMessageError() {}
+
   nsCOMPtr<nsIDOMMozSmsMessage> mSms;
   nsCOMPtr<nsIDOMMozMmsMessage> mMms;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_MobileMessageError_h
--- a/dom/mobilemessage/src/MobileMessageManager.h
+++ b/dom/mobilemessage/src/MobileMessageManager.h
@@ -121,16 +121,18 @@ public:
   IMPL_EVENT_HANDLER(sent)
   IMPL_EVENT_HANDLER(failed)
   IMPL_EVENT_HANDLER(deliverysuccess)
   IMPL_EVENT_HANDLER(deliveryerror)
   IMPL_EVENT_HANDLER(readsuccess)
   IMPL_EVENT_HANDLER(readerror)
 
 private:
+  ~MobileMessageManager() {}
+
   /**
    * Internal Send() method used to send one message.
    */
   already_AddRefed<DOMRequest>
   Send(nsISmsService* aSmsService,
        uint32_t aServiceId,
        const nsAString& aNumber,
        const nsAString& aText,
--- a/dom/network/src/Connection.h
+++ b/dom/network/src/Connection.h
@@ -44,16 +44,18 @@ public:
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   ConnectionType Type() const { return mType; }
 
   IMPL_EVENT_HANDLER(typechange)
 
 private:
+  ~Connection() {}
+
   /**
    * Update the connection information stored in the object using a
    * NetworkInformation object.
    */
   void UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo);
 
   /**
    * The type of current connection.
--- a/dom/promise/PromiseCallback.h
+++ b/dom/promise/PromiseCallback.h
@@ -50,19 +50,20 @@ public:
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(WrapperPromiseCallback,
                                                          PromiseCallback)
 
   void Call(JSContext* aCx,
             JS::Handle<JS::Value> aValue) MOZ_OVERRIDE;
 
   WrapperPromiseCallback(Promise* aNextPromise, JS::Handle<JSObject*> aGlobal,
                          AnyCallback* aCallback);
+
+private:
   ~WrapperPromiseCallback();
 
-private:
   nsRefPtr<Promise> mNextPromise;
   JS::Heap<JSObject*> mGlobal;
   nsRefPtr<AnyCallback> mCallback;
 };
 
 // ResolvePromiseCallback calls aPromise->ResolveFunction() with the value
 // received by Call().
 class ResolvePromiseCallback MOZ_FINAL : public PromiseCallback
@@ -71,19 +72,20 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ResolvePromiseCallback,
                                                          PromiseCallback)
 
   void Call(JSContext* aCx,
             JS::Handle<JS::Value> aValue) MOZ_OVERRIDE;
 
   ResolvePromiseCallback(Promise* aPromise, JS::Handle<JSObject*> aGlobal);
+
+private:
   ~ResolvePromiseCallback();
 
-private:
   nsRefPtr<Promise> mPromise;
   JS::Heap<JSObject*> mGlobal;
 };
 
 // RejectPromiseCallback calls aPromise->RejectFunction() with the value
 // received by Call().
 class RejectPromiseCallback MOZ_FINAL : public PromiseCallback
 {
@@ -91,19 +93,20 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(RejectPromiseCallback,
                                                          PromiseCallback)
 
   void Call(JSContext* aCx,
             JS::Handle<JS::Value> aValue) MOZ_OVERRIDE;
 
   RejectPromiseCallback(Promise* aPromise, JS::Handle<JSObject*> aGlobal);
+
+private:
   ~RejectPromiseCallback();
 
-private:
   nsRefPtr<Promise> mPromise;
   JS::Heap<JSObject*> mGlobal;
 };
 
 // NativePromiseCallback wraps a NativePromiseHandler.
 class NativePromiseCallback MOZ_FINAL : public PromiseCallback
 {
 public:
@@ -111,19 +114,20 @@ public:
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(NativePromiseCallback,
                                            PromiseCallback)
 
   void Call(JSContext* aCx,
             JS::Handle<JS::Value> aValue) MOZ_OVERRIDE;
 
   NativePromiseCallback(PromiseNativeHandler* aHandler,
                         Promise::PromiseState aState);
+
+private:
   ~NativePromiseCallback();
 
-private:
   nsRefPtr<PromiseNativeHandler> mHandler;
   Promise::PromiseState mState;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_PromiseCallback_h
--- a/dom/quota/QuotaManager.cpp
+++ b/dom/quota/QuotaManager.cpp
@@ -223,16 +223,18 @@ public:
   InvalidateOpenedStorages(nsTArray<nsCOMPtr<nsIOfflineStorage> >& aStorages,
                            void* aClosure);
 
   void
   DeleteFiles(QuotaManager* aQuotaManager,
               PersistenceType aPersistenceType);
 
 private:
+  ~OriginClearRunnable() {}
+
   OriginOrPatternString mOriginOrPattern;
   Nullable<PersistenceType> mPersistenceType;
   CallbackState mCallbackState;
 };
 
 // Responsible for calculating the amount of space taken up by storages of a
 // certain origin. Created when nsIQuotaManager::GetUsageForURI is called.
 // May be canceled with nsIQuotaRequest::Cancel. Runs three times, first
@@ -293,16 +295,18 @@ public:
         NS_NOTREACHED("Can't advance past Complete!");
     }
   }
 
   nsresult
   TakeShortcut();
 
 private:
+  ~AsyncUsageRunnable() {}
+
   // Run calls the RunInternal method and makes sure that we always dispatch
   // to the main thread in case of an error.
   inline nsresult
   RunInternal();
 
   nsresult
   AddToUsage(QuotaManager* aQuotaManager,
              PersistenceType aPersistenceType);
@@ -370,16 +374,18 @@ public:
   InvalidateOpenedStorages(nsTArray<nsCOMPtr<nsIOfflineStorage> >& aStorages,
                            void* aClosure);
 
   void
   DeleteFiles(QuotaManager* aQuotaManager,
               PersistenceType aPersistenceType);
 
 private:
+  ~ResetOrClearRunnable() {}
+
   CallbackState mCallbackState;
   bool mClear;
 };
 
 // Responsible for finalizing eviction of certian origins (storage files have
 // been already cleared, we just need to release IO thread only objects and
 // allow next synchronized ops for evicted origins). Created when
 // QuotaManager::FinalizeOriginEviction is called. Runs three times, first
--- a/dom/smil/TimeEvent.h
+++ b/dom/smil/TimeEvent.h
@@ -48,16 +48,18 @@ public:
 
   void InitTimeEvent(const nsAString& aType, nsIDOMWindow* aView,
                      int32_t aDetail, ErrorResult& aRv)
   {
     aRv = InitTimeEvent(aType, aView, aDetail);
   }
 
 private:
+  ~TimeEvent() {}
+
   nsCOMPtr<nsIDOMWindow> mView;
   int32_t mDetail;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TimeEvent_h_
--- a/dom/src/jsurl/nsJSProtocolHandler.h
+++ b/dom/src/jsurl/nsJSProtocolHandler.h
@@ -86,16 +86,18 @@ public:
     NS_IMETHOD Write(nsIObjectOutputStream* aStream) MOZ_OVERRIDE;
 
     // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
     // nsISerializable impl works right.
     NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) MOZ_OVERRIDE;
     //NS_IMETHOD QueryInterface( const nsIID& aIID, void** aInstancePtr );
 
 protected:
+    virtual ~nsJSURI() {}
+
     virtual nsresult EqualsInternal(nsIURI* other,
                                     RefHandlingEnum refHandlingMode,
                                     bool* result) MOZ_OVERRIDE;
 private:
     nsCOMPtr<nsIURI> mBaseURI;
 };
 
 #endif /* nsJSProtocolHandler_h___ */
--- a/dom/src/offline/nsDOMOfflineResourceList.h
+++ b/dom/src/offline/nsDOMOfflineResourceList.h
@@ -49,17 +49,16 @@ public:
   NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
                                            mozilla::DOMEventTargetHelper)
 
   nsDOMOfflineResourceList(nsIURI* aManifestURI,
                            nsIURI* aDocumentURI,
                            nsPIDOMWindow* aWindow);
-  virtual ~nsDOMOfflineResourceList();
 
   void FirePendingEvents();
   void Disconnect();
 
   nsresult Init();
 
   nsPIDOMWindow* GetParentObject() const
   {
@@ -125,16 +124,19 @@ public:
   {
     aRv = MozAdd(aURI);
   }
   void MozRemove(const nsAString& aURI, ErrorResult& aRv)
   {
     aRv = MozRemove(aURI);
   }
 
+protected:
+  virtual ~nsDOMOfflineResourceList();
+
 private:
   nsresult SendEvent(const nsAString &aEventName);
 
   nsresult UpdateAdded(nsIOfflineCacheUpdate *aUpdate);
   nsresult UpdateCompleted(nsIOfflineCacheUpdate *aUpdate);
 
   already_AddRefed<nsIApplicationCacheContainer> GetDocumentAppCacheContainer();
   already_AddRefed<nsIApplicationCache> GetDocumentAppCache();
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -654,16 +654,18 @@ public:
       JS_ReportError(aCx, "Failed to dispatch to main thread!");
       return false;
     }
 
     return syncLoop.Run();
   }
 
 private:
+  ~LogViolationDetailsRunnable() {}
+
   NS_DECL_NSIRUNNABLE
 };
 
 bool
 ContentSecurityPolicyAllows(JSContext* aCx)
 {
   WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
   worker->AssertIsOnWorkerThread();
--- a/dom/workers/ServiceWorkerEvents.h
+++ b/dom/workers/ServiceWorkerEvents.h
@@ -24,16 +24,17 @@ bool
 ServiceWorkerEventsVisible(JSContext* aCx, JSObject* aObj);
 
 class InstallPhaseEvent : public Event
 {
   nsRefPtr<Promise> mPromise;
 
 protected:
   InstallPhaseEvent(mozilla::dom::EventTarget* aOwner);
+  ~InstallPhaseEvent() {}
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InstallPhaseEvent, Event)
   NS_FORWARD_TO_EVENT
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
   {
@@ -75,16 +76,17 @@ public:
 
 class InstallEvent MOZ_FINAL : public InstallPhaseEvent
 {
   // FIXME(nsm): Bug 982787 will allow actually populating this.
   nsRefPtr<ServiceWorker> mActiveWorker;
 
 protected:
   InstallEvent(mozilla::dom::EventTarget* aOwner);
+  ~InstallEvent() {}
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(InstallEvent, InstallPhaseEvent)
   NS_FORWARD_TO_EVENT
 
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
   {
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -804,16 +804,18 @@ public:
   : mFinishedWorker(aFinishedWorker)
   {
     aFinishedWorker->AssertIsOnWorkerThread();
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
 private:
+  ~TopLevelWorkerFinishedRunnable() {}
+
   NS_IMETHOD
   Run() MOZ_OVERRIDE
   {
     AssertIsOnMainThread();
 
     RuntimeService* runtime = RuntimeService::GetService();
     MOZ_ASSERT(runtime);
 
--- a/dom/xbl/XBLChildrenElement.h
+++ b/dom/xbl/XBLChildrenElement.h
@@ -25,17 +25,16 @@ public:
   XBLChildrenElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
     : nsXMLElement(aNodeInfo)
   {
   }
   XBLChildrenElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     : nsXMLElement(aNodeInfo)
   {
   }
-  ~XBLChildrenElement();
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsINode interface methods
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo() { return nullptr; }
@@ -130,16 +129,19 @@ public:
     return mIncludes.IsEmpty();
   }
 
   nsIContent* InsertedChild(uint32_t aIndex)
   {
     return mInsertedChildren[aIndex];
   }
 
+protected:
+  ~XBLChildrenElement();
+
 private:
   nsTArray<nsIContent*> mInsertedChildren; // WEAK
   nsTArray<nsCOMPtr<nsIAtom> > mIncludes;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/xslt/xpath/txNodeSetAdaptor.h
+++ b/dom/xslt/xpath/txNodeSetAdaptor.h
@@ -21,16 +21,19 @@ public:
     txNodeSetAdaptor();
     txNodeSetAdaptor(txNodeSet *aNodeSet);
 
     nsresult Init();
 
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_TXINODESET
 
+protected:
+    ~txNodeSetAdaptor() {}
+
 private:
     txNodeSet* NodeSet()
     {
         return static_cast<txNodeSet*>(mValue.get());
     }
 
     bool mWritable;
 };