author | Ben Kelly <ben@wanderview.com> |
Tue, 17 Apr 2018 07:46:14 -0700 | |
changeset 414150 | d56a387c8b3645673cac34673eb63a585eb6d762 |
parent 414118 | 2eb8596e5602eeed82d6e7033eed210c45ce6136 |
child 414151 | e3a22120dd0c1864bc6b5d6a8c42d3d221ec3d34 |
push id | 33861 |
push user | ccoroiu@mozilla.com |
push date | Wed, 18 Apr 2018 10:50:38 +0000 |
treeherder | mozilla-central@4af4ae0aee55 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | baku |
bugs | 1454646 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/serviceworkers/ServiceWorkerContainer.cpp +++ b/dom/serviceworkers/ServiceWorkerContainer.cpp @@ -19,16 +19,17 @@ #include "mozilla/dom/DOMPrefs.h" #include "mozilla/dom/Navigator.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/ServiceWorker.h" #include "mozilla/dom/ServiceWorkerContainerBinding.h" #include "ServiceWorker.h" +#include "ServiceWorkerContainerImpl.h" namespace mozilla { namespace dom { NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerContainer) NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(ServiceWorkerContainer, DOMEventTargetHelper) @@ -55,22 +56,26 @@ ServiceWorkerContainer::IsEnabled(JSCont return DOMPrefs::ServiceWorkersEnabled(); } // static 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()) { mControllerWorker = aGlobal->GetOrCreateServiceWorker(controller.ref()); } } ServiceWorkerContainer::~ServiceWorkerContainer()
--- a/dom/serviceworkers/ServiceWorkerContainer.h +++ b/dom/serviceworkers/ServiceWorkerContainer.h @@ -18,16 +18,35 @@ namespace dom { class Promise; struct RegistrationOptions; class ServiceWorker; // Lightweight serviceWorker APIs collection. 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) IMPL_EVENT_HANDLER(controllerchange) IMPL_EVENT_HANDLER(error) IMPL_EVENT_HANDLER(message) static bool IsEnabled(JSContext* aCx, JSObject* aGlobal); @@ -64,20 +83,23 @@ public: void DisconnectFromOwner() override; // Invalidates |mControllerWorker| and dispatches a "controllerchange" // event. void 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; RefPtr<Promise> mReadyPromise; MozPromiseRequestHolder<ServiceWorkerRegistrationPromise> mReadyPromiseHolder; };
new file mode 100644 --- /dev/null +++ b/dom/serviceworkers/ServiceWorkerContainerImpl.cpp @@ -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
new file mode 100644 --- /dev/null +++ b/dom/serviceworkers/ServiceWorkerContainerImpl.h @@ -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__ */
--- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.h +++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.h @@ -1,14 +1,17 @@ /* -*- 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_serviceworkerregistrationimpl_h +#define mozilla_dom_serviceworkerregistrationimpl_h + #include "mozilla/dom/WorkerPrivate.h" #include "mozilla/Unused.h" #include "nsCycleCollectionParticipant.h" #include "nsIDocument.h" #include "nsPIDOMWindow.h" #include "ServiceWorkerManager.h" #include "ServiceWorkerRegistration.h" #include "ServiceWorkerRegistrationListener.h" @@ -156,8 +159,10 @@ private: ServiceWorkerRegistration* mOuter; const nsString mScope; RefPtr<WorkerListener> mListener; RefPtr<WeakWorkerRef> mWorkerRef; }; } // dom namespace } // mozilla namespace + +#endif // mozilla_dom_serviceworkerregistrationimpl_h
--- a/dom/serviceworkers/ServiceWorkerUtils.h +++ b/dom/serviceworkers/ServiceWorkerUtils.h @@ -3,26 +3,30 @@ /* 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_ServiceWorkerUtils_h #define _mozilla_dom_ServiceWorkerUtils_h #include "mozilla/MozPromise.h" #include "mozilla/dom/ServiceWorkerRegistrationDescriptor.h" +#include "nsTArray.h" namespace mozilla { namespace dom { class ServiceWorkerRegistrationData; class ServiceWorkerRegistrationDescriptor; typedef MozPromise<ServiceWorkerRegistrationDescriptor, nsresult, false> ServiceWorkerRegistrationPromise; +typedef MozPromise<nsTArray<ServiceWorkerRegistrationDescriptor>, nsresult, false> + ServiceWorkerRegistrationListPromise; + bool ServiceWorkerParentInterceptEnabled(); bool ServiceWorkerRegistrationDataIsValid(const ServiceWorkerRegistrationData& aData); } // namespace dom } // namespace mozilla
--- a/dom/serviceworkers/moz.build +++ b/dom/serviceworkers/moz.build @@ -24,16 +24,17 @@ EXPORTS.mozilla.dom += [ 'ServiceWorkerRegistrationDescriptor.h', 'ServiceWorkerRegistrationInfo.h', 'ServiceWorkerUtils.h', ] UNIFIED_SOURCES += [ 'ServiceWorker.cpp', 'ServiceWorkerContainer.cpp', + 'ServiceWorkerContainerImpl.cpp', 'ServiceWorkerDescriptor.cpp', 'ServiceWorkerEvents.cpp', 'ServiceWorkerInfo.cpp', 'ServiceWorkerInterceptController.cpp', 'ServiceWorkerJob.cpp', 'ServiceWorkerJobQueue.cpp', 'ServiceWorkerManager.cpp', 'ServiceWorkerManagerChild.cpp',