Bug 1231213 - Let ServiceWorkerOpArgs be sent from the parent process to a content process. r=asuth

The args are sent from the parent process main thread to the parent process
background thread and then from the background thread to a content process
worker launcher thread.

Differential Revision: https://phabricator.services.mozilla.com/D26173

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Perry Jiang 2019-08-13 04:57:47 +00:00
Родитель be36c41e08
Коммит b750acd163
8 изменённых файлов: 81 добавлений и 0 удалений

Просмотреть файл

@ -75,6 +75,9 @@ child:
async __delete__(); async __delete__();
async ExecOp(RemoteWorkerOp op); async ExecOp(RemoteWorkerOp op);
async ExecServiceWorkerOp(ServiceWorkerOpArgs aArgs)
returns (ServiceWorkerOpResult aResult);
}; };
} // namespace dom } // namespace dom

Просмотреть файл

@ -32,6 +32,8 @@ protocol PRemoteWorkerController {
async Shutdown() returns (bool aOk); async Shutdown() returns (bool aOk);
async ExecServiceWorkerOp(ServiceWorkerOpArgs aArgs)
returns (ServiceWorkerOpResult aResult);
}; };
} // namespace dom } // namespace dom

Просмотреть файл

@ -34,6 +34,7 @@
#include "mozilla/dom/RemoteWorkerTypes.h" #include "mozilla/dom/RemoteWorkerTypes.h"
#include "mozilla/dom/ServiceWorkerDescriptor.h" #include "mozilla/dom/ServiceWorkerDescriptor.h"
#include "mozilla/dom/ServiceWorkerInterceptController.h" #include "mozilla/dom/ServiceWorkerInterceptController.h"
#include "mozilla/dom/ServiceWorkerOp.h"
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h" #include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
#include "mozilla/dom/ServiceWorkerUtils.h" #include "mozilla/dom/ServiceWorkerUtils.h"
#include "mozilla/dom/workerinternals/ScriptLoader.h" #include "mozilla/dom/workerinternals/ScriptLoader.h"
@ -914,6 +915,18 @@ IPCResult RemoteWorkerChild::RecvExecOp(RemoteWorkerOp&& aOp) {
return IPC_OK(); return IPC_OK();
} }
IPCResult RemoteWorkerChild::RecvExecServiceWorkerOp(
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve) {
MOZ_ASSERT(mIsServiceWorker);
MOZ_ASSERT(
aArgs.type() != ServiceWorkerOpArgs::TServiceWorkerFetchEventOpArgs,
"FetchEvent operations should be sent via PFetchEventOp(Proxy) actors!");
MaybeStartOp(ServiceWorkerOp::Create(aArgs, std::move(aResolve)));
return IPC_OK();
}
/** /**
* PFetchEventOpProxy methods * PFetchEventOpProxy methods
*/ */

Просмотреть файл

@ -105,6 +105,9 @@ class RemoteWorkerChild final
mozilla::ipc::IPCResult RecvExecOp(RemoteWorkerOp&& aOp); mozilla::ipc::IPCResult RecvExecOp(RemoteWorkerOp&& aOp);
mozilla::ipc::IPCResult RecvExecServiceWorkerOp(
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve);
PFetchEventOpProxyChild* AllocPFetchEventOpProxyChild( PFetchEventOpProxyChild* AllocPFetchEventOpProxyChild(
const ServiceWorkerFetchEventOpArgs& aArgs); const ServiceWorkerFetchEventOpArgs& aArgs);

Просмотреть файл

