tor-browser

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

DominatorTree.h (2150B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef mozilla_devtools_DominatorTree__
      7 #define mozilla_devtools_DominatorTree__
      8 
      9 #include "mozilla/devtools/HeapSnapshot.h"
     10 #include "mozilla/dom/BindingDeclarations.h"
     11 #include "js/UbiNodeDominatorTree.h"
     12 #include "nsWrapperCache.h"
     13 
     14 namespace mozilla {
     15 class ErrorResult;
     16 
     17 namespace devtools {
     18 
     19 class DominatorTree final : public nsISupports, public nsWrapperCache {
     20 protected:
     21  nsCOMPtr<nsISupports> mParent;
     22 
     23  virtual ~DominatorTree() {}
     24 
     25 private:
     26  JS::ubi::DominatorTree mDominatorTree;
     27  RefPtr<HeapSnapshot> mHeapSnapshot;
     28 
     29 public:
     30  explicit DominatorTree(JS::ubi::DominatorTree&& aDominatorTree,
     31                         HeapSnapshot* aHeapSnapshot, nsISupports* aParent)
     32      : mParent(aParent),
     33        mDominatorTree(std::move(aDominatorTree)),
     34        mHeapSnapshot(aHeapSnapshot) {
     35    MOZ_ASSERT(aParent);
     36    MOZ_ASSERT(aHeapSnapshot);
     37  };
     38 
     39  NS_DECL_CYCLE_COLLECTING_ISUPPORTS;
     40  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(DominatorTree);
     41 
     42  nsISupports* GetParentObject() const { return mParent; }
     43 
     44  virtual JSObject* WrapObject(JSContext* aCx,
     45                               JS::Handle<JSObject*> aGivenProto) override;
     46 
     47  // readonly attribute NodeId root
     48  uint64_t Root() const { return mDominatorTree.root().identifier(); }
     49 
     50  // [Throws] NodeSize getRetainedSize(NodeId node)
     51  dom::Nullable<uint64_t> GetRetainedSize(uint64_t aNodeId, ErrorResult& aRv);
     52 
     53  // [Throws] sequence<NodeId>? getImmediatelyDominated(NodeId node);
     54  void GetImmediatelyDominated(uint64_t aNodeId,
     55                               dom::Nullable<nsTArray<uint64_t>>& aOutDominated,
     56                               ErrorResult& aRv);
     57 
     58  // NodeId? getImmediateDominator(NodeId node);
     59  dom::Nullable<uint64_t> GetImmediateDominator(uint64_t aNodeId) const;
     60 };
     61 
     62 }  // namespace devtools
     63 }  // namespace mozilla
     64 
     65 #endif  // mozilla_devtools_DominatorTree__