зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1438211 P2 Implement nsGlobalWindowInner::GetOrCreateServiceWorkerRegistration(). r=asuth
--HG-- extra : rebase_source : 7fa79752d66f9955f574e49e094cdd7fff512306
This commit is contained in:
Родитель
0c368d6063
Коммит
9e928c88fb
|
@ -6435,6 +6435,28 @@ nsGlobalWindowInner::GetOrCreateServiceWorker(const ServiceWorkerDescriptor& aDe
|
|||
return ref.forget();
|
||||
}
|
||||
|
||||
RefPtr<ServiceWorkerRegistration>
|
||||
nsGlobalWindowInner::GetOrCreateServiceWorkerRegistration(const ServiceWorkerRegistrationDescriptor& aDescriptor)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
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::CreateForMainThread(this, aDescriptor);
|
||||
}
|
||||
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindowInner::FireDelayedDOMEvents()
|
||||
{
|
||||
|
|
|
@ -356,6 +356,9 @@ public:
|
|||
virtual RefPtr<mozilla::dom::ServiceWorker>
|
||||
GetOrCreateServiceWorker(const mozilla::dom::ServiceWorkerDescriptor& aDescriptor) override;
|
||||
|
||||
RefPtr<mozilla::dom::ServiceWorkerRegistration>
|
||||
GetOrCreateServiceWorkerRegistration(const mozilla::dom::ServiceWorkerRegistrationDescriptor& aDescriptor) override;
|
||||
|
||||
void NoteCalledRegisterForServiceWorkerScope(const nsACString& aScope);
|
||||
|
||||
virtual nsresult FireDelayedDOMEvents() override;
|
||||
|
|
|
@ -30,6 +30,7 @@ NS_IMPL_ADDREF_INHERITED(ServiceWorkerRegistration, DOMEventTargetHelper)
|
|||
NS_IMPL_RELEASE_INHERITED(ServiceWorkerRegistration, DOMEventTargetHelper)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerRegistration)
|
||||
NS_INTERFACE_MAP_ENTRY(ServiceWorkerRegistration)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
ServiceWorkerRegistration::ServiceWorkerRegistration(nsIGlobalObject* aGlobal,
|
||||
|
|
|
@ -26,6 +26,9 @@ class PushManager;
|
|||
class WorkerPrivate;
|
||||
class ServiceWorker;
|
||||
|
||||
#define NS_DOM_SERVICEWORKERREGISTRATION_IID \
|
||||
{0x4578a90e, 0xa427, 0x4237, {0x98, 0x4a, 0xbd, 0x98, 0xe4, 0xcd, 0x5f, 0x3a}}
|
||||
|
||||
class ServiceWorkerRegistration final : public DOMEventTargetHelper
|
||||
{
|
||||
public:
|
||||
|
@ -60,6 +63,7 @@ public:
|
|||
GetPushManager(JSContext* aCx, ErrorResult& aRv) = 0;
|
||||
};
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_SERVICEWORKERREGISTRATION_IID)
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerRegistration, DOMEventTargetHelper)
|
||||
|
||||
|
@ -133,6 +137,7 @@ private:
|
|||
RefPtr<PushManager> mPushManager;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(ServiceWorkerRegistration, NS_DOM_SERVICEWORKERREGISTRATION_IID)
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче