Bug 1726269: part 1) Repeatedly call `::OleSetClipboard` for the Windows-specific...
[gecko.git] / dom / serviceworkers / ServiceWorkerRegistrationProxy.h
blob4614b432b9ce7a91ca5148e3c9599e53d1f84827
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 moz_dom_ServiceWorkerRegistrationProxy_h
8 #define moz_dom_ServiceWorkerRegistrationProxy_h
10 #include "mozilla/dom/PServiceWorkerRegistrationParent.h"
11 #include "nsProxyRelease.h"
12 #include "ServiceWorkerRegistrationDescriptor.h"
13 #include "ServiceWorkerRegistrationListener.h"
14 #include "ServiceWorkerUtils.h"
16 namespace mozilla {
17 namespace dom {
19 class ServiceWorkerRegistrationInfo;
20 class ServiceWorkerRegistrationParent;
22 class ServiceWorkerRegistrationProxy final
23 : public ServiceWorkerRegistrationListener {
24 // Background thread only
25 RefPtr<ServiceWorkerRegistrationParent> mActor;
27 // Written on background thread and read on main thread
28 nsCOMPtr<nsISerialEventTarget> mEventTarget;
30 // Main thread only
31 ServiceWorkerRegistrationDescriptor mDescriptor;
32 nsMainThreadPtrHandle<ServiceWorkerRegistrationInfo> mReg;
34 ~ServiceWorkerRegistrationProxy();
36 // Background thread methods
37 void MaybeShutdownOnBGThread();
39 void UpdateStateOnBGThread(
40 const ServiceWorkerRegistrationDescriptor& aDescriptor);
42 void FireUpdateFoundOnBGThread();
44 // Main thread methods
45 void InitOnMainThread();
47 void MaybeShutdownOnMainThread();
49 void StopListeningOnMainThread();
51 // The timer callback to perform the delayed update
52 class DelayedUpdate;
53 RefPtr<DelayedUpdate> mDelayedUpdate;
55 // ServiceWorkerRegistrationListener interface
56 void UpdateState(
57 const ServiceWorkerRegistrationDescriptor& aDescriptor) override;
59 void FireUpdateFound() override;
61 void RegistrationCleared() override;
63 void GetScope(nsAString& aScope) const override;
65 bool MatchesDescriptor(
66 const ServiceWorkerRegistrationDescriptor& aDescriptor) override;
68 public:
69 explicit ServiceWorkerRegistrationProxy(
70 const ServiceWorkerRegistrationDescriptor& aDescriptor);
72 void Init(ServiceWorkerRegistrationParent* aActor);
74 void RevokeActor(ServiceWorkerRegistrationParent* aActor);
76 RefPtr<GenericPromise> Unregister();
78 RefPtr<ServiceWorkerRegistrationPromise> Update(
79 const nsCString& aNewestWorkerScriptUrl);
81 RefPtr<GenericPromise> SetNavigationPreloadEnabled(const bool& aEnabled);
83 RefPtr<GenericPromise> SetNavigationPreloadHeader(const nsCString& aHeader);
85 RefPtr<NavigationPreloadStatePromise> GetNavigationPreloadState();
87 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ServiceWorkerRegistrationProxy,
88 override);
91 } // namespace dom
92 } // namespace mozilla
94 #endif // moz_dom_ServiceWorkerRegistrationProxy_h