зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434701
P3 Pass ServiceWorkerRegistrationDescriptor to ServiceWorkerRegistration::CreateForWorker(). r=asuth
This commit is contained in:
Родитель
6086e9a880
Коммит
7506d48306
|
@ -1833,6 +1833,13 @@ ServiceWorkerPrivate::SpawnWorkerIfNeeded(WakeUpReason aWhy,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
NS_ENSURE_TRUE(swm, NS_ERROR_FAILURE);
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationInfo> reg =
|
||||
swm->GetRegistration(mInfo->Principal(), mInfo->Scope());
|
||||
NS_ENSURE_TRUE(reg, NS_ERROR_FAILURE);
|
||||
|
||||
// TODO(catalinb): Bug 1192138 - Add telemetry for service worker wake-ups.
|
||||
|
||||
// Ensure that the IndexedDatabaseManager is initialized
|
||||
|
@ -1850,11 +1857,8 @@ ServiceWorkerPrivate::SpawnWorkerIfNeeded(WakeUpReason aWhy,
|
|||
MOZ_ASSERT(!mInfo->CacheName().IsEmpty());
|
||||
info.mServiceWorkerCacheName = mInfo->CacheName();
|
||||
|
||||
PrincipalInfo principalInfo;
|
||||
rv = PrincipalToPrincipalInfo(mInfo->Principal(), &principalInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
info.mServiceWorkerDescriptor.emplace(mInfo->Descriptor());
|
||||
info.mServiceWorkerRegistrationDescriptor.emplace(reg->Descriptor());
|
||||
|
||||
info.mLoadGroup = aLoadGroup;
|
||||
info.mLoadFailedAsyncRunnable = aLoadFailedRunnable;
|
||||
|
|
|
@ -1025,7 +1025,7 @@ public:
|
|||
TransitionWorker(WhichServiceWorker aWhichOne) override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_WARNING("FIXME: Not implemented!");
|
||||
// TODO: Not implemented
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1367,13 +1367,15 @@ ServiceWorkerRegistration::CreateForMainThread(nsPIDOMWindowInner* aWindow,
|
|||
|
||||
/* static */ already_AddRefed<ServiceWorkerRegistration>
|
||||
ServiceWorkerRegistration::CreateForWorker(WorkerPrivate* aWorkerPrivate,
|
||||
const nsAString& aScope)
|
||||
const ServiceWorkerRegistrationDescriptor& aDescriptor)
|
||||
{
|
||||
MOZ_ASSERT(aWorkerPrivate);
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
NS_ConvertUTF8toUTF16 scope(aDescriptor.Scope());
|
||||
|
||||
RefPtr<ServiceWorkerRegistration> registration =
|
||||
new ServiceWorkerRegistrationWorkerThread(aWorkerPrivate, aScope);
|
||||
new ServiceWorkerRegistrationWorkerThread(aWorkerPrivate, scope);
|
||||
|
||||
return registration.forget();
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
static already_AddRefed<ServiceWorkerRegistration>
|
||||
CreateForWorker(WorkerPrivate* aWorkerPrivate,
|
||||
const nsAString& aScope);
|
||||
const ServiceWorkerRegistrationDescriptor& aDescriptor);
|
||||
|
||||
JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
|
|
@ -146,6 +146,7 @@ WorkerLoadInfo::StealFrom(WorkerLoadInfo& aOther)
|
|||
mOrigin = aOther.mOrigin;
|
||||
mServiceWorkerCacheName = aOther.mServiceWorkerCacheName;
|
||||
mServiceWorkerDescriptor = aOther.mServiceWorkerDescriptor;
|
||||
mServiceWorkerRegistrationDescriptor = aOther.mServiceWorkerRegistrationDescriptor;
|
||||
mLoadFlags = aOther.mLoadFlags;
|
||||
mWindowID = aOther.mWindowID;
|
||||
mReferrerPolicy = aOther.mReferrerPolicy;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_workers_WorkerLoadInfo_h
|
||||
|
||||
#include "mozilla/dom/ChannelInfo.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
||||
#include "mozilla/dom/WorkerCommon.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
@ -92,6 +93,7 @@ struct WorkerLoadInfo
|
|||
|
||||
nsString mServiceWorkerCacheName;
|
||||
Maybe<ServiceWorkerDescriptor> mServiceWorkerDescriptor;
|
||||
Maybe<ServiceWorkerRegistrationDescriptor> mServiceWorkerRegistrationDescriptor;
|
||||
|
||||
Maybe<ServiceWorkerDescriptor> mParentController;
|
||||
|
||||
|
|
|
@ -5140,7 +5140,9 @@ WorkerPrivate::GetOrCreateGlobalScope(JSContext* aCx)
|
|||
if (IsSharedWorker()) {
|
||||
globalScope = new SharedWorkerGlobalScope(this, WorkerName());
|
||||
} else if (IsServiceWorker()) {
|
||||
globalScope = new ServiceWorkerGlobalScope(this, ServiceWorkerScope());
|
||||
globalScope =
|
||||
new ServiceWorkerGlobalScope(this,
|
||||
GetServiceWorkerRegistrationDescriptor());
|
||||
} else {
|
||||
globalScope = new DedicatedWorkerGlobalScope(this, WorkerName());
|
||||
}
|
||||
|
|
|
@ -842,6 +842,14 @@ public:
|
|||
return mLoadInfo.mServiceWorkerDescriptor.ref();
|
||||
}
|
||||
|
||||
const ServiceWorkerRegistrationDescriptor&
|
||||
GetServiceWorkerRegistrationDescriptor() const
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(IsServiceWorker());
|
||||
MOZ_DIAGNOSTIC_ASSERT(mLoadInfo.mServiceWorkerRegistrationDescriptor.isSome());
|
||||
return mLoadInfo.mServiceWorkerRegistrationDescriptor.ref();
|
||||
}
|
||||
|
||||
void
|
||||
UpdateServiceWorkerState(ServiceWorkerState aState)
|
||||
{
|
||||
|
|
|
@ -633,9 +633,15 @@ NS_IMPL_ADDREF_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope)
|
|||
NS_IMPL_RELEASE_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope)
|
||||
|
||||
ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
|
||||
const nsACString& aScope)
|
||||
: WorkerGlobalScope(aWorkerPrivate),
|
||||
mScope(NS_ConvertUTF8toUTF16(aScope))
|
||||
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor)
|
||||
: WorkerGlobalScope(aWorkerPrivate)
|
||||
, mScope(NS_ConvertUTF8toUTF16(aRegistrationDescriptor.Scope()))
|
||||
|
||||
// Eagerly create the registration because we will need to receive updates
|
||||
// about the state of the registration. We can't wait until first access
|
||||
// to start receiving these.
|
||||
, mRegistration(ServiceWorkerRegistration::CreateForWorker(aWorkerPrivate,
|
||||
aRegistrationDescriptor))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -672,11 +678,6 @@ ServiceWorkerGlobalScope::GetClients()
|
|||
ServiceWorkerRegistration*
|
||||
ServiceWorkerGlobalScope::Registration()
|
||||
{
|
||||
if (!mRegistration) {
|
||||
mRegistration =
|
||||
ServiceWorkerRegistration::CreateForWorker(mWorkerPrivate, mScope);
|
||||
}
|
||||
|
||||
return mRegistration;
|
||||
}
|
||||
|
||||
|
|
|
@ -303,7 +303,8 @@ public:
|
|||
IMPL_EVENT_HANDLER(notificationclick)
|
||||
IMPL_EVENT_HANDLER(notificationclose)
|
||||
|
||||
ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate, const nsACString& aScope);
|
||||
ServiceWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
|
||||
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor);
|
||||
|
||||
virtual bool
|
||||
WrapGlobalObject(JSContext* aCx,
|
||||
|
|
Загрузка…
Ссылка в новой задаче