зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1438211 P3 Implement WorkerGlobalScope::GetOrCreateServiceWorkerRegistration(). r=asuth
--HG-- extra : rebase_source : 3e6d360edafe30f95a355df25705ab4150372c8f
This commit is contained in:
Родитель
9e928c88fb
Коммит
84799ae3d5
|
@ -559,6 +559,28 @@ WorkerGlobalScope::GetController() const
|
||||||
return mWorkerPrivate->GetController();
|
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,
|
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
|
||||||
const nsString& aName)
|
const nsString& aName)
|
||||||
: WorkerGlobalScope(aWorkerPrivate)
|
: WorkerGlobalScope(aWorkerPrivate)
|
||||||
|
|
|
@ -34,7 +34,6 @@ enum class ImageBitmapFormat : uint8_t;
|
||||||
class Performance;
|
class Performance;
|
||||||
class Promise;
|
class Promise;
|
||||||
class RequestOrUSVString;
|
class RequestOrUSVString;
|
||||||
class ServiceWorkerRegistration;
|
|
||||||
class WorkerLocation;
|
class WorkerLocation;
|
||||||
class WorkerNavigator;
|
class WorkerNavigator;
|
||||||
class WorkerPrivate;
|
class WorkerPrivate;
|
||||||
|
@ -235,6 +234,9 @@ public:
|
||||||
|
|
||||||
Maybe<ServiceWorkerDescriptor>
|
Maybe<ServiceWorkerDescriptor>
|
||||||
GetController() const override;
|
GetController() const override;
|
||||||
|
|
||||||
|
RefPtr<mozilla::dom::ServiceWorkerRegistration>
|
||||||
|
GetOrCreateServiceWorkerRegistration(const ServiceWorkerRegistrationDescriptor& aDescriptor) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DedicatedWorkerGlobalScope final : public WorkerGlobalScope
|
class DedicatedWorkerGlobalScope final : public WorkerGlobalScope
|
||||||
|
|
Загрузка…
Ссылка в новой задаче