tor-browser

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

JSProcessActorProtocol.h (2202B)


      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_JSProcessActorProtocol_h
      8 #define mozilla_dom_JSProcessActorProtocol_h
      9 
     10 #include "mozilla/dom/BrowsingContext.h"
     11 #include "mozilla/dom/JSActorService.h"
     12 #include "nsIObserver.h"
     13 #include "nsString.h"
     14 #include "nsTArray.h"
     15 
     16 namespace mozilla {
     17 class ErrorResult;
     18 
     19 namespace dom {
     20 
     21 struct ProcessActorOptions;
     22 class JSProcessActorInfo;
     23 class EventTarget;
     24 class JSActorProtocolUtils;
     25 
     26 /**
     27 * Object corresponding to a single process actor protocol
     28 *
     29 * This object also can act as a carrier for methods and other state related to
     30 * a single protocol managed by the JSActorService.
     31 */
     32 class JSProcessActorProtocol final : public JSActorProtocol,
     33                                     public nsIObserver {
     34 public:
     35  NS_DECL_NSIOBSERVER
     36  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     37  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(JSProcessActorProtocol, nsIObserver)
     38 
     39  static already_AddRefed<JSProcessActorProtocol> FromIPC(
     40      const JSProcessActorInfo& aInfo);
     41  JSProcessActorInfo ToIPC();
     42 
     43  static already_AddRefed<JSProcessActorProtocol> FromWebIDLOptions(
     44      const nsACString& aName, const ProcessActorOptions& aOptions,
     45      ErrorResult& aRv);
     46 
     47  struct ParentSide : public Sided {};
     48 
     49  struct ChildSide : public Sided {
     50    nsTArray<nsCString> mObservers;
     51  };
     52 
     53  const ParentSide& Parent() const override { return mParent; }
     54  const ChildSide& Child() const override { return mChild; }
     55 
     56  void AddObservers();
     57  void RemoveObservers();
     58  bool Matches(const nsACString& aRemoteType, ErrorResult& aRv);
     59 
     60 private:
     61  explicit JSProcessActorProtocol(const nsACString& aName)
     62      : JSActorProtocol(aName) {}
     63  ~JSProcessActorProtocol() = default;
     64 
     65  bool mIncludeParent = false;
     66 
     67  friend class JSActorProtocolUtils;
     68 
     69  ParentSide mParent;
     70  ChildSide mChild;
     71 };
     72 
     73 }  // namespace dom
     74 }  // namespace mozilla
     75 
     76 #endif  // mozilla_dom_JSProcessActorProtocol_h