@ -260,6 +260,24 @@ void RemoteWorkerController::Thaw() {
MaybeStartSharedWorkerOp(PendingSharedWorkerOp::eThaw); MaybeStartSharedWorkerOp(PendingSharedWorkerOp::eThaw);
} }
RefPtr<ServiceWorkerOpPromise> RemoteWorkerController::ExecServiceWorkerOp(
ServiceWorkerOpArgs&& aArgs) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(mIsServiceWorker);
RefPtr<ServiceWorkerOpPromise::Private> promise =
new ServiceWorkerOpPromise::Private(__func__);
UniquePtr<PendingServiceWorkerOp> op =
MakeUnique<PendingServiceWorkerOp>(std::move(aArgs), promise);
if (!op->MaybeStart(this)) {
mPendingOps.AppendElement(std::move(op));
}
return promise;
}
RemoteWorkerController::PendingSharedWorkerOp::PendingSharedWorkerOp( RemoteWorkerController::PendingSharedWorkerOp::PendingSharedWorkerOp(
Type aType, uint64_t aWindowID) Type aType, uint64_t aWindowID)
: mType(aType), mWindowID(aWindowID) { : mType(aType), mWindowID(aWindowID) {
@ -403,6 +421,19 @@ bool RemoteWorkerController::PendingServiceWorkerOp::MaybeStart(
mArgs = std::move(copyArgs); mArgs = std::move(copyArgs);
} }
aOwner->mActor->SendExecServiceWorkerOp(mArgs)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[promise = std::move(mPromise)](
PRemoteWorkerParent::ExecServiceWorkerOpPromise::
ResolveOrRejectValue&& aResult) {
if (NS_WARN_IF(aResult.IsReject())) {
promise->Reject(NS_ERROR_DOM_ABORT_ERR, __func__);
return;
}
promise->Resolve(std::move(aResult.ResolveValue()), __func__);
});
return true; return true;
} }

Просмотреть файл

@ -132,6 +132,9 @@ class RemoteWorkerController final {
void Thaw(); void Thaw();
RefPtr<ServiceWorkerOpPromise> ExecServiceWorkerOp(
ServiceWorkerOpArgs&& aArgs);
private: private:
RemoteWorkerController(const RemoteWorkerData& aData, RemoteWorkerController(const RemoteWorkerData& aData,
RemoteWorkerObserver* aObserver); RemoteWorkerObserver* aObserver);

Просмотреть файл

@ -16,6 +16,7 @@
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/dom/FetchEventOpParent.h" #include "mozilla/dom/FetchEventOpParent.h"
#include "mozilla/dom/ServiceWorkerOpPromise.h"
#include "mozilla/ipc/BackgroundParent.h" #include "mozilla/ipc/BackgroundParent.h"
namespace mozilla { namespace mozilla {
@ -75,6 +76,28 @@ bool RemoteWorkerControllerParent::DeallocPFetchEventOpParent(
return true; return true;
} }
IPCResult RemoteWorkerControllerParent::RecvExecServiceWorkerOp(
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(mIPCActive);
MOZ_ASSERT(mRemoteWorkerController);
mRemoteWorkerController->ExecServiceWorkerOp(std::move(aArgs))
->Then(GetCurrentThreadSerialEventTarget(), __func__,
[resolve = std::move(aResolve)](
ServiceWorkerOpPromise::ResolveOrRejectValue&& aResult) {
if (NS_WARN_IF(aResult.IsReject())) {
MOZ_ASSERT(NS_FAILED(aResult.RejectValue()));
resolve(aResult.RejectValue());
return;
}
resolve(aResult.ResolveValue());
});
return IPC_OK();
}
IPCResult RemoteWorkerControllerParent::RecvShutdown( IPCResult RemoteWorkerControllerParent::RecvShutdown(
ShutdownResolver&& aResolve) { ShutdownResolver&& aResolve) {
AssertIsOnBackgroundThread(); AssertIsOnBackgroundThread();

Просмотреть файл

@ -43,6 +43,9 @@ class RemoteWorkerControllerParent final : public PRemoteWorkerControllerParent,
bool DeallocPFetchEventOpParent(PFetchEventOpParent* aActor); bool DeallocPFetchEventOpParent(PFetchEventOpParent* aActor);
mozilla::ipc::IPCResult RecvExecServiceWorkerOp(
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve);
mozilla::ipc::IPCResult RecvShutdown(ShutdownResolver&& aResolve); mozilla::ipc::IPCResult RecvShutdown(ShutdownResolver&& aResolve);
mozilla::ipc::IPCResult Recv__delete__() override; mozilla::ipc::IPCResult Recv__delete__() override;