Bug 1328964 - Add names to Runnables to make it compile. draft
authorJan-Ivar Bruaroey <jib@mozilla.com>
Tue, 14 Nov 2017 12:01:30 -0500
changeset 697791 3d92d48afde11c1dfefe371c2ede99d3f6aafef5
parent 697790 5cbbb77ec4599b90dc30e6af50961cf19e777025
child 697792 7955d507ed43a2190b4660029755975ef9cec028
push id89093
push userjbruaroey@mozilla.com
push dateTue, 14 Nov 2017 17:33:26 +0000
bugs1328964
milestone59.0a1
Bug 1328964 - Add names to Runnables to make it compile. MozReview-Commit-ID: B35r0Rugr8U
dom/worklet/Worklet.cpp
dom/worklet/WorkletThread.cpp
dom/worklet/WorkletThread.h
--- a/dom/worklet/Worklet.cpp
+++ b/dom/worklet/Worklet.cpp
@@ -25,17 +25,18 @@
 namespace mozilla {
 namespace dom {
 
 class ExecutionRunnable final : public Runnable
 {
 public:
   ExecutionRunnable(WorkletFetchHandler* aHandler, Worklet::WorkletType aType,
                     char16_t* aScriptBuffer, size_t aScriptLength)
-    : mHandler(aHandler)
+    : Runnable("Worklet::ExecutionRunnable")
+    , mHandler(aHandler)
     , mWorkletType(aType)
     , mBuffer(aScriptBuffer, aScriptLength,
               JS::SourceBufferHolder::GiveOwnership)
     , mResult(NS_ERROR_FAILURE)
   {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
--- a/dom/worklet/WorkletThread.cpp
+++ b/dom/worklet/WorkletThread.cpp
@@ -3,16 +3,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WorkletThread.h"
 #include "prthread.h"
 #include "nsCycleCollector.h"
 #include "mozilla/dom/AtomList.h"
+#include "mozilla/EventQueue.h"
+#include "mozilla/ThreadEventQueue.h"
 
 namespace mozilla {
 namespace dom {
 
 namespace {
 
 // The size of the worklet runtime heaps in bytes.
 #define WORKLET_DEFAULT_RUNTIME_HEAPSIZE 32 * 1024 * 1024
@@ -77,17 +79,17 @@ DestroyWorkletPrincipals(JSPrincipals* a
 {
   MOZ_ASSERT_UNREACHABLE("Worklet principals refcount should never fall below one");
 }
 
 JSObject*
 Wrap(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj)
 {
   if (existing) {
-    js::Wrapper::Renew(cx, existing, obj,
+    js::Wrapper::Renew(existing, obj,
                        &js::OpaqueCrossCompartmentWrapper::singleton);
   }
 
   return js::Wrapper::New(cx, obj,
                           &js::OpaqueCrossCompartmentWrapper::singleton);
 }
 
 const JSWrapObjectCallbacks WrapObjectCallbacks =
@@ -215,17 +217,18 @@ private:
 // basically everything happens into this runnable. The reason behind this
 // approach is that, when the Worklet is terminated, it must not have any JS in
 // stack, but, because we have CC, nsIThread creates an AutoNoJSAPI object by
 // default. Using this runnable, CC exists only into it.
 class WorkletThread::PrimaryRunnable final : public Runnable
 {
 public:
   explicit PrimaryRunnable(WorkletThread* aWorkletThread)
-    : mWorkletThread(aWorkletThread)
+    : Runnable("WorkletThread::PrimaryRunnable")
+    , mWorkletThread(aWorkletThread)
   {
     MOZ_ASSERT(aWorkletThread);
     MOZ_ASSERT(NS_IsMainThread());
 
     mParentContext =
       JS_GetParentContext(CycleCollectedJSContext::Get()->Context());
     MOZ_ASSERT(mParentContext);
   }
@@ -242,17 +245,18 @@ private:
   JSContext* mParentContext;
 };
 
 // This is the last runnable to be dispatched. It calls the TerminateInternal()
 class WorkletThread::TerminateRunnable final : public Runnable
 {
 public:
   explicit TerminateRunnable(WorkletThread* aWorkletThread)
-    : mWorkletThread(aWorkletThread)
+    : Runnable("WorkletThread::TerminateRunnable")
+    , mWorkletThread(aWorkletThread)
   {
     MOZ_ASSERT(aWorkletThread);
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   NS_IMETHOD
   Run() override
   {
@@ -260,17 +264,19 @@ public:
     return NS_OK;
   }
 
 private:
   RefPtr<WorkletThread> mWorkletThread;
 };
 
 WorkletThread::WorkletThread()
-  : nsThread(nsThread::NOT_MAIN_THREAD, kWorkletStackSize)
+  : nsThread(MakeNotNull<ThreadEventQueue<mozilla::EventQueue>*>(
+               MakeUnique<mozilla::EventQueue>()),
+             nsThread::NOT_MAIN_THREAD, kWorkletStackSize)
   , mJSContext(nullptr)
 {
 }
 
 WorkletThread::~WorkletThread()
 {
   // This should be gone during the termination step.
   MOZ_ASSERT(!mJSContext);
@@ -377,17 +383,18 @@ WorkletThread::Terminate()
 void
 WorkletThread::TerminateInternal()
 {
   AssertIsOnWorkletThread();
 
   mJSContext = nullptr;
 
   nsCOMPtr<nsIRunnable> runnable =
-    NewRunnableMethod(this, &WorkletThread::Shutdown);
+    NewRunnableMethod("WorkletThread::Shutdown", this,
+                      &WorkletThread::Shutdown);
   NS_DispatchToMainThread(runnable);
 }
 
 JSContext*
 WorkletThread::GetJSContext() const
 {
   AssertIsOnWorkletThread();
   MOZ_ASSERT(mJSContext);
--- a/dom/worklet/WorkletThread.h
+++ b/dom/worklet/WorkletThread.h
@@ -8,18 +8,18 @@
 #define mozilla_dom_worklet_WorkletThread_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/CondVar.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "nsThread.h"
 
-class JSContext;
-class JSPrincipals;
+struct JSContext;
+struct JSPrincipals;
 class nsIRunnable;
 
 namespace mozilla {
 namespace dom {
 
 class WorkletThread final : public nsThread
 {
 public: