Bug 1282026 - Add assertions in the DTOR of WorkerHolder - part 2 - assertions, r=bkelly
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 18 Jul 2016 09:13:05 +0200
changeset 305286 51d8d12d035cd86ed15badaa5d4a304844987713
parent 305285 0619d5ea9d35e6f0800c044acfb8fb47ca98d8d8
child 305287 ff9608965b499165c061aeb042f382609959eda1
push id79539
push useramarchesini@mozilla.com
push dateMon, 18 Jul 2016 07:15:46 +0000
treeherdermozilla-inbound@ff9608965b49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1282026
milestone50.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 1282026 - Add assertions in the DTOR of WorkerHolder - part 2 - assertions, r=bkelly
dom/workers/WorkerHolder.cpp
dom/workers/WorkerHolder.h
--- a/dom/workers/WorkerHolder.cpp
+++ b/dom/workers/WorkerHolder.cpp
@@ -11,44 +11,50 @@ BEGIN_WORKERS_NAMESPACE
 
 WorkerHolder::WorkerHolder()
   : mWorkerPrivate(nullptr)
 {
 }
 
 WorkerHolder::~WorkerHolder()
 {
+  NS_ASSERT_OWNINGTHREAD(WorkerHolder);
   ReleaseWorkerInternal();
   MOZ_ASSERT(mWorkerPrivate == nullptr);
 }
 
 bool
 WorkerHolder::HoldWorker(WorkerPrivate* aWorkerPrivate)
 {
+  NS_ASSERT_OWNINGTHREAD(WorkerHolder);
   MOZ_ASSERT(aWorkerPrivate);
   aWorkerPrivate->AssertIsOnWorkerThread();
 
   if (!aWorkerPrivate->AddHolder(this)) {
     return false;
   }
 
   mWorkerPrivate = aWorkerPrivate;
   return true;
 }
 
 void
 WorkerHolder::ReleaseWorker()
 {
+  NS_ASSERT_OWNINGTHREAD(WorkerHolder);
   MOZ_ASSERT(mWorkerPrivate);
+
   ReleaseWorkerInternal();
 }
 
 void
 WorkerHolder::ReleaseWorkerInternal()
 {
+  NS_ASSERT_OWNINGTHREAD(WorkerHolder);
+
   if (mWorkerPrivate) {
     mWorkerPrivate->AssertIsOnWorkerThread();
     mWorkerPrivate->RemoveHolder(this);
     mWorkerPrivate = nullptr;
   }
 }
 
 END_WORKERS_NAMESPACE
--- a/dom/workers/WorkerHolder.h
+++ b/dom/workers/WorkerHolder.h
@@ -67,25 +67,30 @@ enum Status
 
   // The close handler has run and the worker is effectively dead.
   Dead
 };
 
 class WorkerHolder
 {
 public:
+  NS_DECL_OWNINGTHREAD
+
   WorkerHolder();
   virtual ~WorkerHolder();
 
   bool HoldWorker(WorkerPrivate* aWorkerPrivate);
   void ReleaseWorker();
 
   virtual bool Notify(Status aStatus) = 0;
 
 protected:
   void ReleaseWorkerInternal();
 
   WorkerPrivate* MOZ_NON_OWNING_REF mWorkerPrivate;
+
+private:
+  void AssertIsOwningThread() const;
 };
 
 END_WORKERS_NAMESPACE
 
 #endif /* mozilla_dom_workers_WorkerHolder_h */