RemoteWorkerNonLifeCycleOpControllerParent.cpp (1429B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #include "RemoteWorkerNonLifeCycleOpControllerParent.h" 6 7 #include "mozilla/dom/RemoteWorkerController.h" 8 9 namespace mozilla::dom { 10 11 RemoteWorkerNonLifeCycleOpControllerParent:: 12 RemoteWorkerNonLifeCycleOpControllerParent( 13 RemoteWorkerController* aController) 14 : mController(aController) { 15 MOZ_ASSERT(mController); 16 } 17 18 RemoteWorkerNonLifeCycleOpControllerParent:: 19 ~RemoteWorkerNonLifeCycleOpControllerParent() = default; 20 21 void RemoteWorkerNonLifeCycleOpControllerParent::Shutdown() { 22 if (CanSend()) { 23 (void)SendShutdown(); 24 } 25 if (mController) { 26 mController = nullptr; 27 } 28 if (GetIPCChannel()) { 29 GetIPCChannel()->Close(); 30 } 31 } 32 33 IPCResult RemoteWorkerNonLifeCycleOpControllerParent::RecvTerminated() { 34 // mController could be nullptr when the controller had already shutted down. 35 if (mController) { 36 mController->mNonLifeCycleOpController = nullptr; 37 mController = nullptr; 38 } 39 40 if (GetIPCChannel()) { 41 GetIPCChannel()->Close(); 42 } 43 44 return IPC_OK(); 45 } 46 47 IPCResult RemoteWorkerNonLifeCycleOpControllerParent::RecvError( 48 const ErrorValue& aError) { 49 MOZ_ASSERT(mController); 50 mController->ErrorPropagation(aError); 51 return IPC_OK(); 52 } 53 54 } // namespace mozilla::dom