зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1462069) for build bustage on /src/dom/clients/manager/ClientManagerService.cpp on a CLOSED TREE
Backed out changeset 999be9379af3 (bug 1462069) Backed out changeset 457cb3f8a0d9 (bug 1462069) Backed out changeset ec66aff745a8 (bug 1462069)
This commit is contained in:
Родитель
9e0e3a5c87
Коммит
dd2e67b482
|
@ -13,8 +13,6 @@
|
|||
#include "ClientPrincipalUtils.h"
|
||||
#include "ClientSourceParent.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
#include "mozilla/dom/ServiceWorkerUtils.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
|
@ -450,40 +448,6 @@ ClientManagerService::MatchAll(const ClientMatchAllArgs& aArgs)
|
|||
return promiseList->GetResultPromise();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
RefPtr<ClientOpPromise>
|
||||
ClaimOnMainThread(const ClientInfo& aClientInfo,
|
||||
const ServiceWorkerDescriptor& aDescriptor)
|
||||
{
|
||||
RefPtr<ClientOpPromise::Private> promise =
|
||||
new ClientOpPromise::Private(__func__);
|
||||
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(__func__,
|
||||
[promise, clientInfo = Move(aClientInfo), desc = Move(aDescriptor)] () {
|
||||
auto scopeExit = MakeScopeExit([&] {
|
||||
promise->Reject(NS_ERROR_DOM_INVALID_STATE_ERR, __func__);
|
||||
});
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
NS_ENSURE_TRUE_VOID(swm);
|
||||
|
||||
RefPtr<GenericPromise> inner = swm->MaybeClaimClient(clientInfo, desc);
|
||||
inner->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
|
||||
[promise] (bool aResult) {
|
||||
promise->Resolve(NS_OK, __func__);
|
||||
}, [promise] (nsresult aRv) {
|
||||
promise->Reject(aRv, __func__);
|
||||
});
|
||||
});
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget()));
|
||||
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
RefPtr<ClientOpPromise>
|
||||
ClientManagerService::Claim(const ClientClaimArgs& aArgs)
|
||||
{
|
||||
|
@ -523,13 +487,7 @@ ClientManagerService::Claim(const ClientClaimArgs& aArgs)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (ServiceWorkerParentInterceptEnabled()) {
|
||||
promiseList->AddPromise(
|
||||
ClaimOnMainThread(source->Info(),
|
||||
ServiceWorkerDescriptor(serviceWorker)));
|
||||
} else {
|
||||
promiseList->AddPromise(source->StartOp(aArgs));
|
||||
}
|
||||
promiseList->AddPromise(source->StartOp(aArgs));
|
||||
}
|
||||
|
||||
// Maybe finish the promise now in case we didn't find any matching clients.
|
||||
|
|
|
@ -640,7 +640,7 @@ ClientSource::Claim(const ClientClaimArgs& aArgs)
|
|||
auto holder =
|
||||
MakeRefPtr<DOMMozPromiseRequestHolder<GenericPromise>>(innerWindow->AsGlobal());
|
||||
|
||||
RefPtr<GenericPromise> p = swm->MaybeClaimClient(mClientInfo, swd);
|
||||
RefPtr<GenericPromise> p = swm->MaybeClaimClient(doc, swd);
|
||||
p->Then(mEventTarget, __func__,
|
||||
[outerPromise, holder] (bool aResult) {
|
||||
holder->Complete();
|
||||
|
|
|
@ -2554,7 +2554,7 @@ ServiceWorkerManager::UpdateInternal(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
|
||||
already_AddRefed<GenericPromise>
|
||||
ServiceWorkerManager::MaybeClaimClient(const ClientInfo& aClientInfo,
|
||||
ServiceWorkerManager::MaybeClaimClient(nsIDocument* aDocument,
|
||||
ServiceWorkerRegistrationInfo* aWorkerRegistration)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aWorkerRegistration);
|
||||
|
@ -2568,19 +2568,26 @@ ServiceWorkerManager::MaybeClaimClient(const ClientInfo& aClientInfo,
|
|||
}
|
||||
|
||||
// Same origin check
|
||||
nsCOMPtr<nsIPrincipal> principal(aClientInfo.GetPrincipal());
|
||||
if (!aWorkerRegistration->Principal()->Equals(principal)) {
|
||||
if (!aWorkerRegistration->Principal()->Equals(aDocument->NodePrincipal())) {
|
||||
ref = GenericPromise::CreateAndReject(NS_ERROR_DOM_SECURITY_ERR, __func__);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
Maybe<ClientInfo> clientInfo(aDocument->GetClientInfo());
|
||||
if (NS_WARN_IF(clientInfo.isNothing())) {
|
||||
ref = GenericPromise::CreateAndReject(NS_ERROR_DOM_INVALID_STATE_ERR,
|
||||
__func__);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
// The registration that should be controlling the client
|
||||
RefPtr<ServiceWorkerRegistrationInfo> matchingRegistration =
|
||||
GetServiceWorkerRegistrationInfo(aClientInfo);
|
||||
GetServiceWorkerRegistrationInfo(aDocument);
|
||||
|
||||
// The registration currently controlling the client
|
||||
RefPtr<ServiceWorkerRegistrationInfo> controllingRegistration;
|
||||
GetClientRegistration(aClientInfo, getter_AddRefs(controllingRegistration));
|
||||
GetClientRegistration(clientInfo.ref(),
|
||||
getter_AddRefs(controllingRegistration));
|
||||
|
||||
if (aWorkerRegistration != matchingRegistration ||
|
||||
aWorkerRegistration == controllingRegistration) {
|
||||
|
@ -2588,17 +2595,18 @@ ServiceWorkerManager::MaybeClaimClient(const ClientInfo& aClientInfo,
|
|||
return ref.forget();
|
||||
}
|
||||
|
||||
ref = StartControllingClient(aClientInfo, aWorkerRegistration);
|
||||
ref = StartControllingClient(clientInfo.ref(), aWorkerRegistration);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<GenericPromise>
|
||||
ServiceWorkerManager::MaybeClaimClient(const ClientInfo& aClientInfo,
|
||||
ServiceWorkerManager::MaybeClaimClient(nsIDocument* aDoc,
|
||||
const ServiceWorkerDescriptor& aServiceWorker)
|
||||
{
|
||||
RefPtr<GenericPromise> ref;
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal = aServiceWorker.GetPrincipal();
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
PrincipalInfoToPrincipal(aServiceWorker.PrincipalInfo());
|
||||
if (!principal) {
|
||||
ref = GenericPromise::CreateAndResolve(false, __func__);
|
||||
return ref.forget();
|
||||
|
@ -2617,7 +2625,7 @@ ServiceWorkerManager::MaybeClaimClient(const ClientInfo& aClientInfo,
|
|||
return ref.forget();
|
||||
}
|
||||
|
||||
ref = MaybeClaimClient(aClientInfo, registration);
|
||||
ref = MaybeClaimClient(aDoc, registration);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -285,11 +285,11 @@ public:
|
|||
JSExnType aExnType);
|
||||
|
||||
already_AddRefed<GenericPromise>
|
||||
MaybeClaimClient(const ClientInfo& aClientInfo,
|
||||
MaybeClaimClient(nsIDocument* aDocument,
|
||||
ServiceWorkerRegistrationInfo* aWorkerRegistration);
|
||||
|
||||
already_AddRefed<GenericPromise>
|
||||
MaybeClaimClient(const ClientInfo& aClientInfo,
|
||||
MaybeClaimClient(nsIDocument* aDoc,
|
||||
const ServiceWorkerDescriptor& aServiceWorker);
|
||||
|
||||
void
|
||||
|
|
|
@ -14,14 +14,18 @@ namespace dom {
|
|||
bool
|
||||
ServiceWorkerParentInterceptEnabled()
|
||||
{
|
||||
// For right now we only support main thread. In the future we could make
|
||||
// this use an atomic bool if we need to support worker threads.
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
static bool sInit = false;
|
||||
static Atomic<bool> sEnabled;
|
||||
static bool sEnabled;
|
||||
|
||||
if (!sInit) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
Preferences::AddAtomicBoolVarCache(&sEnabled,
|
||||
"dom.serviceWorkers.parent_intercept",
|
||||
false);
|
||||
Preferences::AddBoolVarCache(&sEnabled,
|
||||
"dom.serviceWorkers.parent_intercept",
|
||||
false);
|
||||
sInit = true;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче