Backed out 6 changesets (bug 1564235) for ServiceWorkerRegistrar failures. CLOSED TREE

Backed out changeset 78d268b961e6 (bug 1564235)
Backed out changeset 198a29232047 (bug 1564235)
Backed out changeset b1503c48e2f6 (bug 1564235)
Backed out changeset 679bed36bc0b (bug 1564235)
Backed out changeset 789ce1a19e9f (bug 1564235)
Backed out changeset a4cd096b0ba7 (bug 1564235)
This commit is contained in:
Csoregi Natalia 2021-06-10 05:17:08 +03:00
Родитель 84cc1811f1
Коммит e84ffc5f5c
28 изменённых файлов: 29 добавлений и 687 удалений

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

@ -1,16 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* 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/. */
namespace mozilla {
namespace dom {
struct IPCNavigationPreloadState {
bool enabled;
nsCString headerValue;
};
} // namespace dom
} // namespace mozilla

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

@ -1,137 +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 "NavigationPreloadManager.h"
#include "ServiceWorkerUtils.h"
#include "nsNetUtil.h"
#include "mozilla/dom/NavigationPreloadManagerBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/ipc/MessageChannel.h"
namespace mozilla::dom {
using mozilla::ipc::ResponseRejectReason;
NS_IMPL_CYCLE_COLLECTING_ADDREF(NavigationPreloadManager)
NS_IMPL_CYCLE_COLLECTING_RELEASE(NavigationPreloadManager)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(NavigationPreloadManager)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(NavigationPreloadManager, mGlobal)
/* static */
bool NavigationPreloadManager::IsValidHeader(const nsACString& aHeader) {
return NS_IsReasonableHTTPHeaderValue(aHeader);
}
NavigationPreloadManager::NavigationPreloadManager(
nsCOMPtr<nsIGlobalObject>&& aGlobal,
RefPtr<ServiceWorkerRegistration::Inner>& aInner)
: mGlobal(aGlobal), mInner(aInner) {}
JSObject* NavigationPreloadManager::WrapObject(
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
return NavigationPreloadManager_Binding::Wrap(aCx, this, aGivenProto);
}
already_AddRefed<Promise> NavigationPreloadManager::SetEnabled(bool aEnabled) {
ErrorResult result;
RefPtr<Promise> promise = Promise::Create(GetParentObject(), result);
if (NS_WARN_IF(result.Failed())) {
result.SuppressException();
return promise.forget();
}
if (!mInner) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
return promise.forget();
}
mInner->SetNavigationPreloadEnabled(
aEnabled,
[promise](bool aSuccess) {
if (aSuccess) {
promise->MaybeResolveWithUndefined();
return;
}
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
},
[promise](ErrorResult&& aRv) { promise->MaybeReject(std::move(aRv)); });
return promise.forget();
}
already_AddRefed<Promise> NavigationPreloadManager::Enable() {
return SetEnabled(true);
}
already_AddRefed<Promise> NavigationPreloadManager::Disable() {
return SetEnabled(false);
}
already_AddRefed<Promise> NavigationPreloadManager::SetHeaderValue(
const nsACString& aHeader) {
ErrorResult result;
RefPtr<Promise> promise = Promise::Create(GetParentObject(), result);
if (NS_WARN_IF(result.Failed())) {
result.SuppressException();
return promise.forget();
}
if (!IsValidHeader(aHeader)) {
result.ThrowTypeError<MSG_INVALID_HEADER_VALUE>(aHeader);
promise->MaybeReject(std::move(result));
return promise.forget();
}
if (!mInner) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
return promise.forget();
}
mInner->SetNavigationPreloadHeader(
nsAutoCString(aHeader),
[promise](bool aSuccess) {
if (aSuccess) {
promise->MaybeResolveWithUndefined();
return;
}
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
},
[promise](ErrorResult&& aRv) { promise->MaybeReject(std::move(aRv)); });
return promise.forget();
}
already_AddRefed<Promise> NavigationPreloadManager::GetState() {
ErrorResult result;
RefPtr<Promise> promise = Promise::Create(GetParentObject(), result);
if (NS_WARN_IF(result.Failed())) {
result.SuppressException();
return promise.forget();
}
if (!mInner) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
return promise.forget();
}
mInner->GetNavigationPreloadState(
[promise](NavigationPreloadState&& aState) {
promise->MaybeResolve(std::move(aState));
},
[promise](ErrorResult&& aRv) { promise->MaybeReject(std::move(aRv)); });
return promise.forget();
}
} // namespace mozilla::dom

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

@ -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 mozilla_dom_NavigationPreloadManager_h
#define mozilla_dom_NavigationPreloadManager_h
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/ServiceWorkerRegistration.h"
#include "mozilla/RefPtr.h"
class nsIGlobalObject;
namespace mozilla {
namespace dom {
class Promise;
class NavigationPreloadManager final : public nsISupports,
public nsWrapperCache {
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(NavigationPreloadManager)
static bool IsValidHeader(const nsACString& aHeader);
NavigationPreloadManager(nsCOMPtr<nsIGlobalObject>&& aGlobal,
RefPtr<ServiceWorkerRegistration::Inner>& aInner);
// Webidl binding
nsIGlobalObject* GetParentObject() const { return mGlobal; }
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
// WebIdl implementation
already_AddRefed<Promise> Enable();
already_AddRefed<Promise> Disable();
already_AddRefed<Promise> SetHeaderValue(const nsACString& aHeader);
already_AddRefed<Promise> GetState();
private:
~NavigationPreloadManager() = default;
// General method for Enable()/Disable()
already_AddRefed<Promise> SetEnabled(bool aEnabled);
nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<ServiceWorkerRegistration::Inner> mInner;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_NavigationPreloadManager_h

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

@ -4,7 +4,6 @@
include protocol PBackground;
include IPCNavigationPreloadState;
include IPCServiceWorkerRegistrationDescriptor;
include "ipc/ErrorIPCUtils.h";
@ -23,11 +22,6 @@ parent:
async Update(nsCString aNewestWorkerScriptUrl) returns (
IPCServiceWorkerRegistrationDescriptorOrCopyableErrorResult aResult);
// For NavigationPreload interface
async SetNavigationPreloadEnabled(bool aEnabled) returns (bool aSuccess);
async SetNavigationPreloadHeader(nsCString aHeader) returns (bool aSuccess);
async GetNavigationPreloadState() returns (IPCNavigationPreloadState? aState);
child:
async __delete__();

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

@ -7,8 +7,6 @@
#include "RemoteServiceWorkerRegistrationImpl.h"
#include "ServiceWorkerRegistrationChild.h"
#include "mozilla/dom/NavigationPreloadManagerBinding.h"
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/ipc/BackgroundChild.h"
@ -110,76 +108,6 @@ void RemoteServiceWorkerRegistrationImpl::Unregister(
});
}
void RemoteServiceWorkerRegistrationImpl::SetNavigationPreloadEnabled(
bool aEnabled, ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) {
if (!mActor) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
return;
}
mActor->SendSetNavigationPreloadEnabled(
aEnabled,
[successCB = std::move(aSuccessCB), aFailureCB](bool aResult) {
if (!aResult) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
return;
}
successCB(aResult);
},
[aFailureCB](ResponseRejectReason&& aReason) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
});
}
void RemoteServiceWorkerRegistrationImpl::SetNavigationPreloadHeader(
const nsCString& aHeader, ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) {
if (!mActor) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
return;
}
mActor->SendSetNavigationPreloadHeader(
aHeader,
[successCB = std::move(aSuccessCB), aFailureCB](bool aResult) {
if (!aResult) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
return;
}
successCB(aResult);
},
[aFailureCB](ResponseRejectReason&& aReason) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
});
}
void RemoteServiceWorkerRegistrationImpl::GetNavigationPreloadState(
NavigationPreloadGetStateCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) {
if (!mActor) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
return;
}
mActor->SendGetNavigationPreloadState(
[successCB = std::move(aSuccessCB),
aFailureCB](Maybe<IPCNavigationPreloadState>&& aState) {
if (NS_WARN_IF(!aState)) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
return;
}
NavigationPreloadState state;
state.mEnabled = aState.ref().enabled();
state.mHeaderValue.Construct(std::move(aState.ref().headerValue()));
successCB(std::move(state));
},
[aFailureCB](ResponseRejectReason&& aReason) {
aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
});
}
RemoteServiceWorkerRegistrationImpl::RemoteServiceWorkerRegistrationImpl(
const ServiceWorkerRegistrationDescriptor& aDescriptor)
: mOuter(nullptr), mShutdown(false) {

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

@ -36,18 +36,6 @@ class RemoteServiceWorkerRegistrationImpl final
void Unregister(ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) override;
void SetNavigationPreloadEnabled(
bool aEnabled, ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) override;
void SetNavigationPreloadHeader(
const nsCString& aHeader, ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) override;
void GetNavigationPreloadState(
NavigationPreloadGetStateCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) override;
public:
explicit RemoteServiceWorkerRegistrationImpl(
const ServiceWorkerRegistrationDescriptor& aDescriptor);

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

@ -213,8 +213,6 @@ nsresult PopulateRegistrationData(
aData.lastUpdateTime() = aRegistration->GetLastUpdateTime();
aData.navigationPreloadState() = aRegistration->GetNavigationPreloadState();
MOZ_ASSERT(ServiceWorkerRegistrationDataIsValid(aData));
return NS_OK;
@ -1476,8 +1474,7 @@ void ServiceWorkerManager::LoadRegistration(
registration =
CreateNewRegistration(aRegistration.scope(), principal,
static_cast<ServiceWorkerUpdateViaCache>(
aRegistration.updateViaCache()),
aRegistration.navigationPreloadState());
aRegistration.updateViaCache()));
} else {
// If active worker script matches our expectations for a "current worker",
// then we are done. Since scripts with the same URL might have different
@ -2654,8 +2651,7 @@ ServiceWorkerManager::GetRegistration(const nsACString& aScopeKey,
already_AddRefed<ServiceWorkerRegistrationInfo>
ServiceWorkerManager::CreateNewRegistration(
const nsCString& aScope, nsIPrincipal* aPrincipal,
ServiceWorkerUpdateViaCache aUpdateViaCache,
IPCNavigationPreloadState aNavigationPreloadState) {
ServiceWorkerUpdateViaCache aUpdateViaCache) {
#ifdef DEBUG
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIURI> scopeURI;
@ -2668,8 +2664,7 @@ ServiceWorkerManager::CreateNewRegistration(
#endif
RefPtr<ServiceWorkerRegistrationInfo> registration =
new ServiceWorkerRegistrationInfo(aScope, aPrincipal, aUpdateViaCache,
std::move(aNavigationPreloadState));
new ServiceWorkerRegistrationInfo(aScope, aPrincipal, aUpdateViaCache);
// From now on ownership of registration is with
// mServiceWorkerRegistrationInfos.

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

@ -160,9 +160,7 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
already_AddRefed<ServiceWorkerRegistrationInfo> CreateNewRegistration(
const nsCString& aScope, nsIPrincipal* aPrincipal,
ServiceWorkerUpdateViaCache aUpdateViaCache,
IPCNavigationPreloadState aNavigationPreloadState =
IPCNavigationPreloadState(false, "true"_ns));
ServiceWorkerUpdateViaCache aUpdateViaCache);
void RemoveRegistration(ServiceWorkerRegistrationInfo* aRegistration);

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

@ -50,7 +50,7 @@ namespace dom {
namespace {
static const char* gSupportedRegistrarVersions[] = {
SERVICEWORKERREGISTRAR_VERSION, "8", "7", "6", "5", "4", "3", "2"};
SERVICEWORKERREGISTRAR_VERSION, "7", "6", "5", "4", "3", "2"};
static const uint32_t kInvalidGeneration = static_cast<uint32_t>(-1);
@ -128,9 +128,6 @@ nsresult CreatePrincipalInfo(nsILineInputStream* aStream,
return NS_OK;
}
const IPCNavigationPreloadState gDefaultNavigationPreloadState(false,
"true"_ns);
} // namespace
NS_IMPL_ISUPPORTS(ServiceWorkerRegistrar, nsIObserver, nsIAsyncShutdownBlocker)
@ -447,9 +444,8 @@ nsresult ServiceWorkerRegistrar::ReadData() {
entry->updateViaCache() = updateViaCache.ToInteger(&rv, 16);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (entry->updateViaCache() >
nsIServiceWorkerRegistrationInfo::UPDATE_VIA_CACHE_NONE) {
} else if (entry->updateViaCache() >
nsIServiceWorkerRegistrationInfo::UPDATE_VIA_CACHE_NONE) {
return NS_ERROR_INVALID_ARG;
}
@ -476,74 +472,6 @@ nsresult ServiceWorkerRegistrar::ReadData() {
return rv;
}
entry->lastUpdateTime() = lastUpdateTime;
nsAutoCString navigationPreloadEnabledStr;
GET_LINE(navigationPreloadEnabledStr);
bool navigationPreloadEnabled =
navigationPreloadEnabledStr.ToInteger(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
entry->navigationPreloadState().enabled() = navigationPreloadEnabled;
GET_LINE(entry->navigationPreloadState().headerValue());
} else if (version.EqualsLiteral("8")) {
rv = CreatePrincipalInfo(lineInputStream, entry);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
GET_LINE(entry->currentWorkerURL());
nsAutoCString fetchFlag;
GET_LINE(fetchFlag);
if (!fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE) &&
!fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_FALSE)) {
return NS_ERROR_INVALID_ARG;
}
entry->currentWorkerHandlesFetch() =
fetchFlag.EqualsLiteral(SERVICEWORKERREGISTRAR_TRUE);
nsAutoCString cacheName;
GET_LINE(cacheName);
CopyUTF8toUTF16(cacheName, entry->cacheName());
nsAutoCString updateViaCache;
GET_LINE(updateViaCache);
entry->updateViaCache() = updateViaCache.ToInteger(&rv, 16);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
if (entry->updateViaCache() >
nsIServiceWorkerRegistrationInfo::UPDATE_VIA_CACHE_NONE) {
return NS_ERROR_INVALID_ARG;
}
nsAutoCString installedTimeStr;
GET_LINE(installedTimeStr);
int64_t installedTime = installedTimeStr.ToInteger64(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
entry->currentWorkerInstalledTime() = installedTime;
nsAutoCString activatedTimeStr;
GET_LINE(activatedTimeStr);
int64_t activatedTime = activatedTimeStr.ToInteger64(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
entry->currentWorkerActivatedTime() = activatedTime;
nsAutoCString lastUpdateTimeStr;
GET_LINE(lastUpdateTimeStr);
int64_t lastUpdateTime = lastUpdateTimeStr.ToInteger64(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
entry->lastUpdateTime() = lastUpdateTime;
entry->navigationPreloadState() = gDefaultNavigationPreloadState;
} else if (version.EqualsLiteral("7")) {
rv = CreatePrincipalInfo(lineInputStream, entry);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -599,8 +527,6 @@ nsresult ServiceWorkerRegistrar::ReadData() {
return rv;
}
entry->lastUpdateTime() = lastUpdateTime;
entry->navigationPreloadState() = gDefaultNavigationPreloadState;
} else if (version.EqualsLiteral("6")) {
rv = CreatePrincipalInfo(lineInputStream, entry);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -636,8 +562,6 @@ nsresult ServiceWorkerRegistrar::ReadData() {
entry->currentWorkerInstalledTime() = 0;
entry->currentWorkerActivatedTime() = 0;
entry->lastUpdateTime() = 0;
entry->navigationPreloadState() = gDefaultNavigationPreloadState;
} else if (version.EqualsLiteral("5")) {
overwrite = true;
dedupe = true;
@ -668,8 +592,6 @@ nsresult ServiceWorkerRegistrar::ReadData() {
entry->currentWorkerInstalledTime() = 0;
entry->currentWorkerActivatedTime() = 0;
entry->lastUpdateTime() = 0;
entry->navigationPreloadState() = gDefaultNavigationPreloadState;
} else if (version.EqualsLiteral("4")) {
overwrite = true;
dedupe = true;
@ -694,8 +616,6 @@ nsresult ServiceWorkerRegistrar::ReadData() {
entry->currentWorkerInstalledTime() = 0;
entry->currentWorkerActivatedTime() = 0;
entry->lastUpdateTime() = 0;
entry->navigationPreloadState() = gDefaultNavigationPreloadState;
} else if (version.EqualsLiteral("3")) {
overwrite = true;
dedupe = true;
@ -720,8 +640,6 @@ nsresult ServiceWorkerRegistrar::ReadData() {
entry->currentWorkerInstalledTime() = 0;
entry->currentWorkerActivatedTime() = 0;
entry->lastUpdateTime() = 0;
entry->navigationPreloadState() = gDefaultNavigationPreloadState;
} else if (version.EqualsLiteral("2")) {
overwrite = true;
dedupe = true;
@ -753,8 +671,6 @@ nsresult ServiceWorkerRegistrar::ReadData() {
entry->currentWorkerInstalledTime() = 0;
entry->currentWorkerActivatedTime() = 0;
entry->lastUpdateTime() = 0;
entry->navigationPreloadState() = gDefaultNavigationPreloadState;
} else {
MOZ_ASSERT_UNREACHABLE("Should never get here!");
}
@ -1157,13 +1073,6 @@ nsresult ServiceWorkerRegistrar::WriteData(
buffer.AppendInt(aData[i].lastUpdateTime());
buffer.Append('\n');
buffer.AppendInt(
static_cast<int32_t>(aData[i].navigationPreloadState().enabled()));
buffer.Append('\n');
buffer.Append(aData[i].navigationPreloadState().headerValue());
buffer.Append('\n');
buffer.AppendLiteral(SERVICEWORKERREGISTRAR_TERMINATOR);
buffer.Append('\n');

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

@ -17,7 +17,7 @@
#include "nsTArray.h"
#define SERVICEWORKERREGISTRAR_FILE u"serviceworker.txt"
#define SERVICEWORKERREGISTRAR_VERSION "9"
#define SERVICEWORKERREGISTRAR_VERSION "8"
#define SERVICEWORKERREGISTRAR_TERMINATOR "#"
#define SERVICEWORKERREGISTRAR_TRUE "true"
#define SERVICEWORKERREGISTRAR_FALSE "false"

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

@ -4,7 +4,6 @@
* 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 IPCNavigationPreloadState;
include PBackgroundSharedTypes;
namespace mozilla {
@ -25,8 +24,6 @@ struct ServiceWorkerRegistrationData
int64_t currentWorkerInstalledTime;
int64_t currentWorkerActivatedTime;
int64_t lastUpdateTime;
IPCNavigationPreloadState navigationPreloadState;
};
} // namespace dom

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

@ -7,7 +7,6 @@
#include "ServiceWorkerRegistration.h"
#include "mozilla/dom/DOMMozPromiseRequestHolder.h"
#include "mozilla/dom/NavigationPreloadManager.h"
#include "mozilla/dom/Notification.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PushManager.h"
@ -25,8 +24,7 @@ namespace dom {
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerRegistration,
DOMEventTargetHelper, mInstallingWorker,
mWaitingWorker, mActiveWorker,
mNavigationPreloadManager, mPushManager);
mWaitingWorker, mActiveWorker, mPushManager);
NS_IMPL_ADDREF_INHERITED(ServiceWorkerRegistration, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(ServiceWorkerRegistration, DOMEventTargetHelper)
@ -144,16 +142,6 @@ already_AddRefed<ServiceWorker> ServiceWorkerRegistration::GetActive() const {
return ref.forget();
}
already_AddRefed<NavigationPreloadManager>
ServiceWorkerRegistration::NavigationPreload() {
if (!mNavigationPreloadManager) {
mNavigationPreloadManager =
MakeRefPtr<NavigationPreloadManager>(GetParentObject(), mInner);
}
RefPtr<NavigationPreloadManager> ref = mNavigationPreloadManager;
return ref.forget();
}
void ServiceWorkerRegistration::UpdateState(
const ServiceWorkerRegistrationDescriptor& aDescriptor) {
MOZ_DIAGNOSTIC_ASSERT(MatchesDescriptor(aDescriptor));

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

@ -21,7 +21,6 @@ class nsIGlobalObject;
namespace mozilla {
namespace dom {
class NavigationPreloadManager;
class Promise;
class PushManager;
class WorkerPrivate;
@ -52,19 +51,6 @@ class ServiceWorkerRegistration final : public DOMEventTargetHelper {
virtual void Unregister(ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) = 0;
// Interface for NavigationPreload
virtual void SetNavigationPreloadEnabled(
bool aEnabled, ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) = 0;
virtual void SetNavigationPreloadHeader(
const nsCString& aHeader, ServiceWorkerBoolCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) = 0;
virtual void GetNavigationPreloadState(
NavigationPreloadGetStateCallback&& aSuccessCB,
ServiceWorkerFailureCallback&& aFailureCB) = 0;
};
NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_SERVICEWORKERREGISTRATION_IID)
@ -95,8 +81,6 @@ class ServiceWorkerRegistration final : public DOMEventTargetHelper {
already_AddRefed<ServiceWorker> GetActive() const;
already_AddRefed<NavigationPreloadManager> NavigationPreload();
void UpdateState(const ServiceWorkerRegistrationDescriptor& aDescriptor);
bool MatchesDescriptor(
@ -149,7 +133,6 @@ class ServiceWorkerRegistration final : public DOMEventTargetHelper {
RefPtr<ServiceWorker> mInstallingWorker;
RefPtr<ServiceWorker> mWaitingWorker;
RefPtr<ServiceWorker> mActiveWorker;
RefPtr<NavigationPreloadManager> mNavigationPreloadManager;
RefPtr<PushManager> mPushManager;
struct VersionCallback {

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

@ -72,8 +72,7 @@ bool ServiceWorkerRegistrationInfo::IsCorrupt() const { return mCorrupt; }
ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(
const nsACString& aScope, nsIPrincipal* aPrincipal,
ServiceWorkerUpdateViaCache aUpdateViaCache,
IPCNavigationPreloadState&& aNavigationPreloadState)
ServiceWorkerUpdateViaCache aUpdateViaCache)
: mPrincipal(aPrincipal),
mDescriptor(GetNextId(), GetNextVersion(), aPrincipal, aScope,
aUpdateViaCache),
@ -84,8 +83,7 @@ ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo(
mCreationTimeStamp(TimeStamp::Now()),
mLastUpdateTime(0),
mUnregistered(false),
mCorrupt(false),
mNavigationPreloadState(std::move(aNavigationPreloadState)) {
mCorrupt(false) {
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
}
@ -802,24 +800,6 @@ const nsID& ServiceWorkerRegistrationInfo::AgentClusterId() const {
return mAgentClusterId;
}
void ServiceWorkerRegistrationInfo::SetNavigationPreloadEnabled(
const bool& aEnabled) {
MOZ_ASSERT(NS_IsMainThread());
mNavigationPreloadState.enabled() = aEnabled;
}
void ServiceWorkerRegistrationInfo::SetNavigationPreloadHeader(
const nsCString& aHeader) {
MOZ_ASSERT(NS_IsMainThread());
mNavigationPreloadState.headerValue() = aHeader;
}
IPCNavigationPreloadState
ServiceWorkerRegistrationInfo::GetNavigationPreloadState() const {
MOZ_ASSERT(NS_IsMainThread());
return mNavigationPreloadState;
}
// static
uint64_t ServiceWorkerRegistrationInfo::GetNextId() {
MOZ_ASSERT(NS_IsMainThread());

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

@ -9,7 +9,6 @@
#include <functional>
#include "mozilla/dom/IPCNavigationPreloadState.h"
#include "mozilla/dom/ServiceWorkerInfo.h"
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
@ -70,18 +69,15 @@ class ServiceWorkerRegistrationInfo final
bool mCorrupt;
IPCNavigationPreloadState mNavigationPreloadState;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISERVICEWORKERREGISTRATIONINFO
typedef std::function<void()> TryToActivateCallback;
ServiceWorkerRegistrationInfo(
const nsACString& aScope, nsIPrincipal* aPrincipal,
ServiceWorkerUpdateViaCache aUpdateViaCache,
IPCNavigationPreloadState&& aNavigationPreloadState);
ServiceWorkerRegistrationInfo(const nsACString& aScope,
nsIPrincipal* aPrincipal,
ServiceWorkerUpdateViaCache aUpdateViaCache);
void AddInstance(ServiceWorkerRegistrationListener* aInstance,
const ServiceWorkerRegistrationDescriptor& aDescriptor);
@ -230,12 +226,6 @@ class ServiceWorkerRegistrationInfo final
const nsID& AgentClusterId() const;
void SetNavigationPreloadEnabled(const bool& aEnabled);
void SetNavigationPreloadHeader(const nsCString& aHeader);
IPCNavigationPreloadState GetNavigationPreloadState() const;
private:
// Roughly equivalent to [[Update Registration State algorithm]]. Make sure
// this is called *before* updating SW instances' state, otherwise they

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

@ -78,55 +78,6 @@ IPCResult ServiceWorkerRegistrationParent::RecvUpdate(
return IPC_OK();
}
IPCResult ServiceWorkerRegistrationParent::RecvSetNavigationPreloadEnabled(
const bool& aEnabled, SetNavigationPreloadEnabledResolver&& aResolver) {
if (!mProxy) {
aResolver(false);
return IPC_OK();
}
mProxy->SetNavigationPreloadEnabled(aEnabled)->Then(
GetCurrentSerialEventTarget(), __func__,
[aResolver](bool) { aResolver(true); },
[aResolver](nsresult) { aResolver(false); });
return IPC_OK();
}
IPCResult ServiceWorkerRegistrationParent::RecvSetNavigationPreloadHeader(
const nsCString& aHeader, SetNavigationPreloadHeaderResolver&& aResolver) {
if (!mProxy) {
aResolver(false);
return IPC_OK();
}
mProxy->SetNavigationPreloadHeader(aHeader)->Then(
GetCurrentSerialEventTarget(), __func__,
[aResolver](bool) { aResolver(true); },
[aResolver](nsresult) { aResolver(false); });
return IPC_OK();
}
IPCResult ServiceWorkerRegistrationParent::RecvGetNavigationPreloadState(
GetNavigationPreloadStateResolver&& aResolver) {
if (!mProxy) {
aResolver(Nothing());
return IPC_OK();
}
mProxy->GetNavigationPreloadState()->Then(
GetCurrentSerialEventTarget(), __func__,
[aResolver](const IPCNavigationPreloadState& aState) {
aResolver(Some(aState));
},
[aResolver](const CopyableErrorResult& aResult) {
aResolver(Nothing());
});
return IPC_OK();
}
ServiceWorkerRegistrationParent::ServiceWorkerRegistrationParent()
: mDeleteSent(false) {}

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

@ -33,17 +33,6 @@ class ServiceWorkerRegistrationParent final
mozilla::ipc::IPCResult RecvUpdate(const nsCString& aNewestWorkerScriptUrl,
UpdateResolver&& aResolver) override;
mozilla::ipc::IPCResult RecvSetNavigationPreloadEnabled(
const bool& aEnabled,
SetNavigationPreloadEnabledResolver&& aResolver) override;
mozilla::ipc::IPCResult RecvSetNavigationPreloadHeader(
const nsCString& aHeader,
SetNavigationPreloadHeaderResolver&& aResolver) override;
mozilla::ipc::IPCResult RecvGetNavigationPreloadState(
GetNavigationPreloadStateResolver&& aResolver) override;
public:
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerRegistrationParent, override);

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

@ -384,100 +384,5 @@ RefPtr<ServiceWorkerRegistrationPromise> ServiceWorkerRegistrationProxy::Update(
return promise;
}
RefPtr<GenericPromise>
ServiceWorkerRegistrationProxy::SetNavigationPreloadEnabled(
const bool& aEnabled) {
AssertIsOnBackgroundThread();
RefPtr<ServiceWorkerRegistrationProxy> self = this;
RefPtr<GenericPromise::Private> promise =
new GenericPromise::Private(__func__);
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableFunction(__func__, [aEnabled, self, promise]() mutable {
nsresult rv = NS_ERROR_DOM_INVALID_STATE_ERR;
auto scopeExit = MakeScopeExit([&] { promise->Reject(rv, __func__); });
NS_ENSURE_TRUE_VOID(self->mReg);
NS_ENSURE_TRUE_VOID(self->mReg->GetActive());
auto reg = self->mReg;
reg->SetNavigationPreloadEnabled(aEnabled);
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
NS_ENSURE_TRUE_VOID(swm);
swm->StoreRegistration(reg->Principal(), reg);
scopeExit.release();
promise->Resolve(true, __func__);
});
MOZ_ALWAYS_SUCCEEDS(
SchedulerGroup::Dispatch(TaskCategory::Other, r.forget()));
return promise;
}
RefPtr<GenericPromise>
ServiceWorkerRegistrationProxy::SetNavigationPreloadHeader(
const nsCString& aHeader) {
AssertIsOnBackgroundThread();
RefPtr<ServiceWorkerRegistrationProxy> self = this;
RefPtr<GenericPromise::Private> promise =
new GenericPromise::Private(__func__);
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableFunction(__func__, [aHeader, self, promise]() mutable {
nsresult rv = NS_ERROR_DOM_INVALID_STATE_ERR;
auto scopeExit = MakeScopeExit([&] { promise->Reject(rv, __func__); });
NS_ENSURE_TRUE_VOID(self->mReg);
NS_ENSURE_TRUE_VOID(self->mReg->GetActive());
auto reg = self->mReg;
reg->SetNavigationPreloadHeader(aHeader);
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
NS_ENSURE_TRUE_VOID(swm);
swm->StoreRegistration(reg->Principal(), reg);
scopeExit.release();
promise->Resolve(true, __func__);
});
MOZ_ALWAYS_SUCCEEDS(
SchedulerGroup::Dispatch(TaskCategory::Other, r.forget()));
return promise;
}
RefPtr<NavigationPreloadStatePromise>
ServiceWorkerRegistrationProxy::GetNavigationPreloadState() {
AssertIsOnBackgroundThread();
RefPtr<ServiceWorkerRegistrationProxy> self = this;
RefPtr<NavigationPreloadStatePromise::Private> promise =
new NavigationPreloadStatePromise::Private(__func__);
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableFunction(__func__, [self, promise]() mutable {
nsresult rv = NS_ERROR_DOM_INVALID_STATE_ERR;
auto scopeExit = MakeScopeExit([&] { promise->Reject(rv, __func__); });
NS_ENSURE_TRUE_VOID(self->mReg);
scopeExit.release();
promise->Resolve(self->mReg->GetNavigationPreloadState(), __func__);
});
MOZ_ALWAYS_SUCCEEDS(
SchedulerGroup::Dispatch(TaskCategory::Other, r.forget()));
return promise;
}
} // namespace dom
} // namespace mozilla

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

@ -78,12 +78,6 @@ class ServiceWorkerRegistrationProxy final
RefPtr<ServiceWorkerRegistrationPromise> Update(
const nsCString& aNewestWorkerScriptUrl);
RefPtr<GenericPromise> SetNavigationPreloadEnabled(const bool& aEnabled);
RefPtr<GenericPromise> SetNavigationPreloadHeader(const nsCString& aHeader);
RefPtr<NavigationPreloadStatePromise> GetNavigationPreloadState();
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ServiceWorkerRegistrationProxy,
override);
};

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

@ -7,7 +7,6 @@
#define _mozilla_dom_ServiceWorkerUtils_h
#include "mozilla/MozPromise.h"
#include "mozilla/dom/IPCNavigationPreloadState.h"
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
#include "nsTArray.h"
@ -23,7 +22,6 @@ namespace dom {
class ClientInfo;
class ServiceWorkerRegistrationData;
class ServiceWorkerRegistrationDescriptor;
struct NavigationPreloadState;
typedef MozPromise<ServiceWorkerRegistrationDescriptor, CopyableErrorResult,
false>
@ -33,9 +31,6 @@ typedef MozPromise<CopyableTArray<ServiceWorkerRegistrationDescriptor>,
CopyableErrorResult, false>
ServiceWorkerRegistrationListPromise;
typedef MozPromise<IPCNavigationPreloadState, CopyableErrorResult, false>
NavigationPreloadStatePromise;
typedef std::function<void(const ServiceWorkerRegistrationDescriptor&)>
ServiceWorkerRegistrationCallback;
@ -47,9 +42,6 @@ typedef std::function<void(bool)> ServiceWorkerBoolCallback;
typedef std::function<void(ErrorResult&&)> ServiceWorkerFailureCallback;
typedef std::function<void(NavigationPreloadState&&)>
NavigationPreloadGetStateCallback;
bool ServiceWorkerRegistrationDataIsValid(
const ServiceWorkerRegistrationData& aData);

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

@ -13,7 +13,6 @@ EXPORTS.mozilla.dom += [
"FetchEventOpParent.h",
"FetchEventOpProxyChild.h",
"FetchEventOpProxyParent.h",
"NavigationPreloadManager.h",
"ServiceWorker.h",
"ServiceWorkerActors.h",
"ServiceWorkerChild.h",
@ -47,7 +46,6 @@ UNIFIED_SOURCES += [
"FetchEventOpParent.cpp",
"FetchEventOpProxyChild.cpp",
"FetchEventOpProxyParent.cpp",
"NavigationPreloadManager.cpp",
"RemoteServiceWorkerContainerImpl.cpp",
"RemoteServiceWorkerImpl.cpp",
"RemoteServiceWorkerRegistrationImpl.cpp",
@ -90,7 +88,6 @@ UNIFIED_SOURCES += [
]
IPDL_SOURCES += [
"IPCNavigationPreloadState.ipdlh",
"IPCServiceWorkerDescriptor.ipdlh",
"IPCServiceWorkerRegistrationDescriptor.ipdlh",
"PFetchEventOp.ipdl",

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

@ -1,22 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* https://w3c.github.io/ServiceWorker/#navigation-preload-manager
*/
[Pref="dom.serviceWorkers.navigationPreload.enabled", SecureContext,
Exposed=(Window,Worker)]
interface NavigationPreloadManager {
Promise<void> enable();
Promise<void> disable();
Promise<void> setHeaderValue(ByteString value);
Promise<NavigationPreloadState> getState();
};
dictionary NavigationPreloadState {
boolean enabled = false;
ByteString headerValue;
};

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

@ -16,9 +16,6 @@ interface ServiceWorkerRegistration : EventTarget {
readonly attribute ServiceWorker? waiting;
readonly attribute ServiceWorker? active;
[Pref="dom.serviceWorkers.navigationPreload.enabled", SameObject]
readonly attribute NavigationPreloadManager navigationPreload;
readonly attribute USVString scope;
[Throws]
readonly attribute ServiceWorkerUpdateViaCache updateViaCache;

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

@ -229,9 +229,6 @@ with Files("MutationEvent.webidl"):
with Files("NativeOSFileInternals.webidl"):
BUG_COMPONENT = ("Toolkit", "OS.File")
with Files("NavigationPreloadManager.webidl"):
BUG_COMPONENT = ("Core", "DOM: Service Workers")
with Files("Net*"):
BUG_COMPONENT = ("Core", "Networking")
@ -723,7 +720,6 @@ WEBIDL_FILES = [
"MutationObserver.webidl",
"NamedNodeMap.webidl",
"NativeOSFileInternals.webidl",
"NavigationPreloadManager.webidl",
"Navigator.webidl",
"NetErrorInfo.webidl",
"NetworkInformation.webidl",

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

@ -3088,11 +3088,6 @@
value: false
mirror: always
- name: dom.serviceWorkers.navigationPreload.enabled
type: RelaxedAtomicBool
value: false
mirror: always
# If true. then the service worker interception and the ServiceWorkerManager
# will live in the parent process. This only takes effect on browser start.
- name: dom.serviceWorkers.parent_intercept

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

@ -1,4 +1,3 @@
prefs: [dom.serviceWorkers.navigationPreload.enabled:true]
implementation-status: backlog
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1564235
leak-threshold: [tab:102400]

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

@ -0,0 +1,11 @@
[get-state.https.html]
expected: TIMEOUT
[getState]
expected: FAIL
[getState from a worker]
expected: TIMEOUT
[no active worker]
expected: NOTRUN

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

@ -0,0 +1,4 @@
[navigationPreload.https.html]
[The navigationPreload attribute must return service worker registration's NavigationPreloadManager object.]
expected: FAIL