Bug 1066410 - Serious color distortion happened when plays WebRTC. r=jesup, a=bajaj
[gecko.git] / dom / workers / ServiceWorkerRegistration.h
blob59d9633819f1a104f036da3eeb3e7f4d30c29c47
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_ServiceWorkerRegistration_h
8 #define mozilla_dom_ServiceWorkerRegistration_h
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/ServiceWorkerCommon.h"
13 class nsPIDOMWindow;
15 namespace mozilla {
16 namespace dom {
18 class Promise;
20 namespace workers {
21 class ServiceWorker;
24 class ServiceWorkerRegistration MOZ_FINAL : public DOMEventTargetHelper
26 public:
27 NS_DECL_ISUPPORTS_INHERITED
28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerRegistration,
29 DOMEventTargetHelper)
31 IMPL_EVENT_HANDLER(updatefound)
33 ServiceWorkerRegistration(nsPIDOMWindow* aWindow,
34 const nsAString& aScope);
36 JSObject*
37 WrapObject(JSContext* aCx);
39 already_AddRefed<workers::ServiceWorker>
40 GetInstalling();
42 already_AddRefed<workers::ServiceWorker>
43 GetWaiting();
45 already_AddRefed<workers::ServiceWorker>
46 GetActive();
48 void
49 GetScope(nsAString& aScope) const
51 aScope = mScope;
54 already_AddRefed<Promise>
55 Unregister(ErrorResult& aRv);
57 // Useful methods for ServiceWorkerManager:
59 nsIURI*
60 GetDocumentURI() const;
62 void
63 InvalidateWorkerReference(WhichServiceWorker aWhichOnes);
65 // DOMEventTargethelper
66 virtual void DisconnectFromOwner() MOZ_OVERRIDE;
68 private:
69 ~ServiceWorkerRegistration();
71 already_AddRefed<workers::ServiceWorker>
72 GetWorkerReference(WhichServiceWorker aWhichOne);
74 void
75 StartListeningForEvents();
77 void
78 StopListeningForEvents();
80 // The following properties are cached here to ensure JS equality is satisfied
81 // instead of acquiring a new worker instance from the ServiceWorkerManager
82 // for every access. A null value is considered a cache miss.
83 // These three may change to a new worker at any time.
84 nsRefPtr<workers::ServiceWorker> mInstallingWorker;
85 nsRefPtr<workers::ServiceWorker> mWaitingWorker;
86 nsRefPtr<workers::ServiceWorker> mActiveWorker;
88 const nsString mScope;
89 bool mListeningForEvents;
92 } // namespace dom
93 } // namespace mozilla
95 #endif /* mozilla_dom_ServiceWorkerRegistration_h */