зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
d89bee1b4e
Коммит
55f1da5063
|
@ -75,6 +75,9 @@ child:
|
|||
async __delete__();
|
||||
|
||||
async ExecOp(RemoteWorkerOp op);
|
||||
|
||||
async ExecServiceWorkerOp(ServiceWorkerOpArgs aArgs)
|
||||
returns (ServiceWorkerOpResult aResult);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -32,6 +32,8 @@ protocol PRemoteWorkerController {
|
|||
|
||||
async Shutdown() returns (bool aOk);
|
||||
|
||||
async ExecServiceWorkerOp(ServiceWorkerOpArgs aArgs)
|
||||
returns (ServiceWorkerOpResult aResult);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "mozilla/dom/RemoteWorkerTypes.h"
|
||||
#include "mozilla/dom/ServiceWorkerDescriptor.h"
|
||||
#include "mozilla/dom/ServiceWorkerInterceptController.h"
|
||||
#include "mozilla/dom/ServiceWorkerOp.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
||||
#include "mozilla/dom/ServiceWorkerUtils.h"
|
||||
#include "mozilla/dom/workerinternals/ScriptLoader.h"
|
||||
|
@ -923,6 +924,18 @@ IPCResult RemoteWorkerChild::RecvExecOp(RemoteWorkerOp&& aOp) {
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -105,6 +105,9 @@ class RemoteWorkerChild final
|
|||
|
||||
mozilla::ipc::IPCResult RecvExecOp(RemoteWorkerOp&& aOp);
|
||||
|
||||
mozilla::ipc::IPCResult RecvExecServiceWorkerOp(
|
||||
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve);
|
||||
|
||||
PFetchEventOpProxyChild* AllocPFetchEventOpProxyChild(
|
||||
const ServiceWorkerFetchEventOpArgs& aArgs);
|
||||
|
||||
|
|
|
@ -260,6 +260,24 @@ void RemoteWorkerController::Thaw() {
|
|||
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(
|
||||
Type aType, uint64_t aWindowID)
|
||||
: mType(aType), mWindowID(aWindowID) {
|
||||
|
@ -403,6 +421,19 @@ bool RemoteWorkerController::PendingServiceWorkerOp::MaybeStart(
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,9 @@ class RemoteWorkerController final {
|
|||
|
||||
void Thaw();
|
||||
|
||||
RefPtr<ServiceWorkerOpPromise> ExecServiceWorkerOp(
|
||||
ServiceWorkerOpArgs&& aArgs);
|
||||
|
||||
private:
|
||||
RemoteWorkerController(const RemoteWorkerData& aData,
|
||||
RemoteWorkerObserver* aObserver);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/FetchEventOpParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerOpPromise.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -75,6 +76,28 @@ bool RemoteWorkerControllerParent::DeallocPFetchEventOpParent(
|
|||
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(
|
||||
ShutdownResolver&& aResolve) {
|
||||
AssertIsOnBackgroundThread();
|
||||
|
|
|
@ -43,6 +43,9 @@ class RemoteWorkerControllerParent final : public PRemoteWorkerControllerParent,
|
|||
|
||||
bool DeallocPFetchEventOpParent(PFetchEventOpParent* aActor);
|
||||
|
||||
mozilla::ipc::IPCResult RecvExecServiceWorkerOp(
|
||||
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve);
|
||||
|
||||
mozilla::ipc::IPCResult RecvShutdown(ShutdownResolver&& aResolve);
|
||||
|
||||
mozilla::ipc::IPCResult Recv__delete__() override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче