tor-browser

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

SharedWorkerParent.h (2235B)


      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_dom_SharedWorkerParent_h
      8 #define mozilla_dom_dom_SharedWorkerParent_h
      9 
     10 #include "mozilla/dom/PSharedWorkerParent.h"
     11 #include "mozilla/dom/quota/CheckedUnsafePtr.h"
     12 #include "mozilla/ipc/BackgroundUtils.h"
     13 #include "nsISupportsImpl.h"
     14 
     15 namespace mozilla::dom {
     16 
     17 class MessagePortIdentifier;
     18 class RemoteWorkerData;
     19 class SharedWorkerManagerWrapper;
     20 
     21 /**
     22 * PBackground actor that relays life-cycle events (freeze/thaw, suspend/resume,
     23 * close) to the PBackground SharedWorkerManager and relays error/termination
     24 * back to the child.
     25 */
     26 class SharedWorkerParent final
     27    : public mozilla::dom::PSharedWorkerParent,
     28      public SupportsCheckedUnsafePtr<CheckIf<DiagnosticAssertEnabled>> {
     29 public:
     30  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedWorkerParent)
     31 
     32  SharedWorkerParent();
     33 
     34  void Initialize(const RemoteWorkerData& aData, uint64_t aWindowID,
     35                  const MessagePortIdentifier& aPortIdentifier);
     36 
     37  void ManagerCreated(
     38      already_AddRefed<SharedWorkerManagerWrapper> aWorkerManagerWrapper);
     39 
     40  void ErrorPropagation(nsresult aError);
     41 
     42  void MismatchOptionsErrorPropagation();
     43 
     44  mozilla::ipc::IPCResult RecvClose();
     45 
     46  mozilla::ipc::IPCResult RecvSuspend();
     47 
     48  mozilla::ipc::IPCResult RecvResume();
     49 
     50  mozilla::ipc::IPCResult RecvFreeze();
     51 
     52  mozilla::ipc::IPCResult RecvThaw();
     53 
     54  bool IsSuspended() const { return mSuspended; }
     55 
     56  bool IsFrozen() const { return mFrozen; }
     57 
     58  uint64_t WindowID() const { return mWindowID; }
     59 
     60 private:
     61  ~SharedWorkerParent();
     62 
     63  void ActorDestroy(IProtocol::ActorDestroyReason aReason) override;
     64 
     65  nsCOMPtr<nsIEventTarget> mBackgroundEventTarget;
     66  RefPtr<SharedWorkerManagerWrapper> mWorkerManagerWrapper;
     67 
     68  enum {
     69    eInit,
     70    ePending,
     71    eActive,
     72    eClosed,
     73  } mStatus;
     74 
     75  uint64_t mWindowID;
     76 
     77  bool mSuspended;
     78  bool mFrozen;
     79 };
     80 
     81 }  // namespace mozilla::dom
     82 
     83 #endif  // mozilla_dom_dom_SharedWorkerParent_h