Bug 1514733 - RemoteWorkerController should be notified when the RemoteWorkerParent actor is dismissed, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 11 Apr 2019 14:35:59 +0000
changeset 469017 5954214372b7ccf56b47d79eb0d6fdb3384455fe
parent 469016 78ed7f9d65666d570e1a87195c1ab5434d588fb8
child 469018 ad202eb740788d8580ed8e1e9b40e85536842b21
push id35856
push usercsabou@mozilla.com
push dateFri, 12 Apr 2019 03:19:48 +0000
treeherdermozilla-central@940684cd1065 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1514733
milestone68.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 1514733 - RemoteWorkerController should be notified when the RemoteWorkerParent actor is dismissed, r=asuth Differential Revision: https://phabricator.services.mozilla.com/D26963
dom/workers/remoteworkers/RemoteWorkerController.cpp
dom/workers/remoteworkers/RemoteWorkerController.h
dom/workers/remoteworkers/RemoteWorkerParent.cpp
--- a/dom/workers/remoteworkers/RemoteWorkerController.cpp
+++ b/dom/workers/remoteworkers/RemoteWorkerController.cpp
@@ -214,16 +214,30 @@ void RemoteWorkerController::AddPortIden
   if (mState == eTerminated) {
     return;
   }
 
   MOZ_ASSERT(mState == eReady);
   Unused << mActor->SendExecOp(RemoteWorkerPortIdentifierOp(aPortIdentifier));
 }
 
+void RemoteWorkerController::ForgetActorAndTerminate() {
+  AssertIsOnBackgroundThread();
+  MOZ_ASSERT(XRE_IsParentProcess());
+
+  // The actor has been destroyed without a proper close() notification. Let's
+  // inform the observer.
+  if (mState == eReady) {
+    mObserver->Terminated();
+  }
+
+  mActor = nullptr;
+  Terminate();
+}
+
 void RemoteWorkerController::Terminate() {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(XRE_IsParentProcess());
 
   if (mState == eTerminated) {
     return;
   }
 
--- a/dom/workers/remoteworkers/RemoteWorkerController.h
+++ b/dom/workers/remoteworkers/RemoteWorkerController.h
@@ -128,16 +128,18 @@ class RemoteWorkerController final {
   ~RemoteWorkerController();
 
   void SetWorkerActor(RemoteWorkerParent* aActor);
 
   void ErrorPropagation(const ErrorValue& aValue);
 
   void WorkerTerminated();
 
+  void ForgetActorAndTerminate();
+
   void Shutdown();
 
   void CreationFailed();
 
   void CreationSucceeded();
 
   RefPtr<RemoteWorkerObserver> mObserver;
   RefPtr<RemoteWorkerParent> mActor;
--- a/dom/workers/remoteworkers/RemoteWorkerParent.cpp
+++ b/dom/workers/remoteworkers/RemoteWorkerParent.cpp
@@ -78,17 +78,20 @@ void RemoteWorkerParent::ActorDestroy(IP
     RefPtr<UnregisterActorRunnable> r =
         new UnregisterActorRunnable(parent.forget());
 
     nsCOMPtr<nsIEventTarget> target =
         SystemGroup::EventTargetFor(TaskCategory::Other);
     target->Dispatch(r.forget(), NS_DISPATCH_NORMAL);
   }
 
-  mController = nullptr;
+  if (mController) {
+    mController->ForgetActorAndTerminate();
+    mController = nullptr;
+  }
 }
 
 IPCResult RemoteWorkerParent::RecvCreated(const bool& aStatus) {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(XRE_IsParentProcess());
 
   if (!mController) {
     return IPC_OK();