зеркало из 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();
|
||||
}
|
||||
|
||||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче