tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RemoteWorkerControllerParent.h (2680B)


      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_remoteworkercontrollerparent_h__
      8 #define mozilla_dom_remoteworkercontrollerparent_h__
      9 
     10 #include <functional>
     11 
     12 #include "RemoteWorkerController.h"
     13 #include "mozilla/RefPtr.h"
     14 #include "mozilla/dom/PRemoteWorkerControllerParent.h"
     15 #include "nsISupportsImpl.h"
     16 
     17 namespace mozilla::dom {
     18 
     19 /**
     20 * PBackground-resident proxy used by ServiceWorkerManager because canonical
     21 * ServiceWorkerManager state exists on the parent process main thread but the
     22 * RemoteWorkerController API is used from the parent process PBackground
     23 * thread.
     24 */
     25 class RemoteWorkerControllerParent final : public PRemoteWorkerControllerParent,
     26                                           public RemoteWorkerObserver {
     27  friend class PRemoteWorkerControllerParent;
     28 
     29 public:
     30  NS_INLINE_DECL_REFCOUNTING(RemoteWorkerControllerParent, override)
     31 
     32  explicit RemoteWorkerControllerParent(
     33      const RemoteWorkerData& aRemoteWorkerData);
     34 
     35  // Returns the corresponding RemoteWorkerParent (if any).
     36  RefPtr<RemoteWorkerParent> GetRemoteWorkerParent() const;
     37 
     38  void MaybeSendSetServiceWorkerSkipWaitingFlag(
     39      std::function<void(bool)>&& aCallback);
     40 
     41 private:
     42  ~RemoteWorkerControllerParent();
     43 
     44  PFetchEventOpParent* AllocPFetchEventOpParent(
     45      const ParentToParentServiceWorkerFetchEventOpArgs& aArgs);
     46 
     47  mozilla::ipc::IPCResult RecvPFetchEventOpConstructor(
     48      PFetchEventOpParent* aActor,
     49      const ParentToParentServiceWorkerFetchEventOpArgs& aArgs) override;
     50 
     51  bool DeallocPFetchEventOpParent(PFetchEventOpParent* aActor);
     52 
     53  mozilla::ipc::IPCResult RecvExecServiceWorkerOp(
     54      ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve);
     55 
     56  mozilla::ipc::IPCResult RecvShutdown(ShutdownResolver&& aResolve);
     57 
     58  mozilla::ipc::IPCResult Recv__delete__() override;
     59 
     60  void ActorDestroy(ActorDestroyReason aReason) override;
     61 
     62  void CreationFailed() override;
     63 
     64  void CreationSucceeded() override;
     65 
     66  void ErrorReceived(const ErrorValue& aValue) override;
     67 
     68  void LockNotified(bool aCreated) final {
     69    // no-op for service workers
     70  }
     71 
     72  void WebTransportNotified(bool aCreated) final {
     73    // no-op for service workers
     74  }
     75 
     76  void Terminated() override;
     77 
     78  RefPtr<RemoteWorkerController> mRemoteWorkerController;
     79 
     80  bool mIPCActive = true;
     81 };
     82 
     83 }  // namespace mozilla::dom
     84 
     85 #endif  // mozilla_dom_remoteworkercontrollerparent_h__