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_ServiceWorkerProxy_h
8 #define moz_dom_ServiceWorkerProxy_h
10 #include "nsProxyRelease.h"
11 #include "ServiceWorkerDescriptor.h"
13 namespace mozilla::dom
{
17 class ServiceWorkerCloneData
;
18 class ServiceWorkerInfo
;
19 class ServiceWorkerParent
;
21 class ServiceWorkerProxy final
{
22 // Background thread only
23 RefPtr
<ServiceWorkerParent
> mActor
;
25 // Written on background thread and read on main thread
26 nsCOMPtr
<nsISerialEventTarget
> mEventTarget
;
29 ServiceWorkerDescriptor mDescriptor
;
30 nsMainThreadPtrHandle
<ServiceWorkerInfo
> mInfo
;
32 ~ServiceWorkerProxy();
34 // Background thread methods
35 void MaybeShutdownOnBGThread();
37 void SetStateOnBGThread(ServiceWorkerState aState
);
39 // Main thread methods
40 void InitOnMainThread();
42 void MaybeShutdownOnMainThread();
44 void StopListeningOnMainThread();
47 explicit ServiceWorkerProxy(const ServiceWorkerDescriptor
& aDescriptor
);
49 void Init(ServiceWorkerParent
* aActor
);
51 void RevokeActor(ServiceWorkerParent
* aActor
);
53 void PostMessage(RefPtr
<ServiceWorkerCloneData
>&& aData
,
54 const ClientInfo
& aClientInfo
, const ClientState
& aState
);
56 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ServiceWorkerProxy
);
59 } // namespace mozilla::dom
61 #endif // moz_dom_ServiceWorkerProxy_h