mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1454646 P1 Add a ServiceWorkerContainer::Inner scaffold. r=baku
This commit is contained in:
parent
254334df5b
commit
a7ef225557
@ -24,6 +24,7 @@
|
||||
#include "mozilla/dom/ServiceWorkerContainerBinding.h"
|
||||
|
||||
#include "ServiceWorker.h"
|
||||
#include "ServiceWorkerContainerImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -60,12 +61,16 @@ ServiceWorkerContainer::IsEnabled(JSContext* aCx, JSObject* aGlobal)
|
||||
already_AddRefed<ServiceWorkerContainer>
|
||||
ServiceWorkerContainer::Create(nsIGlobalObject* aGlobal)
|
||||
{
|
||||
RefPtr<ServiceWorkerContainer> ref = new ServiceWorkerContainer(aGlobal);
|
||||
RefPtr<Inner> inner = new ServiceWorkerContainerImpl();
|
||||
RefPtr<ServiceWorkerContainer> ref =
|
||||
new ServiceWorkerContainer(aGlobal, inner.forget());
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
ServiceWorkerContainer::ServiceWorkerContainer(nsIGlobalObject* aGlobal)
|
||||
ServiceWorkerContainer::ServiceWorkerContainer(nsIGlobalObject* aGlobal,
|
||||
already_AddRefed<ServiceWorkerContainer::Inner> aInner)
|
||||
: DOMEventTargetHelper(aGlobal)
|
||||
, mInner(aInner)
|
||||
{
|
||||
Maybe<ServiceWorkerDescriptor> controller = aGlobal->GetController();
|
||||
if (controller.isSome()) {
|
||||
|
@ -23,6 +23,25 @@ class ServiceWorker;
|
||||
class ServiceWorkerContainer final : public DOMEventTargetHelper
|
||||
{
|
||||
public:
|
||||
class Inner
|
||||
{
|
||||
public:
|
||||
virtual RefPtr<ServiceWorkerRegistrationPromise>
|
||||
Register(const nsAString& aScriptURL,
|
||||
const RegistrationOptions& aOptions) = 0;
|
||||
|
||||
virtual RefPtr<ServiceWorkerRegistrationPromise>
|
||||
GetRegistration(const nsAString& aURL) = 0;
|
||||
|
||||
virtual RefPtr<ServiceWorkerRegistrationListPromise>
|
||||
GetRegistrations() = 0;
|
||||
|
||||
virtual RefPtr<ServiceWorkerRegistrationPromise>
|
||||
GetReady() = 0;
|
||||
|
||||
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
||||
};
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerContainer, DOMEventTargetHelper)
|
||||
|
||||
@ -69,10 +88,13 @@ public:
|
||||
ControllerChanged(ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
explicit ServiceWorkerContainer(nsIGlobalObject* aGlobal);
|
||||
ServiceWorkerContainer(nsIGlobalObject* aGlobal,
|
||||
already_AddRefed<ServiceWorkerContainer::Inner> aInner);
|
||||
|
||||
~ServiceWorkerContainer();
|
||||
|
||||
RefPtr<Inner> mInner;
|
||||
|
||||
// This only changes when a worker hijacks everything in its scope by calling
|
||||
// claim.
|
||||
RefPtr<ServiceWorker> mControllerWorker;
|
||||
|
42
dom/serviceworkers/ServiceWorkerContainerImpl.cpp
Normal file
42
dom/serviceworkers/ServiceWorkerContainerImpl.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ServiceWorkerContainerImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
ServiceWorkerContainerImpl::Register(const nsAString& aScriptURL,
|
||||
const RegistrationOptions& aOptions)
|
||||
{
|
||||
// TODO
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
ServiceWorkerContainerImpl::GetRegistration(const nsAString& aURL)
|
||||
{
|
||||
// TODO
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationListPromise>
|
||||
ServiceWorkerContainerImpl::GetRegistrations()
|
||||
{
|
||||
// TODO
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
ServiceWorkerContainerImpl::GetReady()
|
||||
{
|
||||
// TODO
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
40
dom/serviceworkers/ServiceWorkerContainerImpl.h
Normal file
40
dom/serviceworkers/ServiceWorkerContainerImpl.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_serviceworkercontainerimpl_h__
|
||||
#define mozilla_dom_serviceworkercontainerimpl_h__
|
||||
|
||||
#include "ServiceWorkerContainer.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// Lightweight serviceWorker APIs collection.
|
||||
class ServiceWorkerContainerImpl final : public ServiceWorkerContainer::Inner
|
||||
{
|
||||
~ServiceWorkerContainerImpl() = default;
|
||||
|
||||
public:
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
Register(const nsAString& aScriptURL,
|
||||
const RegistrationOptions& aOptions) override;
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
GetRegistration(const nsAString& aURL) override;
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationListPromise>
|
||||
GetRegistrations() override;
|
||||
|
||||
RefPtr<ServiceWorkerRegistrationPromise>
|
||||
GetReady() override;
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerContainerImpl, override)
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_serviceworkercontainerimpl_h__ */
|
@ -4,6 +4,9 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_serviceworkerregistrationimpl_h
|
||||
#define mozilla_dom_serviceworkerregistrationimpl_h
|
||||
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
@ -161,3 +164,5 @@ private:
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
||||
#endif // mozilla_dom_serviceworkerregistrationimpl_h
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -18,6 +19,9 @@ class ServiceWorkerRegistrationDescriptor;
|
||||
typedef MozPromise<ServiceWorkerRegistrationDescriptor, nsresult, false>
|
||||
ServiceWorkerRegistrationPromise;
|
||||
|
||||
typedef MozPromise<nsTArray<ServiceWorkerRegistrationDescriptor>, nsresult, false>
|
||||
ServiceWorkerRegistrationListPromise;
|
||||
|
||||
bool
|
||||
ServiceWorkerParentInterceptEnabled();
|
||||
|
||||
|
@ -29,6 +29,7 @@ EXPORTS.mozilla.dom += [
|
||||
UNIFIED_SOURCES += [
|
||||
'ServiceWorker.cpp',
|
||||
'ServiceWorkerContainer.cpp',
|
||||
'ServiceWorkerContainerImpl.cpp',
|
||||
'ServiceWorkerDescriptor.cpp',
|
||||
'ServiceWorkerEvents.cpp',
|
||||
'ServiceWorkerInfo.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user