зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a59d382a7950 (bug 1611046) for bustages on nsCodeCoverage.cpp
This commit is contained in:
Родитель
c0b98009fc
Коммит
18ef916675
|
@ -107,7 +107,6 @@
|
|||
#include "mozilla/dom/PushNotifier.h"
|
||||
#include "mozilla/dom/SHEntryParent.h"
|
||||
#include "mozilla/dom/SHistoryParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrar.h"
|
||||
#include "mozilla/dom/ServiceWorkerUtils.h"
|
||||
#include "mozilla/dom/StorageIPC.h"
|
||||
|
@ -6380,16 +6379,6 @@ PFileDescriptorSetParent* ContentParent::SendPFileDescriptorSetConstructor(
|
|||
return PContentParent::SendPFileDescriptorSetConstructor(aFD);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvReportServiceWorkerShutdownProgress(
|
||||
uint32_t aShutdownStateId, ServiceWorkerShutdownState::Progress aProgress) {
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
MOZ_RELEASE_ASSERT(swm, "ServiceWorkers should shutdown before SWM.");
|
||||
|
||||
swm->ReportServiceWorkerShutdownProgress(aShutdownStateId, aProgress);
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvCommitWindowContextTransaction(
|
||||
WindowContext* aContext, WindowContext::BaseTransaction&& aTransaction,
|
||||
uint64_t aEpoch) {
|
||||
|
|
|
@ -1236,10 +1236,6 @@ class ContentParent final
|
|||
const nsACString& aOriginKey, const nsTArray<KeyValuePair>& aDefaultData,
|
||||
const nsTArray<KeyValuePair>& aSessionData);
|
||||
|
||||
mozilla::ipc::IPCResult RecvReportServiceWorkerShutdownProgress(
|
||||
uint32_t aShutdownStateId,
|
||||
ServiceWorkerShutdownState::Progress aProgress);
|
||||
|
||||
// Notify the ContentChild to enable the input event prioritization when
|
||||
// initializing.
|
||||
void MaybeEnableRemoteInputEventQueue();
|
||||
|
|
|
@ -121,7 +121,6 @@ using gfxSparseBitSet from "gfxFontUtils.h";
|
|||
using mozilla::dom::MediaControlKeysEvent from "ipc/MediaControlIPC.h";
|
||||
using mozilla::dom::ControlledMediaState from "ipc/MediaControlIPC.h";
|
||||
using refcounted class nsDocShellLoadState from "nsDocShellLoadState.h";
|
||||
using mozilla::dom::ServiceWorkerShutdownState::Progress from "mozilla/dom/ServiceWorkerShutdownState.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
{
|
||||
|
@ -1525,15 +1524,6 @@ parent:
|
|||
async GetModulesTrust(ModulePaths aModPaths, bool aRunAtNormalPriority)
|
||||
returns (ModulesMapResult? modMapResult);
|
||||
|
||||
/**
|
||||
* Used to route shutdown diagnostic info from the content process
|
||||
* ServiceWorkers to the parent process' ServiceWorkerManager's
|
||||
* ServiceWorkerShutdownBlocker. (The only other actor chain available
|
||||
* for this would be very convoluted and create ordering problems).
|
||||
*/
|
||||
async ReportServiceWorkerShutdownProgress(uint32_t aShutdownStateId,
|
||||
Progress aProgress);
|
||||
|
||||
both:
|
||||
async ScriptError(nsString message, nsString sourceName, nsString sourceLine,
|
||||
uint32_t lineNumber, uint32_t colNumber, uint32_t flags,
|
||||
|
|
|
@ -322,8 +322,8 @@ ServiceWorkerManager::~ServiceWorkerManager() {
|
|||
}
|
||||
}
|
||||
|
||||
void ServiceWorkerManager::BlockShutdownOn(GenericNonExclusivePromise* aPromise,
|
||||
uint32_t aShutdownStateId) {
|
||||
void ServiceWorkerManager::BlockShutdownOn(
|
||||
GenericNonExclusivePromise* aPromise) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
// This may be called when in non-e10s mode with parent-intercept enabled.
|
||||
|
@ -334,7 +334,7 @@ void ServiceWorkerManager::BlockShutdownOn(GenericNonExclusivePromise* aPromise,
|
|||
MOZ_ASSERT(mShutdownBlocker);
|
||||
MOZ_ASSERT(aPromise);
|
||||
|
||||
mShutdownBlocker->WaitOnPromise(aPromise, aShutdownStateId);
|
||||
mShutdownBlocker->WaitOnPromise(aPromise);
|
||||
}
|
||||
|
||||
void ServiceWorkerManager::Init(ServiceWorkerRegistrar* aRegistrar) {
|
||||
|
@ -3145,20 +3145,5 @@ void ServiceWorkerManager::RemoveOrphanedRegistration(
|
|||
mOrphanedRegistrations.remove(aRegistration);
|
||||
}
|
||||
|
||||
uint32_t ServiceWorkerManager::MaybeInitServiceWorkerShutdownProgress() const {
|
||||
if (!mShutdownBlocker) {
|
||||
return ServiceWorkerShutdownBlocker::kInvalidShutdownStateId;
|
||||
}
|
||||
|
||||
return mShutdownBlocker->CreateShutdownState();
|
||||
}
|
||||
|
||||
void ServiceWorkerManager::ReportServiceWorkerShutdownProgress(
|
||||
uint32_t aShutdownStateId,
|
||||
ServiceWorkerShutdownState::Progress aProgress) const {
|
||||
MOZ_ASSERT(mShutdownBlocker);
|
||||
mShutdownBlocker->ReportShutdownProgress(aShutdownStateId, aProgress);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "nsIServiceWorkerManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "ServiceWorkerShutdownState.h"
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
|
@ -276,8 +275,7 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
|||
void NoteInheritedController(const ClientInfo& aClientInfo,
|
||||
const ServiceWorkerDescriptor& aController);
|
||||
|
||||
void BlockShutdownOn(GenericNonExclusivePromise* aPromise,
|
||||
uint32_t aShutdownStateId);
|
||||
void BlockShutdownOn(GenericNonExclusivePromise* aPromise);
|
||||
|
||||
nsresult GetClientRegistration(
|
||||
const ClientInfo& aClientInfo,
|
||||
|
@ -287,14 +285,6 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
|||
const ClientInfo& aNewClientInfo,
|
||||
const ServiceWorkerDescriptor& aServiceWorker);
|
||||
|
||||
// Returns the shutdown state ID (may be an invalid ID if an
|
||||
// nsIAsyncShutdownBlocker is not used).
|
||||
uint32_t MaybeInitServiceWorkerShutdownProgress() const;
|
||||
|
||||
void ReportServiceWorkerShutdownProgress(
|
||||
uint32_t aShutdownStateId,
|
||||
ServiceWorkerShutdownState::Progress aProgress) const;
|
||||
|
||||
private:
|
||||
struct RegistrationDataPerPrincipal;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "ServiceWorkerCloneData.h"
|
||||
#include "ServiceWorkerShutdownState.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/CycleCollectedJSContext.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
@ -334,8 +333,6 @@ bool ServiceWorkerOp::MaybeStart(RemoteWorkerChild* aOwner,
|
|||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[self](
|
||||
const GenericNonExclusivePromise::ResolveOrRejectValue& aResult) {
|
||||
MaybeReportServiceWorkerShutdownProgress(self->mArgs, true);
|
||||
|
||||
MOZ_ASSERT(!self->mPromiseHolder.IsEmpty());
|
||||
|
||||
if (NS_WARN_IF(aResult.IsReject())) {
|
||||
|
@ -351,8 +348,6 @@ bool ServiceWorkerOp::MaybeStart(RemoteWorkerChild* aOwner,
|
|||
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
__func__, [self = std::move(self), owner = std::move(owner)]() mutable {
|
||||
MaybeReportServiceWorkerShutdownProgress(self->mArgs);
|
||||
|
||||
auto lock = owner->mState.Lock();
|
||||
auto& state = lock.ref();
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@ struct ServiceWorkerUpdateStateOpArgs {
|
|||
ServiceWorkerState state;
|
||||
};
|
||||
|
||||
struct ServiceWorkerTerminateWorkerOpArgs {
|
||||
uint32_t shutdownStateId;
|
||||
};
|
||||
struct ServiceWorkerTerminateWorkerOpArgs {};
|
||||
|
||||
struct ServiceWorkerLifeCycleEventOpArgs {
|
||||
nsString eventName;
|
||||
|
|
|
@ -376,15 +376,12 @@ nsresult ServiceWorkerPrivateImpl::CheckScriptEvaluation(
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<GenericNonExclusivePromise> promise = self->ShutdownInternal();
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
MOZ_ASSERT(swm);
|
||||
|
||||
auto shutdownStateId = swm->MaybeInitServiceWorkerShutdownProgress();
|
||||
|
||||
RefPtr<GenericNonExclusivePromise> promise =
|
||||
self->ShutdownInternal(shutdownStateId);
|
||||
|
||||
swm->BlockShutdownOn(promise, shutdownStateId);
|
||||
swm->BlockShutdownOn(promise);
|
||||
|
||||
promise->Then(
|
||||
GetCurrentThreadSerialEventTarget(), __func__,
|
||||
|
@ -677,18 +674,15 @@ void ServiceWorkerPrivateImpl::Shutdown() {
|
|||
"All Service Workers should start shutting down before the "
|
||||
"ServiceWorkerManager does!");
|
||||
|
||||
auto shutdownStateId = swm->MaybeInitServiceWorkerShutdownProgress();
|
||||
|
||||
RefPtr<GenericNonExclusivePromise> promise =
|
||||
ShutdownInternal(shutdownStateId);
|
||||
swm->BlockShutdownOn(promise, shutdownStateId);
|
||||
RefPtr<GenericNonExclusivePromise> promise = ShutdownInternal();
|
||||
swm->BlockShutdownOn(promise);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(WorkerIsDead());
|
||||
}
|
||||
|
||||
RefPtr<GenericNonExclusivePromise> ServiceWorkerPrivateImpl::ShutdownInternal(
|
||||
uint32_t aShutdownStateId) {
|
||||
RefPtr<GenericNonExclusivePromise>
|
||||
ServiceWorkerPrivateImpl::ShutdownInternal() {
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(mControllerChild);
|
||||
|
||||
|
@ -707,7 +701,7 @@ RefPtr<GenericNonExclusivePromise> ServiceWorkerPrivateImpl::ShutdownInternal(
|
|||
new GenericNonExclusivePromise::Private(__func__);
|
||||
|
||||
Unused << ExecServiceWorkerOp(
|
||||
ServiceWorkerTerminateWorkerOpArgs(aShutdownStateId),
|
||||
ServiceWorkerTerminateWorkerOpArgs(),
|
||||
[promise](ServiceWorkerOpResult&& aResult) {
|
||||
MOZ_ASSERT(aResult.type() == ServiceWorkerOpResult::Tnsresult);
|
||||
promise->Resolve(true, __func__);
|
||||
|
|
|
@ -123,8 +123,7 @@ class ServiceWorkerPrivateImpl final : public ServiceWorkerPrivate::Inner,
|
|||
|
||||
void Shutdown();
|
||||
|
||||
RefPtr<GenericNonExclusivePromise> ShutdownInternal(
|
||||
uint32_t aShutdownStateId);
|
||||
RefPtr<GenericNonExclusivePromise> ShutdownInternal();
|
||||
|
||||
nsresult ExecServiceWorkerOp(
|
||||
ServiceWorkerOpArgs&& aArgs,
|
||||
|
|
|
@ -64,20 +64,6 @@ NS_IMETHODIMP ServiceWorkerShutdownBlocker::GetState(nsIPropertyBag** aBagOut) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsAutoCString shutdownStates;
|
||||
|
||||
for (auto iter = mShutdownStates.iter(); !iter.done(); iter.next()) {
|
||||
shutdownStates.Append(iter.get().value().GetProgressString());
|
||||
shutdownStates.Append(", ");
|
||||
}
|
||||
|
||||
rv = propertyBag->SetPropertyAsACString(NS_LITERAL_STRING("shutdownStates"),
|
||||
shutdownStates);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
propertyBag.forget(aBagOut);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -104,22 +90,18 @@ ServiceWorkerShutdownBlocker::CreateAndRegisterOn(
|
|||
}
|
||||
|
||||
void ServiceWorkerShutdownBlocker::WaitOnPromise(
|
||||
GenericNonExclusivePromise* aPromise, uint32_t aShutdownStateId) {
|
||||
GenericNonExclusivePromise* aPromise) {
|
||||
AssertIsOnMainThread();
|
||||
MOZ_DIAGNOSTIC_ASSERT(IsAcceptingPromises());
|
||||
MOZ_ASSERT(aPromise);
|
||||
MOZ_ASSERT(mShutdownStates.has(aShutdownStateId));
|
||||
|
||||
++mState.as<AcceptingPromises>().mPendingPromises;
|
||||
|
||||
RefPtr<ServiceWorkerShutdownBlocker> self = this;
|
||||
|
||||
aPromise->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[self = std::move(self), shutdownStateId = aShutdownStateId](
|
||||
[self = std::move(self)](
|
||||
const GenericNonExclusivePromise::ResolveOrRejectValue&) {
|
||||
// Progress reporting might race with aPromise settling.
|
||||
self->mShutdownStates.remove(shutdownStateId);
|
||||
|
||||
if (!self->PromiseSettled()) {
|
||||
self->MaybeUnblockShutdown();
|
||||
}
|
||||
|
@ -133,38 +115,6 @@ void ServiceWorkerShutdownBlocker::StopAcceptingPromises() {
|
|||
mState = AsVariant(NotAcceptingPromises(mState.as<AcceptingPromises>()));
|
||||
}
|
||||
|
||||
uint32_t ServiceWorkerShutdownBlocker::CreateShutdownState() {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
static uint32_t nextShutdownStateId = 1;
|
||||
|
||||
MOZ_ALWAYS_TRUE(mShutdownStates.putNew(nextShutdownStateId,
|
||||
ServiceWorkerShutdownState()));
|
||||
|
||||
return nextShutdownStateId++;
|
||||
}
|
||||
|
||||
void ServiceWorkerShutdownBlocker::ReportShutdownProgress(
|
||||
uint32_t aShutdownStateId, Progress aProgress) {
|
||||
AssertIsOnMainThread();
|
||||
MOZ_RELEASE_ASSERT(aShutdownStateId != kInvalidShutdownStateId);
|
||||
|
||||
auto lookup = mShutdownStates.lookup(aShutdownStateId);
|
||||
|
||||
// Progress reporting might race with the promise that WaitOnPromise is called
|
||||
// with settling.
|
||||
if (!lookup) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This will check for a valid progress transition with assertions.
|
||||
lookup->value().SetProgress(aProgress);
|
||||
|
||||
if (aProgress == Progress::ShutdownCompleted) {
|
||||
mShutdownStates.remove(lookup);
|
||||
}
|
||||
}
|
||||
|
||||
ServiceWorkerShutdownBlocker::ServiceWorkerShutdownBlocker()
|
||||
: mState(VariantType<AcceptingPromises>()) {
|
||||
AssertIsOnMainThread();
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
#include "nsIAsyncShutdown.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
#include "ServiceWorkerShutdownState.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/HashTable.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -23,9 +21,6 @@ namespace dom {
|
|||
*/
|
||||
class ServiceWorkerShutdownBlocker final : public nsIAsyncShutdownBlocker {
|
||||
public:
|
||||
using Progress = ServiceWorkerShutdownState::Progress;
|
||||
static const uint32_t kInvalidShutdownStateId = 0;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIASYNCSHUTDOWNBLOCKER
|
||||
|
||||
|
@ -42,12 +37,8 @@ class ServiceWorkerShutdownBlocker final : public nsIAsyncShutdownBlocker {
|
|||
* Can be called multiple times, and shutdown will be blocked until all the
|
||||
* calls' promises settle, but all of these calls must happen before
|
||||
* `StopAcceptingPromises()` is called (assertions will enforce this).
|
||||
*
|
||||
* See `CreateShutdownState` for aShutdownStateId, which is needed to clear
|
||||
* the shutdown state if the shutdown process aborts for some reason.
|
||||
*/
|
||||
void WaitOnPromise(GenericNonExclusivePromise* aPromise,
|
||||
uint32_t aShutdownStateId);
|
||||
void WaitOnPromise(GenericNonExclusivePromise* aPromise);
|
||||
|
||||
/**
|
||||
* Once this is called, shutdown will be blocked until all promises
|
||||
|
@ -56,17 +47,6 @@ class ServiceWorkerShutdownBlocker final : public nsIAsyncShutdownBlocker {
|
|||
*/
|
||||
void StopAcceptingPromises();
|
||||
|
||||
/**
|
||||
* Start tracking the shutdown of an individual ServiceWorker for hang
|
||||
* reporting purposes. Returns a "shutdown state ID" that should be used
|
||||
* in subsequent calls to ReportShutdownProgress. The shutdown of an
|
||||
* individual ServiceWorker is presumed to be completed when its `Progress`
|
||||
* reaches `Progress::ShutdownCompleted`.
|
||||
*/
|
||||
uint32_t CreateShutdownState();
|
||||
|
||||
void ReportShutdownProgress(uint32_t aShutdownStateId, Progress aProgress);
|
||||
|
||||
private:
|
||||
ServiceWorkerShutdownBlocker();
|
||||
|
||||
|
@ -104,8 +84,6 @@ class ServiceWorkerShutdownBlocker final : public nsIAsyncShutdownBlocker {
|
|||
Variant<AcceptingPromises, NotAcceptingPromises> mState;
|
||||
|
||||
nsCOMPtr<nsIAsyncShutdownClient> mShutdownClient;
|
||||
|
||||
HashMap<uint32_t, ServiceWorkerShutdownState> mShutdownStates;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "ServiceWorkerShutdownState.h"
|
||||
|
||||
#include <array>
|
||||
#include <type_traits>
|
||||
|
||||
#include "MainThreadUtils.h"
|
||||
#include "ServiceWorkerUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/RemoteWorkerService.h"
|
||||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
#include "mozilla/dom/WorkerCommon.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using Progress = ServiceWorkerShutdownState::Progress;
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr inline auto UnderlyingProgressValue(Progress aProgress) {
|
||||
return std::underlying_type_t<Progress>(aProgress);
|
||||
}
|
||||
|
||||
constexpr std::array<const char*, UnderlyingProgressValue(Progress::EndGuard_)>
|
||||
gProgressStrings = {{
|
||||
// clang-format off
|
||||
"parent process main thread",
|
||||
"parent process IPDL background thread",
|
||||
"content process worker launcher thread",
|
||||
"content process main thread",
|
||||
"shutdown completed"
|
||||
// clang-format on
|
||||
}};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
ServiceWorkerShutdownState::ServiceWorkerShutdownState()
|
||||
: mProgress(Progress::ParentProcessMainThread) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
ServiceWorkerShutdownState::~ServiceWorkerShutdownState() {
|
||||
Unused << NS_WARN_IF(mProgress != Progress::ShutdownCompleted);
|
||||
}
|
||||
|
||||
const char* ServiceWorkerShutdownState::GetProgressString() const {
|
||||
return gProgressStrings[UnderlyingProgressValue(mProgress)];
|
||||
}
|
||||
|
||||
void ServiceWorkerShutdownState::SetProgress(Progress aProgress) {
|
||||
MOZ_ASSERT(aProgress != Progress::EndGuard_);
|
||||
MOZ_RELEASE_ASSERT(UnderlyingProgressValue(mProgress) + 1 ==
|
||||
UnderlyingProgressValue(aProgress));
|
||||
|
||||
mProgress = aProgress;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void ReportProgressToServiceWorkerManager(uint32_t aShutdownStateId,
|
||||
Progress aProgress) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
MOZ_RELEASE_ASSERT(swm, "ServiceWorkers should shutdown before SWM.");
|
||||
|
||||
swm->ReportServiceWorkerShutdownProgress(aShutdownStateId, aProgress);
|
||||
}
|
||||
|
||||
void ReportProgressToParentProcess(uint32_t aShutdownStateId,
|
||||
Progress aProgress) {
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
ContentChild* contentChild = ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(contentChild);
|
||||
|
||||
contentChild->SendReportServiceWorkerShutdownProgress(aShutdownStateId,
|
||||
aProgress);
|
||||
}
|
||||
|
||||
void ReportServiceWorkerShutdownProgress(uint32_t aShutdownStateId,
|
||||
Progress aProgress) {
|
||||
MOZ_ASSERT(UnderlyingProgressValue(Progress::ParentProcessMainThread) <
|
||||
UnderlyingProgressValue(aProgress));
|
||||
MOZ_ASSERT(UnderlyingProgressValue(aProgress) <
|
||||
UnderlyingProgressValue(Progress::EndGuard_));
|
||||
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
__func__, [shutdownStateId = aShutdownStateId, progress = aProgress] {
|
||||
if (XRE_IsParentProcess()) {
|
||||
ReportProgressToServiceWorkerManager(shutdownStateId, progress);
|
||||
} else {
|
||||
ReportProgressToParentProcess(shutdownStateId, progress);
|
||||
}
|
||||
});
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
MOZ_ALWAYS_SUCCEEDS(r->Run());
|
||||
} else {
|
||||
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget()));
|
||||
}
|
||||
}
|
||||
|
||||
void ReportServiceWorkerShutdownProgress(uint32_t aShutdownStateId) {
|
||||
Progress progress = Progress::EndGuard_;
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
mozilla::ipc::AssertIsOnBackgroundThread();
|
||||
|
||||
progress = Progress::ParentProcessIpdlBackgroundThread;
|
||||
} else {
|
||||
if (NS_IsMainThread()) {
|
||||
progress = Progress::ContentProcessMainThread;
|
||||
} else {
|
||||
MOZ_ASSERT(RemoteWorkerService::Thread()->IsOnCurrentThread());
|
||||
progress = Progress::ContentProcessWorkerLauncherThread;
|
||||
}
|
||||
}
|
||||
|
||||
ReportServiceWorkerShutdownProgress(aShutdownStateId, progress);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void MaybeReportServiceWorkerShutdownProgress(const ServiceWorkerOpArgs& aArgs,
|
||||
bool aShutdownCompleted) {
|
||||
if (!ServiceWorkerParentInterceptEnabled() ||
|
||||
(XRE_IsParentProcess() && !XRE_IsE10sParentProcess())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aShutdownCompleted) {
|
||||
MOZ_ASSERT(aArgs.type() ==
|
||||
ServiceWorkerOpArgs::TServiceWorkerTerminateWorkerOpArgs);
|
||||
|
||||
ReportServiceWorkerShutdownProgress(
|
||||
aArgs.get_ServiceWorkerTerminateWorkerOpArgs().shutdownStateId(),
|
||||
Progress::ShutdownCompleted);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (aArgs.type() ==
|
||||
ServiceWorkerOpArgs::TServiceWorkerTerminateWorkerOpArgs) {
|
||||
ReportServiceWorkerShutdownProgress(
|
||||
aArgs.get_ServiceWorkerTerminateWorkerOpArgs().shutdownStateId());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,63 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef DOM_SERVICEWORKERS_SERVICEWORKERSHUTDOWNSTATE_H_
|
||||
#define DOM_SERVICEWORKERS_SERVICEWORKERSHUTDOWNSTATE_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/dom/ServiceWorkerOpArgs.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ServiceWorkerShutdownState {
|
||||
public:
|
||||
// Represents the "location" of the shutdown message or completion of
|
||||
// shutdown.
|
||||
enum class Progress {
|
||||
ParentProcessMainThread,
|
||||
ParentProcessIpdlBackgroundThread,
|
||||
ContentProcessWorkerLauncherThread,
|
||||
ContentProcessMainThread,
|
||||
ShutdownCompleted,
|
||||
EndGuard_,
|
||||
};
|
||||
|
||||
ServiceWorkerShutdownState();
|
||||
|
||||
~ServiceWorkerShutdownState();
|
||||
|
||||
const char* GetProgressString() const;
|
||||
|
||||
void SetProgress(Progress aProgress);
|
||||
|
||||
private:
|
||||
Progress mProgress;
|
||||
};
|
||||
|
||||
// Asynchronously reports that shutdown has progressed to the calling thread
|
||||
// if aArgs is for shutdown. If aShutdownCompleted is true, aArgs must be for
|
||||
// shutdown.
|
||||
void MaybeReportServiceWorkerShutdownProgress(const ServiceWorkerOpArgs& aArgs,
|
||||
bool aShutdownCompleted = false);
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
namespace IPC {
|
||||
|
||||
using Progress = mozilla::dom::ServiceWorkerShutdownState::Progress;
|
||||
|
||||
template <>
|
||||
struct ParamTraits<Progress>
|
||||
: public ContiguousEnumSerializer<
|
||||
Progress, Progress::ParentProcessMainThread, Progress::EndGuard_> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // DOM_SERVICEWORKERS_SERVICEWORKERSHUTDOWNSTATE_H_
|
|
@ -31,7 +31,6 @@ EXPORTS.mozilla.dom += [
|
|||
'ServiceWorkerRegistration.h',
|
||||
'ServiceWorkerRegistrationDescriptor.h',
|
||||
'ServiceWorkerRegistrationInfo.h',
|
||||
'ServiceWorkerShutdownState.h',
|
||||
'ServiceWorkerUtils.h',
|
||||
]
|
||||
|
||||
|
@ -79,7 +78,6 @@ UNIFIED_SOURCES += [
|
|||
'ServiceWorkerRegistrationProxy.cpp',
|
||||
'ServiceWorkerScriptCache.cpp',
|
||||
'ServiceWorkerShutdownBlocker.cpp',
|
||||
'ServiceWorkerShutdownState.cpp',
|
||||
'ServiceWorkerUnregisterCallback.cpp',
|
||||
'ServiceWorkerUnregisterJob.cpp',
|
||||
'ServiceWorkerUpdateJob.cpp',
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "mozilla/dom/ServiceWorkerInterceptController.h"
|
||||
#include "mozilla/dom/ServiceWorkerOp.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
||||
#include "mozilla/dom/ServiceWorkerShutdownState.h"
|
||||
#include "mozilla/dom/ServiceWorkerUtils.h"
|
||||
#include "mozilla/dom/workerinternals/ScriptLoader.h"
|
||||
#include "mozilla/dom/WorkerError.h"
|
||||
|
@ -995,8 +994,6 @@ IPCResult RemoteWorkerChild::RecvExecServiceWorkerOp(
|
|||
aArgs.type() != ServiceWorkerOpArgs::TServiceWorkerFetchEventOpArgs,
|
||||
"FetchEvent operations should be sent via PFetchEventOp(Proxy) actors!");
|
||||
|
||||
MaybeReportServiceWorkerShutdownProgress(aArgs);
|
||||
|
||||
MaybeStartOp(ServiceWorkerOp::Create(aArgs, std::move(aResolve)));
|
||||
|
||||
return IPC_OK();
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/FetchEventOpParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerOpPromise.h"
|
||||
#include "mozilla/dom/ServiceWorkerShutdownState.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -102,8 +101,6 @@ IPCResult RemoteWorkerControllerParent::RecvExecServiceWorkerOp(
|
|||
MOZ_ASSERT(mIPCActive);
|
||||
MOZ_ASSERT(mRemoteWorkerController);
|
||||
|
||||
MaybeReportServiceWorkerShutdownProgress(aArgs);
|
||||
|
||||
mRemoteWorkerController->ExecServiceWorkerOp(std::move(aArgs))
|
||||
->Then(GetCurrentThreadSerialEventTarget(), __func__,
|
||||
[resolve = std::move(aResolve)](
|
||||
|
|
Загрузка…
Ссылка в новой задаче