Bug 1438211 P3 Implement WorkerGlobalScope::GetOrCreateServiceWorkerRegistration(). r=asuth

--HG--
extra : rebase_source : 3e6d360edafe30f95a355df25705ab4150372c8f
This commit is contained in:
Ben Kelly 2018-03-02 13:02:49 -08:00
Родитель 9e928c88fb
Коммит 84799ae3d5
2 изменённых файлов: 25 добавлений и 1 удалений

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

@ -559,6 +559,28 @@ WorkerGlobalScope::GetController() const
return mWorkerPrivate->GetController();
}
RefPtr<ServiceWorkerRegistration>
WorkerGlobalScope::GetOrCreateServiceWorkerRegistration(const ServiceWorkerRegistrationDescriptor& aDescriptor)
{
mWorkerPrivate->AssertIsOnWorkerThread();
RefPtr<ServiceWorkerRegistration> ref;
ForEachEventTargetObject([&] (DOMEventTargetHelper* aTarget, bool* aDoneOut) {
RefPtr<ServiceWorkerRegistration> swr = do_QueryObject(aTarget);
if (!swr || !swr->MatchesDescriptor(aDescriptor)) {
return;
}
ref = swr.forget();
*aDoneOut = true;
});
if (!ref) {
ref = ServiceWorkerRegistration::CreateForWorker(mWorkerPrivate, aDescriptor);
}
return ref.forget();
}
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
const nsString& aName)
: WorkerGlobalScope(aWorkerPrivate)

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

@ -34,7 +34,6 @@ enum class ImageBitmapFormat : uint8_t;
class Performance;
class Promise;
class RequestOrUSVString;
class ServiceWorkerRegistration;
class WorkerLocation;
class WorkerNavigator;
class WorkerPrivate;
@ -235,6 +234,9 @@ public:
Maybe<ServiceWorkerDescriptor>
GetController() const override;
RefPtr<mozilla::dom::ServiceWorkerRegistration>
GetOrCreateServiceWorkerRegistration(const ServiceWorkerRegistrationDescriptor& aDescriptor) override;
};
class DedicatedWorkerGlobalScope final : public WorkerGlobalScope