mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1434701
P1 Make ServiceWorkerRegistration::CreateForMainThread() take a ServiceWorkerRegistrationDescriptor. r=catalinb r=asuth
This commit is contained in:
parent
0d21e3454c
commit
de795dbd34
@ -244,6 +244,7 @@
|
||||
#include "mozilla/dom/ImageBitmapBinding.h"
|
||||
#include "mozilla/dom/ServiceWorker.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistration.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
||||
#include "mozilla/dom/U2F.h"
|
||||
#include "mozilla/dom/WebIDLGlobalNameHash.h"
|
||||
#include "mozilla/dom/Worklet.h"
|
||||
@ -5174,14 +5175,15 @@ nsGlobalWindowInner::GetCaches(ErrorResult& aRv)
|
||||
}
|
||||
|
||||
already_AddRefed<ServiceWorkerRegistration>
|
||||
nsPIDOMWindowInner::GetServiceWorkerRegistration(const nsAString& aScope)
|
||||
nsPIDOMWindowInner::GetServiceWorkerRegistration(const ServiceWorkerRegistrationDescriptor& aDescriptor)
|
||||
{
|
||||
NS_ConvertUTF8toUTF16 scope(aDescriptor.Scope());
|
||||
RefPtr<ServiceWorkerRegistration> registration;
|
||||
if (!mServiceWorkerRegistrationTable.Get(aScope,
|
||||
if (!mServiceWorkerRegistrationTable.Get(scope,
|
||||
getter_AddRefs(registration))) {
|
||||
registration =
|
||||
ServiceWorkerRegistration::CreateForMainThread(this, aScope);
|
||||
mServiceWorkerRegistrationTable.Put(aScope, registration);
|
||||
ServiceWorkerRegistration::CreateForMainThread(this, aDescriptor);
|
||||
mServiceWorkerRegistrationTable.Put(scope, registration);
|
||||
}
|
||||
return registration.forget();
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ class Performance;
|
||||
class ServiceWorker;
|
||||
class ServiceWorkerDescriptor;
|
||||
class ServiceWorkerRegistration;
|
||||
class ServiceWorkerRegistrationDescriptor;
|
||||
class Timeout;
|
||||
class TimeoutManager;
|
||||
class CustomElementRegistry;
|
||||
@ -187,7 +188,7 @@ public:
|
||||
nsresult SetAudioCapture(bool aCapture);
|
||||
|
||||
already_AddRefed<mozilla::dom::ServiceWorkerRegistration>
|
||||
GetServiceWorkerRegistration(const nsAString& aScope);
|
||||
GetServiceWorkerRegistration(const mozilla::dom::ServiceWorkerRegistrationDescriptor& aDescriptor);
|
||||
void InvalidateServiceWorkerRegistration(const nsAString& aScope);
|
||||
|
||||
mozilla::dom::Performance* GetPerformance();
|
||||
|
@ -465,7 +465,7 @@ class ServiceWorkerResolveWindowPromiseOnRegisterCallback final : public Service
|
||||
RefPtr<ServiceWorkerRegistrationInfo> reg = registerJob->GetRegistration();
|
||||
|
||||
RefPtr<ServiceWorkerRegistration> swr =
|
||||
window->GetServiceWorkerRegistration(NS_ConvertUTF8toUTF16(reg->Scope()));
|
||||
window->GetServiceWorkerRegistration(reg->Descriptor());
|
||||
promise->MaybeResolve(swr);
|
||||
}
|
||||
|
||||
@ -1023,7 +1023,7 @@ public:
|
||||
}
|
||||
|
||||
RefPtr<ServiceWorkerRegistration> swr =
|
||||
mWindow->GetServiceWorkerRegistration(scope);
|
||||
mWindow->GetServiceWorkerRegistration(info->Descriptor());
|
||||
|
||||
array.AppendElement(swr);
|
||||
}
|
||||
@ -1146,9 +1146,8 @@ public:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ConvertUTF8toUTF16 scope(registration->Scope());
|
||||
RefPtr<ServiceWorkerRegistration> swr =
|
||||
mWindow->GetServiceWorkerRegistration(scope);
|
||||
mWindow->GetServiceWorkerRegistration(registration->Descriptor());
|
||||
mPromise->MaybeResolve(swr);
|
||||
|
||||
return NS_OK;
|
||||
@ -1463,9 +1462,8 @@ ServiceWorkerManager::CheckReadyPromise(nsPIDOMWindowInner* aWindow,
|
||||
GetServiceWorkerRegistrationInfo(principal, aURI);
|
||||
|
||||
if (registration && registration->GetActive()) {
|
||||
NS_ConvertUTF8toUTF16 scope(registration->Scope());
|
||||
RefPtr<ServiceWorkerRegistration> swr =
|
||||
aWindow->GetServiceWorkerRegistration(scope);
|
||||
aWindow->GetServiceWorkerRegistration(registration->Descriptor());
|
||||
aPromise->MaybeResolve(swr);
|
||||
return true;
|
||||
}
|
||||
|
@ -1352,13 +1352,15 @@ ServiceWorkerRegistration::WrapObject(JSContext* aCx,
|
||||
|
||||
/* static */ already_AddRefed<ServiceWorkerRegistration>
|
||||
ServiceWorkerRegistration::CreateForMainThread(nsPIDOMWindowInner* aWindow,
|
||||
const nsAString& aScope)
|
||||
const ServiceWorkerRegistrationDescriptor& aDescriptor)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
NS_ConvertUTF8toUTF16 scope(aDescriptor.Scope());
|
||||
|
||||
RefPtr<ServiceWorkerRegistration> registration =
|
||||
new ServiceWorkerRegistrationMainThread(aWindow, aScope);
|
||||
new ServiceWorkerRegistrationMainThread(aWindow, scope);
|
||||
|
||||
return registration.forget();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace dom {
|
||||
|
||||
class Promise;
|
||||
class PushManager;
|
||||
class ServiceWorkerRegistrationDescriptor;
|
||||
class WorkerListener;
|
||||
|
||||
// Used by ServiceWorkerManager to notify ServiceWorkerRegistrations of
|
||||
@ -58,7 +59,7 @@ public:
|
||||
|
||||
static already_AddRefed<ServiceWorkerRegistration>
|
||||
CreateForMainThread(nsPIDOMWindowInner* aWindow,
|
||||
const nsAString& aScope);
|
||||
const ServiceWorkerRegistrationDescriptor& aDescriptor);
|
||||
|
||||
static already_AddRefed<ServiceWorkerRegistration>
|
||||
CreateForWorker(WorkerPrivate* aWorkerPrivate,
|
||||
|
Loading…
Reference in New Issue
Block a user