2015-05-03 22:32:37 +03: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: */
|
2013-11-20 03:14:07 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2018-01-27 00:08:59 +03:00
|
|
|
#ifndef mozilla_dom_serviceworker_h__
|
|
|
|
#define mozilla_dom_serviceworker_h__
|
2013-11-20 03:14:07 +04:00
|
|
|
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
|
|
|
#include "mozilla/dom/ServiceWorkerBinding.h" // For ServiceWorkerState.
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowInner;
|
2013-11-20 03:14:07 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-02-19 19:40:21 +03:00
|
|
|
class ServiceWorkerInfo;
|
|
|
|
class ServiceWorkerManager;
|
2013-11-20 03:14:07 +04:00
|
|
|
class SharedWorker;
|
|
|
|
|
2014-11-06 18:57:57 +03:00
|
|
|
bool
|
|
|
|
ServiceWorkerVisible(JSContext* aCx, JSObject* aObj);
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ServiceWorker final : public DOMEventTargetHelper
|
2013-11-20 03:14:07 +04:00
|
|
|
{
|
2016-03-04 03:37:57 +03:00
|
|
|
friend class ServiceWorkerInfo;
|
2013-11-20 03:14:07 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(statechange)
|
|
|
|
IMPL_EVENT_HANDLER(error)
|
|
|
|
|
|
|
|
virtual JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-11-20 03:14:07 +04:00
|
|
|
|
|
|
|
ServiceWorkerState
|
|
|
|
State() const
|
|
|
|
{
|
|
|
|
return mState;
|
|
|
|
}
|
|
|
|
|
2014-12-19 14:25:56 +03:00
|
|
|
void
|
|
|
|
SetState(ServiceWorkerState aState)
|
|
|
|
{
|
|
|
|
mState = aState;
|
|
|
|
}
|
|
|
|
|
2013-11-20 03:14:07 +04:00
|
|
|
void
|
2015-02-19 19:40:21 +03:00
|
|
|
GetScriptURL(nsString& aURL) const;
|
2013-11-20 03:14:07 +04:00
|
|
|
|
2014-12-19 14:25:56 +03:00
|
|
|
void
|
2015-02-19 19:40:21 +03:00
|
|
|
DispatchStateChange(ServiceWorkerState aState)
|
2014-12-19 14:25:56 +03:00
|
|
|
{
|
|
|
|
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("statechange"));
|
|
|
|
}
|
|
|
|
|
2015-02-09 20:42:00 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#undef PostMessage
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
2017-02-03 13:00:38 +03:00
|
|
|
const Sequence<JSObject*>& aTransferable, ErrorResult& aRv);
|
2015-02-09 20:42:00 +03:00
|
|
|
|
2013-11-20 03:14:07 +04:00
|
|
|
private:
|
2016-03-04 03:37:57 +03:00
|
|
|
// This class can only be created from ServiceWorkerInfo::GetOrCreateInstance().
|
2016-01-30 20:05:36 +03:00
|
|
|
ServiceWorker(nsPIDOMWindowInner* aWindow, ServiceWorkerInfo* aInfo);
|
2013-11-20 03:14:07 +04:00
|
|
|
|
|
|
|
// This class is reference-counted and will be destroyed from Release().
|
|
|
|
~ServiceWorker();
|
|
|
|
|
|
|
|
ServiceWorkerState mState;
|
2015-10-18 08:24:48 +03:00
|
|
|
const RefPtr<ServiceWorkerInfo> mInfo;
|
2013-11-20 03:14:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2018-01-27 00:08:59 +03:00
|
|
|
#endif // mozilla_dom_serviceworker_h__
|