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/. */
6 
7 #ifndef mozilla_dom_RemoteWorkerParent_h
8 #define mozilla_dom_RemoteWorkerParent_h
9 
10 #include "mozilla/dom/PRemoteWorkerParent.h"
11 
12 namespace mozilla {
13 namespace dom {
14 
15 class RemoteWorkerController;
16 
17 /**
18  * PBackground-managed parent actor that is mutually associated with a single
19  * RemoteWorkerController.  Relays error/close events to the controller and in
20  * turns is told life-cycle events.
21  */
22 class RemoteWorkerParent final : public PRemoteWorkerParent {
23   friend class PRemoteWorkerParent;
24 
25  public:
26   NS_INLINE_DECL_REFCOUNTING(RemoteWorkerParent)
27 
28   RemoteWorkerParent();
29 
30   void Initialize(bool aAlreadyRegistered = false);
31 
32   void SetController(RemoteWorkerController* aController);
33 
34   void MaybeSendDelete();
35 
36  private:
37   ~RemoteWorkerParent();
38 
39   already_AddRefed<PFetchEventOpProxyParent> AllocPFetchEventOpProxyParent(
40       const ParentToChildServiceWorkerFetchEventOpArgs& aArgs);
41 
42   void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override;
43 
44   mozilla::ipc::IPCResult RecvError(const ErrorValue& aValue);
45 
46   mozilla::ipc::IPCResult RecvNotifyLock(const bool& aCreated);
47 
48   mozilla::ipc::IPCResult RecvClose();
49 
50   mozilla::ipc::IPCResult RecvCreated(const bool& aStatus);
51 
52   mozilla::ipc::IPCResult RecvSetServiceWorkerSkipWaitingFlag(
53       SetServiceWorkerSkipWaitingFlagResolver&& aResolve);
54 
55   bool mDeleteSent = false;
56   RefPtr<RemoteWorkerController> mController;
57 };
58 
59 }  // namespace dom
60 }  // namespace mozilla
61 
62 #endif  // mozilla_dom_RemoteWorkerParent_h
63