1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_workers_serviceworker_h__
7 #define mozilla_dom_workers_serviceworker_h__
9 #include "mozilla/DOMEventTargetHelper.h"
10 #include "mozilla/dom/BindingDeclarations.h"
11 #include "mozilla/dom/ServiceWorkerBinding.h" // For ServiceWorkerState.
24 class ServiceWorker MOZ_FINAL
: public DOMEventTargetHelper
26 friend class RuntimeService
;
28 NS_DECL_ISUPPORTS_INHERITED
29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorker
, DOMEventTargetHelper
)
31 IMPL_EVENT_HANDLER(statechange
)
32 IMPL_EVENT_HANDLER(error
)
35 WrapObject(JSContext
* aCx
) MOZ_OVERRIDE
;
44 GetScope(nsString
& aScope
) const
50 GetUrl(nsString
& aURL
) const
56 GetWorkerPrivate() const;
59 // This class can only be created from the RuntimeService.
60 ServiceWorker(nsPIDOMWindow
* aWindow
, SharedWorker
* aSharedWorker
);
62 // This class is reference-counted and will be destroyed from Release().
65 ServiceWorkerState mState
;
69 // To allow ServiceWorkers to potentially drop the backing DOMEventTargetHelper and
70 // re-instantiate it later, they simply own a SharedWorker member that
71 // can be released and recreated as required rather than re-implement some of
72 // the SharedWorker logic.
73 nsRefPtr
<SharedWorker
> mSharedWorker
;
76 } // namespace workers
78 } // namespace mozilla
80 #endif // mozilla_dom_workers_serviceworker_h__