2014-08-19 13:56:00 +00:00
|
|
|
/* -*- 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_ServiceWorkerRegistration_h
|
|
|
|
#define mozilla_dom_ServiceWorkerRegistration_h
|
|
|
|
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2015-01-26 18:31:38 +00:00
|
|
|
#include "mozilla/dom/ServiceWorkerBinding.h"
|
2014-08-19 13:56:00 +00:00
|
|
|
#include "mozilla/dom/ServiceWorkerCommon.h"
|
2016-06-23 08:53:14 +00:00
|
|
|
#include "mozilla/dom/workers/bindings/WorkerHolder.h"
|
2016-05-05 10:21:00 +00:00
|
|
|
#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2015-06-26 01:50:24 +00:00
|
|
|
// Support for Notification API extension.
|
|
|
|
#include "mozilla/dom/NotificationBinding.h"
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
class nsPIDOMWindowInner;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Promise;
|
2015-04-11 03:19:28 +00:00
|
|
|
class PushManager;
|
2015-04-08 22:22:36 +00:00
|
|
|
class WorkerListener;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
|
|
|
namespace workers {
|
|
|
|
class ServiceWorker;
|
2015-04-08 22:22:36 +00:00
|
|
|
class WorkerPrivate;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace workers
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2015-04-08 20:13:32 +00:00
|
|
|
// Used by ServiceWorkerManager to notify ServiceWorkerRegistrations of
|
|
|
|
// updatefound event and invalidating ServiceWorker instances.
|
|
|
|
class ServiceWorkerRegistrationListener
|
|
|
|
{
|
|
|
|
public:
|
2017-01-25 19:51:34 +00:00
|
|
|
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
2015-04-08 20:13:32 +00:00
|
|
|
|
|
|
|
virtual void
|
|
|
|
UpdateFound() = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
InvalidateWorkers(WhichServiceWorker aWhichOnes) = 0;
|
|
|
|
|
2016-11-21 02:14:54 +00:00
|
|
|
virtual void
|
|
|
|
TransitionWorker(WhichServiceWorker aWhichOne) = 0;
|
|
|
|
|
2015-11-23 18:38:08 +00:00
|
|
|
virtual void
|
|
|
|
RegistrationRemoved() = 0;
|
|
|
|
|
2015-04-08 20:13:32 +00:00
|
|
|
virtual void
|
|
|
|
GetScope(nsAString& aScope) const = 0;
|
|
|
|
};
|
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
class ServiceWorkerRegistration : public DOMEventTargetHelper
|
2014-08-19 13:56:00 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(updatefound)
|
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
static bool
|
|
|
|
Visible(JSContext* aCx, JSObject* aObj);
|
|
|
|
|
|
|
|
static bool
|
|
|
|
NotificationAPIVisible(JSContext* aCx, JSObject* aObj);
|
|
|
|
|
|
|
|
|
|
|
|
static already_AddRefed<ServiceWorkerRegistration>
|
|
|
|
CreateForMainThread(nsPIDOMWindowInner* aWindow,
|
|
|
|
const nsAString& aScope);
|
|
|
|
|
|
|
|
static already_AddRefed<ServiceWorkerRegistration>
|
|
|
|
CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
|
|
|
|
const nsAString& aScope);
|
2014-08-19 13:56:00 +00:00
|
|
|
|
|
|
|
JSObject*
|
2016-06-12 14:26:51 +00:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2015-04-03 22:18:55 +00:00
|
|
|
virtual already_AddRefed<workers::ServiceWorker>
|
|
|
|
GetInstalling() = 0;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2015-04-03 22:18:55 +00:00
|
|
|
virtual already_AddRefed<workers::ServiceWorker>
|
|
|
|
GetWaiting() = 0;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2015-04-03 22:18:55 +00:00
|
|
|
virtual already_AddRefed<workers::ServiceWorker>
|
|
|
|
GetActive() = 0;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
virtual void
|
|
|
|
GetScope(nsAString& aScope) const = 0;
|
2015-04-03 22:18:55 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
virtual already_AddRefed<Promise>
|
|
|
|
Update(ErrorResult& aRv) = 0;
|
2015-03-20 01:09:10 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
virtual already_AddRefed<Promise>
|
|
|
|
Unregister(ErrorResult& aRv) = 0;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
virtual already_AddRefed<PushManager>
|
|
|
|
GetPushManager(JSContext* aCx, ErrorResult& aRv) = 0;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
virtual already_AddRefed<Promise>
|
2015-06-26 01:50:24 +00:00
|
|
|
ShowNotification(JSContext* aCx,
|
|
|
|
const nsAString& aTitle,
|
2015-06-26 01:50:24 +00:00
|
|
|
const NotificationOptions& aOptions,
|
2016-06-12 14:26:51 +00:00
|
|
|
ErrorResult& aRv) = 0;
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
virtual already_AddRefed<Promise>
|
|
|
|
GetNotifications(const GetNotificationOptions& aOptions,
|
|
|
|
ErrorResult& aRv) = 0;
|
2015-04-07 20:09:07 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
protected:
|
|
|
|
ServiceWorkerRegistration(nsPIDOMWindowInner* aWindow,
|
|
|
|
const nsAString& aScope);
|
2015-04-07 20:09:07 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
virtual ~ServiceWorkerRegistration()
|
|
|
|
{ }
|
2014-08-19 13:56:00 +00:00
|
|
|
|
2016-06-12 14:26:51 +00:00
|
|
|
const nsString mScope;
|
2015-04-03 22:18:55 +00:00
|
|
|
};
|
2015-04-11 03:19:28 +00:00
|
|
|
|
2014-08-19 13:56:00 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-04-03 22:18:55 +00:00
|
|
|
#endif /* mozilla_dom_ServiceWorkerRegistration_h */
|