[PM] Always create the SystemNode singleton.

The SystemNode singleton is currently created on demand by the first
call to "Graph::FindOrCreateSystemNode". This is problematic because
some policies might register themselves as SystemNodeObserver without
this node ever being created. This CL causes the SystemNode to be
created by default when setting up the graph.

Change-Id: Ibdd9af2821df87e1c18197ad9f424ec69b5d5a8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2951241
Reviewed-by: Chris Hamilton <[email protected]>
Commit-Queue: Sébastien Marchand <[email protected]>
Cr-Commit-Position: refs/heads/master@{#892575}
diff --git a/components/performance_manager/decorators/frame_visibility_decorator.cc b/components/performance_manager/decorators/frame_visibility_decorator.cc
index 283960d..4b50883 100644
--- a/components/performance_manager/decorators/frame_visibility_decorator.cc
+++ b/components/performance_manager/decorators/frame_visibility_decorator.cc
@@ -51,7 +51,7 @@
 FrameVisibilityDecorator::~FrameVisibilityDecorator() = default;
 
 void FrameVisibilityDecorator::OnPassedToGraph(Graph* graph) {
-  DCHECK(graph->IsEmpty());
+  DCHECK(graph->HasOnlySystemNode());
   graph->AddPageNodeObserver(this);
   graph->AddFrameNodeObserver(this);
 }
diff --git a/components/performance_manager/decorators/page_load_tracker_decorator.cc b/components/performance_manager/decorators/page_load_tracker_decorator.cc
index e453186..568f563 100644
--- a/components/performance_manager/decorators/page_load_tracker_decorator.cc
+++ b/components/performance_manager/decorators/page_load_tracker_decorator.cc
@@ -169,7 +169,7 @@
   // This observer presumes that it's been added before any nodes exist in the
   // graph.
   // TODO(chrisha): Add graph introspection functions to Graph.
-  DCHECK(GraphImpl::FromGraph(graph)->nodes().empty());
+  DCHECK(graph->HasOnlySystemNode());
   graph->AddFrameNodeObserver(this);
   graph->AddProcessNodeObserver(this);
 }
diff --git a/components/performance_manager/decorators/process_metrics_decorator.cc b/components/performance_manager/decorators/process_metrics_decorator.cc
index 1b96b9c6..dccb10a 100644
--- a/components/performance_manager/decorators/process_metrics_decorator.cc
+++ b/components/performance_manager/decorators/process_metrics_decorator.cc
@@ -178,7 +178,7 @@
   }
 
   GraphImpl::FromGraph(graph_)
-      ->FindOrCreateSystemNodeImpl()
+      ->GetSystemNodeImpl()
       ->OnProcessMemoryMetricsAvailable();
   refresh_timer_.Reset();
 }
diff --git a/components/performance_manager/execution_context/execution_context_registry_impl.cc b/components/performance_manager/execution_context/execution_context_registry_impl.cc
index cd59c74..be201b6 100644
--- a/components/performance_manager/execution_context/execution_context_registry_impl.cc
+++ b/components/performance_manager/execution_context/execution_context_registry_impl.cc
@@ -175,7 +175,7 @@
 
 void ExecutionContextRegistryImpl::OnPassedToGraph(Graph* graph) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  DCHECK(graph->IsEmpty());
+  DCHECK(graph->HasOnlySystemNode());
   graph->RegisterObject(this);
   graph->AddFrameNodeObserver(this);
   graph->AddWorkerNodeObserver(this);
diff --git a/components/performance_manager/graph/graph_impl.cc b/components/performance_manager/graph/graph_impl.cc
index 7f8b729..204ca72 100644
--- a/components/performance_manager/graph/graph_impl.cc
+++ b/components/performance_manager/graph/graph_impl.cc
@@ -182,6 +182,11 @@
   DCHECK(nodes_.empty());
 }
 
+void GraphImpl::SetUp() {
+  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+  CreateSystemNode();
+}
+
 void GraphImpl::TearDown() {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
 
@@ -286,9 +291,10 @@
   registered_objects_.UnregisterObject(object);
 }
 
-const SystemNode* GraphImpl::FindOrCreateSystemNode() {
+const SystemNode* GraphImpl::GetSystemNode() const {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  return FindOrCreateSystemNodeImpl();
+  DCHECK(system_node_.get());
+  return system_node_.get();
 }
 
 std::vector<const ProcessNode*> GraphImpl::GetAllProcessNodes() const {
@@ -307,9 +313,9 @@
   return GetAllNodesOfType<WorkerNodeImpl, const WorkerNode*>();
 }
 
-bool GraphImpl::IsEmpty() const {
+bool GraphImpl::HasOnlySystemNode() const {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  return nodes_.empty();
+  return nodes_.size() == 1 && *nodes_.begin() == GetSystemNodeImpl();
 }
 
 ukm::UkmRecorder* GraphImpl::GetUkmRecorder() const {
@@ -350,18 +356,6 @@
   return reinterpret_cast<GraphImpl*>(const_cast<void*>(graph->GetImpl()));
 }
 
-SystemNodeImpl* GraphImpl::FindOrCreateSystemNodeImpl() {
-  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  if (!system_node_) {
-    // Create the singleton system node instance. Ownership is taken by the
-    // graph.
-    system_node_ = std::make_unique<SystemNodeImpl>();
-    AddNewNode(system_node_.get());
-  }
-
-  return system_node_.get();
-}
-
 bool GraphImpl::NodeInGraph(const NodeBase* node) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
   const auto& it = nodes_.find(const_cast<NodeBase*>(node));
@@ -550,11 +544,8 @@
       for (auto* observer : process_node_observers_)
         observer->OnProcessNodeAdded(process_node);
     } break;
-    case NodeTypeEnum::kSystem: {
-      auto* system_node = SystemNodeImpl::FromNodeBase(node);
-      for (auto* observer : system_node_observers_)
-        observer->OnSystemNodeAdded(system_node);
-    } break;
+    case NodeTypeEnum::kSystem:
+      break;
     case NodeTypeEnum::kWorker: {
       auto* worker_node = WorkerNodeImpl::FromNodeBase(node);
       for (auto* observer : worker_node_observers_)
@@ -585,11 +576,8 @@
       for (auto* observer : process_node_observers_)
         observer->OnBeforeProcessNodeRemoved(process_node);
     } break;
-    case NodeTypeEnum::kSystem: {
-      auto* system_node = SystemNodeImpl::FromNodeBase(node);
-      for (auto* observer : system_node_observers_)
-        observer->OnBeforeSystemNodeRemoved(system_node);
-    } break;
+    case NodeTypeEnum::kSystem:
+      break;
     case NodeTypeEnum::kWorker: {
       auto* worker_node = WorkerNodeImpl::FromNodeBase(node);
       for (auto* observer : worker_node_observers_)
@@ -664,6 +652,14 @@
   return ret;
 }
 
+void GraphImpl::CreateSystemNode() {
+  DCHECK(!system_node_);
+  // Create the singleton system node instance. Ownership is taken by the
+  // graph.
+  system_node_ = std::make_unique<SystemNodeImpl>();
+  AddNewNode(system_node_.get());
+}
+
 void GraphImpl::ReleaseSystemNode() {
   if (!system_node_.get())
     return;
diff --git a/components/performance_manager/graph/graph_impl.h b/components/performance_manager/graph/graph_impl.h
index a3cc10e..ef5f568c 100644
--- a/components/performance_manager/graph/graph_impl.h
+++ b/components/performance_manager/graph/graph_impl.h
@@ -54,6 +54,9 @@
   GraphImpl(const GraphImpl&) = delete;
   GraphImpl& operator=(const GraphImpl&) = delete;
 
+  // Set up the graph.
+  void SetUp();
+
   // Tear down the graph to prepare for deletion.
   void TearDown();
 
@@ -74,12 +77,12 @@
   std::unique_ptr<GraphOwned> TakeFromGraph(GraphOwned* graph_owned) override;
   void RegisterObject(GraphRegistered* object) override;
   void UnregisterObject(GraphRegistered* object) override;
-  const SystemNode* FindOrCreateSystemNode() override;
+  const SystemNode* GetSystemNode() const override;
   std::vector<const ProcessNode*> GetAllProcessNodes() const override;
   std::vector<const FrameNode*> GetAllFrameNodes() const override;
   std::vector<const PageNode*> GetAllPageNodes() const override;
   std::vector<const WorkerNode*> GetAllWorkerNodes() const override;
-  bool IsEmpty() const override;
+  bool HasOnlySystemNode() const override;
   ukm::UkmRecorder* GetUkmRecorder() const override;
   NodeDataDescriberRegistry* GetNodeDataDescriberRegistry() const override;
   uintptr_t GetImplType() const override;
@@ -102,7 +105,10 @@
     return ukm_recorder_;
   }
 
-  SystemNodeImpl* FindOrCreateSystemNodeImpl();
+  SystemNodeImpl* GetSystemNodeImpl() const {
+    DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+    return system_node_.get();
+  }
   std::vector<ProcessNodeImpl*> GetAllProcessNodeImpls() const;
   std::vector<FrameNodeImpl*> GetAllFrameNodeImpls() const;
   std::vector<PageNodeImpl*> GetAllPageNodeImpls() const;
@@ -202,6 +208,7 @@
   template <typename NodeType, typename ReturnNodeType>
   std::vector<ReturnNodeType> GetAllNodesOfType() const;
 
+  void CreateSystemNode() VALID_CONTEXT_REQUIRED(sequence_checker_);
   void ReleaseSystemNode() VALID_CONTEXT_REQUIRED(sequence_checker_);
 
   std::unique_ptr<SystemNodeImpl> system_node_
diff --git a/components/performance_manager/graph/graph_impl_unittest.cc b/components/performance_manager/graph/graph_impl_unittest.cc
index 4493444..82fb710 100644
--- a/components/performance_manager/graph/graph_impl_unittest.cc
+++ b/components/performance_manager/graph/graph_impl_unittest.cc
@@ -26,13 +26,9 @@
   EXPECT_EQ(graph(), GraphImpl::FromGraph(graph_base));
 }
 
-TEST_F(GraphImplTest, FindOrCreateSystemNode) {
-  EXPECT_TRUE(graph()->IsEmpty());
-  SystemNodeImpl* system_node = graph()->FindOrCreateSystemNodeImpl();
-  EXPECT_FALSE(graph()->IsEmpty());
-
-  // A second request should return the same instance.
-  EXPECT_EQ(system_node, graph()->FindOrCreateSystemNodeImpl());
+TEST_F(GraphImplTest, GetSystemNodeImpl) {
+  // The SystemNode singleton should be created by default.
+  EXPECT_NE(nullptr, graph()->GetSystemNodeImpl());
 }
 
 TEST_F(GraphImplTest, GetProcessNodeByPid) {
@@ -291,7 +287,7 @@
   AssertDictValueContainsListKey(descr, "d1", "d1", "ProcessNode");
   EXPECT_EQ(1u, descr.DictSize());
 
-  descr = registry->DescribeNodeData(graph()->FindOrCreateSystemNodeImpl());
+  descr = registry->DescribeNodeData(graph()->GetSystemNode());
   AssertDictValueContainsListKey(descr, "d1", "d1", "SystemNode");
   EXPECT_EQ(1u, descr.DictSize());
 
diff --git a/components/performance_manager/graph/policies/process_priority_policy.cc b/components/performance_manager/graph/policies/process_priority_policy.cc
index cfc313d..876e488c 100644
--- a/components/performance_manager/graph/policies/process_priority_policy.cc
+++ b/components/performance_manager/graph/policies/process_priority_policy.cc
@@ -104,7 +104,7 @@
 }
 
 void ProcessPriorityPolicy::OnPassedToGraph(Graph* graph) {
-  DCHECK(graph->IsEmpty());
+  DCHECK(graph->HasOnlySystemNode());
   graph->AddProcessNodeObserver(this);
 }
 
diff --git a/components/performance_manager/graph/system_node_impl_unittest.cc b/components/performance_manager/graph/system_node_impl_unittest.cc
index 2017e2e48..4d85ba7f31 100644
--- a/components/performance_manager/graph/system_node_impl_unittest.cc
+++ b/components/performance_manager/graph/system_node_impl_unittest.cc
@@ -46,8 +46,7 @@
 using SystemNodeImplDeathTest = SystemNodeImplTest;
 
 TEST_F(SystemNodeImplDeathTest, SafeDowncast) {
-  const NodeBase* system =
-      NodeBase::FromNode(graph()->FindOrCreateSystemNode());
+  const NodeBase* system = NodeBase::FromNode(graph()->GetSystemNodeImpl());
   ASSERT_DEATH_IF_SUPPORTED(PageNodeImpl::FromNodeBase(system), "");
 }
 
@@ -58,8 +57,6 @@
   LenientMockObserver() {}
   ~LenientMockObserver() override {}
 
-  MOCK_METHOD1(OnSystemNodeAdded, void(const SystemNode*));
-  MOCK_METHOD1(OnBeforeSystemNodeRemoved, void(const SystemNode*));
   MOCK_METHOD1(OnProcessMemoryMetricsAvailable, void(const SystemNode*));
   MOCK_METHOD1(OnMemoryPressure,
                void(base::MemoryPressureListener::MemoryPressureLevel));
@@ -92,11 +89,7 @@
   MockObserver obs;
   graph()->AddSystemNodeObserver(&obs);
 
-  // Fetch the system node and expect a matching call to "OnSystemNodeAdded".
-  EXPECT_CALL(obs, OnSystemNodeAdded(_))
-      .WillOnce(Invoke(&obs, &MockObserver::SetNotifiedSystemNode));
-  const SystemNode* system_node = graph()->FindOrCreateSystemNode();
-  EXPECT_EQ(system_node, obs.TakeNotifiedSystemNode());
+  const SystemNode* system_node = graph()->GetSystemNode();
 
   EXPECT_CALL(obs, OnProcessMemoryMetricsAvailable(_))
       .WillOnce(Invoke(&obs, &MockObserver::SetNotifiedSystemNode));
@@ -114,24 +107,12 @@
           base::MemoryPressureListener::MemoryPressureLevel::
               MEMORY_PRESSURE_LEVEL_CRITICAL);
 
-  // Release the system node and expect a call to "OnBeforeSystemNodeRemoved".
-  EXPECT_CALL(obs, OnBeforeSystemNodeRemoved(_))
-      .WillOnce(Invoke(&obs, &MockObserver::SetNotifiedSystemNode));
-  graph()->ReleaseSystemNodeForTesting();
-  EXPECT_EQ(system_node, obs.TakeNotifiedSystemNode());
-
   graph()->RemoveSystemNodeObserver(&obs);
 }
 
-TEST_F(SystemNodeImplTest, MemoryPressureNotifiation) {
+TEST_F(SystemNodeImplTest, MemoryPressureNotification) {
   MockObserver obs;
   graph()->AddSystemNodeObserver(&obs);
-
-  EXPECT_CALL(obs, OnSystemNodeAdded(_))
-      .WillOnce(Invoke(&obs, &MockObserver::SetNotifiedSystemNode));
-  const SystemNode* system_node = graph()->FindOrCreateSystemNode();
-  EXPECT_EQ(system_node, obs.TakeNotifiedSystemNode());
-
   util::test::FakeMemoryPressureMonitor mem_pressure_monitor;
 
   {
@@ -166,11 +147,6 @@
     run_loop.Run();
   }
 
-  EXPECT_CALL(obs, OnBeforeSystemNodeRemoved(_))
-      .WillOnce(Invoke(&obs, &MockObserver::SetNotifiedSystemNode));
-  graph()->ReleaseSystemNodeForTesting();
-  EXPECT_EQ(system_node, obs.TakeNotifiedSystemNode());
-
   graph()->RemoveSystemNodeObserver(&obs);
 }
 
diff --git a/components/performance_manager/graph_features_helper_unittest.cc b/components/performance_manager/graph_features_helper_unittest.cc
index 353aeb1..fd1fc7a 100644
--- a/components/performance_manager/graph_features_helper_unittest.cc
+++ b/components/performance_manager/graph_features_helper_unittest.cc
@@ -23,6 +23,8 @@
   EXPECT_TRUE(features.flags().v8_context_tracker);
 
   TestGraphImpl graph;
+  graph.SetUp();
+
   EXPECT_FALSE(v8_memory::V8ContextTracker::GetFromGraph(&graph));
   features.ConfigureGraph(&graph);
   EXPECT_TRUE(v8_memory::V8ContextTracker::GetFromGraph(&graph));
@@ -33,6 +35,7 @@
 TEST(GraphFeaturesHelperTest, EnableDefault) {
   GraphFeaturesHelper features;
   TestGraphImpl graph;
+  graph.SetUp();
 
   EXPECT_EQ(0u, graph.GraphOwnedCountForTesting());
   EXPECT_EQ(0u, graph.GraphRegisteredCountForTesting());
diff --git a/components/performance_manager/performance_manager_impl.cc b/components/performance_manager/performance_manager_impl.cc
index f93e724..fad8299 100644
--- a/components/performance_manager/performance_manager_impl.cc
+++ b/components/performance_manager/performance_manager_impl.cc
@@ -369,6 +369,7 @@
   DCHECK(!g_performance_manager);
 
   g_performance_manager = this;
+  graph_.SetUp();
   graph_.set_ukm_recorder(ukm::UkmRecorder::Get());
   std::move(on_start).Run(&graph_);
 }
diff --git a/components/performance_manager/public/graph/graph.h b/components/performance_manager/public/graph/graph.h
index b48e1a47..86b6a092 100644
--- a/components/performance_manager/public/graph/graph.h
+++ b/components/performance_manager/public/graph/graph.h
@@ -110,14 +110,14 @@
   }
 
   // Returns a collection of all known nodes of the given type.
-  virtual const SystemNode* FindOrCreateSystemNode() = 0;
+  virtual const SystemNode* GetSystemNode() const = 0;
   virtual std::vector<const ProcessNode*> GetAllProcessNodes() const = 0;
   virtual std::vector<const FrameNode*> GetAllFrameNodes() const = 0;
   virtual std::vector<const PageNode*> GetAllPageNodes() const = 0;
   virtual std::vector<const WorkerNode*> GetAllWorkerNodes() const = 0;
 
-  // Returns true if the graph is currently empty.
-  virtual bool IsEmpty() const = 0;
+  // Returns true if the graph only contains the default nodes.
+  virtual bool HasOnlySystemNode() const = 0;
 
   // Returns the associated UKM recorder if it is defined.
   virtual ukm::UkmRecorder* GetUkmRecorder() const = 0;
diff --git a/components/performance_manager/public/graph/system_node.h b/components/performance_manager/public/graph/system_node.h
index 624401e..707241a4 100644
--- a/components/performance_manager/public/graph/system_node.h
+++ b/components/performance_manager/public/graph/system_node.h
@@ -13,8 +13,8 @@
 
 class SystemNodeObserver;
 
-// The SystemNode represents system-wide state. There is at most one system node
-// in a graph.
+// The SystemNode represents system-wide state. Each graph owns exactly one
+// system node. This node has the same lifetime has the graph that owns it.
 class SystemNode : public Node {
  public:
   using Observer = SystemNodeObserver;
@@ -35,19 +35,6 @@
   SystemNodeObserver();
   virtual ~SystemNodeObserver();
 
-  // Node lifetime notifications.
-
-  // Called when the |system_node| is added to the graph. Observers must not
-  // make any property changes or cause re-entrant notifications during the
-  // scope of this call. Instead, make property changes via a separate posted
-  // task.
-  virtual void OnSystemNodeAdded(const SystemNode* system_node) = 0;
-
-  // Called before the |system_node| is removed from the graph. Observers must
-  // not make any property changes or cause re-entrant notifications during the
-  // scope of this call.
-  virtual void OnBeforeSystemNodeRemoved(const SystemNode* system_node) = 0;
-
   // Called when a new set of process memory metrics is available.
   //
   // Note: This is only valid if at least one component has expressed interest
@@ -87,8 +74,6 @@
   ~ObserverDefaultImpl() override;
 
   // SystemNodeObserver implementation:
-  void OnSystemNodeAdded(const SystemNode* system_node) override {}
-  void OnBeforeSystemNodeRemoved(const SystemNode* system_node) override {}
   void OnProcessMemoryMetricsAvailable(const SystemNode* system_node) override {
   }
   void OnBeforeMemoryPressure(
diff --git a/components/performance_manager/test_support/graph_test_harness.cc b/components/performance_manager/test_support/graph_test_harness.cc
index 116e2f1c..1a618bf0 100644
--- a/components/performance_manager/test_support/graph_test_harness.cc
+++ b/components/performance_manager/test_support/graph_test_harness.cc
@@ -46,6 +46,7 @@
 void GraphTestHarness::SetUp() {
   setup_called_ = true;
 
+  graph_->SetUp();
   graph_features_helper_.ConfigureGraph(graph_.get());
 
   // This can't be done in the constructor because it is a virtual function.
diff --git a/components/performance_manager/test_support/graph_test_harness.h b/components/performance_manager/test_support/graph_test_harness.h
index 313f4c2..98e9184 100644
--- a/components/performance_manager/test_support/graph_test_harness.h
+++ b/components/performance_manager/test_support/graph_test_harness.h
@@ -153,7 +153,7 @@
 class TestNodeWrapper<SystemNodeImpl> {
  public:
   static TestNodeWrapper<SystemNodeImpl> Create(GraphImpl* graph) {
-    return TestNodeWrapper<SystemNodeImpl>(graph->FindOrCreateSystemNodeImpl());
+    return TestNodeWrapper<SystemNodeImpl>(graph->GetSystemNodeImpl());
   }
 
   explicit TestNodeWrapper(SystemNodeImpl* impl) : impl_(impl) {}
@@ -233,8 +233,7 @@
   }
 
   TestNodeWrapper<SystemNodeImpl> GetSystemNode() {
-    return TestNodeWrapper<SystemNodeImpl>(
-        graph()->FindOrCreateSystemNodeImpl());
+    return TestNodeWrapper<SystemNodeImpl>(graph()->GetSystemNodeImpl());
   }
 
   // testing::Test:
diff --git a/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc b/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc
index 98c75bbb..237b6d42 100644
--- a/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc
+++ b/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc
@@ -24,16 +24,19 @@
 
 class V8ContextTrackerHelpersTest : public GraphTestHarness {
  public:
-  V8ContextTrackerHelpersTest()
-      : registry(graph()->PassToGraph(
-            std::make_unique<
-                execution_context::ExecutionContextRegistryImpl>())),
-        mock_graph(graph()) {}
+  V8ContextTrackerHelpersTest() = default;
 
   ~V8ContextTrackerHelpersTest() override = default;
 
-  execution_context::ExecutionContextRegistry* const registry = nullptr;
-  MockSinglePageWithMultipleProcessesGraph mock_graph;
+  void OnGraphCreated(GraphImpl* graph_impl) override {
+    registry = graph_impl->PassToGraph(
+        std::make_unique<execution_context::ExecutionContextRegistryImpl>());
+    mock_graph =
+        std::make_unique<MockSinglePageWithMultipleProcessesGraph>(graph());
+  }
+
+  execution_context::ExecutionContextRegistry* registry = nullptr;
+  std::unique_ptr<MockSinglePageWithMultipleProcessesGraph> mock_graph;
   mojom::IframeAttributionData fake_iframe_attribution_data;
 };
 
@@ -54,15 +57,15 @@
 
 TEST_F(V8ContextTrackerHelpersTest, HasCrossProcessParent) {
   // Fails for a main-frame.
-  EXPECT_FALSE(HasCrossProcessParent(mock_graph.frame.get()));
+  EXPECT_FALSE(HasCrossProcessParent(mock_graph->frame.get()));
 
   // Returns true for an actual cross-process child frame.
-  EXPECT_TRUE(HasCrossProcessParent(mock_graph.child_frame.get()));
+  EXPECT_TRUE(HasCrossProcessParent(mock_graph->child_frame.get()));
 
   // Fails for a same-process child frame.
   TestNodeWrapper<FrameNodeImpl> child_frame(graph()->CreateFrameNodeAutoId(
-      mock_graph.process.get(), mock_graph.page.get(), mock_graph.frame.get(),
-      4));
+      mock_graph->process.get(), mock_graph->page.get(),
+      mock_graph->frame.get(), 4));
   EXPECT_FALSE(HasCrossProcessParent(child_frame.get()));
 }
 
@@ -94,7 +97,7 @@
 }
 
 TEST_F(V8ContextTrackerHelpersTest, GetExecutionContext) {
-  FrameNode* frame_node = mock_graph.frame.get();
+  FrameNode* frame_node = mock_graph->frame.get();
   auto* execution_context =
       GetExecutionContext(frame_node->GetFrameToken(), graph());
   ASSERT_TRUE(execution_context);
@@ -103,13 +106,13 @@
 
 TEST_F(V8ContextTrackerHelpersTest, ValidateV8ContextDescriptionMainWorld) {
   TestNodeWrapper<FrameNodeImpl> child_frame(graph()->CreateFrameNodeAutoId(
-      mock_graph.process.get(), mock_graph.page.get(), mock_graph.frame.get(),
-      4));
+      mock_graph->process.get(), mock_graph->page.get(),
+      mock_graph->frame.get(), 4));
 
   // A valid description of a main frame.
   auto desc = mojom::V8ContextDescription(
       blink::V8ContextToken(), mojom::V8ContextWorldType::kMain,
-      /* world_name */ absl::nullopt, mock_graph.frame->frame_token());
+      /* world_name */ absl::nullopt, mock_graph->frame->frame_token());
   EXPECT_EQ(V8ContextDescriptionStatus::kValid,
             ValidateV8ContextDescription(desc));
   EXPECT_EQ(false,
@@ -118,7 +121,7 @@
   // A valid description of a cross-process child frame.
   desc = mojom::V8ContextDescription(
       blink::V8ContextToken(), mojom::V8ContextWorldType::kMain,
-      /* world_name */ absl::nullopt, mock_graph.child_frame->frame_token());
+      /* world_name */ absl::nullopt, mock_graph->child_frame->frame_token());
   EXPECT_EQ(V8ContextDescriptionStatus::kValid,
             ValidateV8ContextDescription(desc));
   EXPECT_EQ(false,
@@ -146,7 +149,7 @@
   EXPECT_EQ(V8ContextDescriptionStatus::kUnexpectedWorldName,
             ValidateV8ContextDescription(mojom::V8ContextDescription(
                 blink::V8ContextToken(), mojom::V8ContextWorldType::kMain,
-                kWorldName, mock_graph.frame->frame_token())));
+                kWorldName, mock_graph->frame->frame_token())));
 
   // A main world must have an |execution_context_token|.
   EXPECT_EQ(V8ContextDescriptionStatus::kMissingExecutionContextToken,
@@ -166,7 +169,7 @@
 TEST_F(V8ContextTrackerHelpersTest, ValidateV8ContextDescriptionWorkerWorld) {
   blink::DedicatedWorkerToken worker_token;
   auto worker = TestNodeWrapper<WorkerNodeImpl>::Create(
-      graph(), WorkerNode::WorkerType::kDedicated, mock_graph.process.get(),
+      graph(), WorkerNode::WorkerType::kDedicated, mock_graph->process.get(),
       "browser_context", worker_token);
 
   // A valid worker description.
@@ -206,7 +209,7 @@
   // A valid extension description.
   auto desc = mojom::V8ContextDescription(
       blink::V8ContextToken(), mojom::V8ContextWorldType::kExtension,
-      kValidExtensionWorldName, mock_graph.frame->frame_token());
+      kValidExtensionWorldName, mock_graph->frame->frame_token());
   EXPECT_EQ(V8ContextDescriptionStatus::kValid,
             ValidateV8ContextDescription(desc));
   EXPECT_EQ(false,
@@ -217,13 +220,13 @@
       V8ContextDescriptionStatus::kMissingWorldName,
       ValidateV8ContextDescription(mojom::V8ContextDescription(
           blink::V8ContextToken(), mojom::V8ContextWorldType::kExtension,
-          /* world_name */ absl::nullopt, mock_graph.frame->frame_token())));
+          /* world_name */ absl::nullopt, mock_graph->frame->frame_token())));
 
   // An invalid extension name should fail.
   EXPECT_EQ(V8ContextDescriptionStatus::kInvalidExtensionWorldName,
             ValidateV8ContextDescription(mojom::V8ContextDescription(
                 blink::V8ContextToken(), mojom::V8ContextWorldType::kExtension,
-                kInvalidExtensionWorldName, mock_graph.frame->frame_token())));
+                kInvalidExtensionWorldName, mock_graph->frame->frame_token())));
 
   // An extension must have an |execution_context_token|.
   EXPECT_EQ(V8ContextDescriptionStatus::kMissingExecutionContextToken,
@@ -243,7 +246,7 @@
   // An isolated world may or may not have a |world_name|.
   auto desc = mojom::V8ContextDescription(
       blink::V8ContextToken(), mojom::V8ContextWorldType::kIsolated,
-      /* world_name */ absl::nullopt, mock_graph.frame->frame_token());
+      /* world_name */ absl::nullopt, mock_graph->frame->frame_token());
   EXPECT_EQ(V8ContextDescriptionStatus::kValid,
             ValidateV8ContextDescription(desc));
   EXPECT_EQ(false,
@@ -251,7 +254,7 @@
 
   desc = mojom::V8ContextDescription(
       blink::V8ContextToken(), mojom::V8ContextWorldType::kIsolated, kWorldName,
-      mock_graph.frame->frame_token());
+      mock_graph->frame->frame_token());
   EXPECT_EQ(V8ContextDescriptionStatus::kValid,
             ValidateV8ContextDescription(desc));
   EXPECT_EQ(false,
@@ -276,7 +279,7 @@
   // A valid inspector world.
   auto desc = mojom::V8ContextDescription(
       blink::V8ContextToken(), mojom::V8ContextWorldType::kInspector,
-      /* world_name */ absl::nullopt, mock_graph.frame->frame_token());
+      /* world_name */ absl::nullopt, mock_graph->frame->frame_token());
   EXPECT_EQ(V8ContextDescriptionStatus::kValid,
             ValidateV8ContextDescription(desc));
   EXPECT_EQ(false,
@@ -319,7 +322,7 @@
       V8ContextDescriptionStatus::kUnexpectedExecutionContextToken,
       ValidateV8ContextDescription(mojom::V8ContextDescription(
           blink::V8ContextToken(), mojom::V8ContextWorldType::kRegExp,
-          /* world_name */ absl::nullopt, mock_graph.frame->frame_token())));
+          /* world_name */ absl::nullopt, mock_graph->frame->frame_token())));
 }
 
 }  // namespace v8_memory
diff --git a/components/performance_manager/v8_memory/v8_context_tracker_internal_unittest.cc b/components/performance_manager/v8_memory/v8_context_tracker_internal_unittest.cc
index 5066364e..e097793d 100644
--- a/components/performance_manager/v8_memory/v8_context_tracker_internal_unittest.cc
+++ b/components/performance_manager/v8_memory/v8_context_tracker_internal_unittest.cc
@@ -26,12 +26,15 @@
 
 class V8ContextTrackerInternalTest : public GraphTestHarness {
  public:
-  V8ContextTrackerInternalTest()
-      : registry_(graph()->PassToGraph(
-            std::make_unique<
-                execution_context::ExecutionContextRegistryImpl>())),
-        tracker_(graph()->PassToGraph(std::make_unique<V8ContextTracker>())),
-        mock_graph_(graph()) {}
+  V8ContextTrackerInternalTest() = default;
+
+  void OnGraphCreated(GraphImpl* graph_impl) override {
+    registry_ = graph_impl->PassToGraph(
+        std::make_unique<execution_context::ExecutionContextRegistryImpl>());
+    tracker_ = graph_impl->PassToGraph(std::make_unique<V8ContextTracker>());
+    mock_graph_ =
+        std::make_unique<MockSinglePageWithMultipleProcessesGraph>(graph());
+  }
 
   ~V8ContextTrackerInternalTest() override = default;
 
@@ -39,9 +42,9 @@
     return tracker_->data_store();
   }
 
-  execution_context::ExecutionContextRegistry* const registry_ = nullptr;
-  V8ContextTracker* const tracker_ = nullptr;
-  MockSinglePageWithMultipleProcessesGraph mock_graph_;
+  execution_context::ExecutionContextRegistry* registry_ = nullptr;
+  V8ContextTracker* tracker_ = nullptr;
+  std::unique_ptr<MockSinglePageWithMultipleProcessesGraph> mock_graph_;
 };
 
 mojom::V8ContextDescription MakeMatchingV8ContextDescription(
@@ -66,10 +69,10 @@
 TEST_F(V8ContextTrackerInternalDeathTest,
        PassingUnreferencedExecutionContextDataFails) {
   auto* process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
   std::unique_ptr<ExecutionContextData> ec_data =
       std::make_unique<ExecutionContextData>(
-          process_data, mock_graph_.frame->frame_token(), nullptr);
+          process_data, mock_graph_->frame->frame_token(), nullptr);
   EXPECT_TRUE(ec_data->ShouldDestroy());
   EXPECT_DCHECK_DEATH(data_store()->Pass(std::move(ec_data)));
 }
@@ -77,10 +80,10 @@
 TEST_F(V8ContextTrackerInternalDeathTest,
        MultipleMainWorldsForExecutionContextFails) {
   auto* process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
   std::unique_ptr<ExecutionContextData> ec_data =
       std::make_unique<ExecutionContextData>(
-          process_data, mock_graph_.frame->frame_token(), nullptr);
+          process_data, mock_graph_->frame->frame_token(), nullptr);
   EXPECT_TRUE(ec_data->ShouldDestroy());
   EXPECT_EQ(0u, ec_data->main_nondetached_v8_context_count());
 
@@ -105,12 +108,12 @@
 
 TEST_F(V8ContextTrackerInternalDeathTest, CrossProcessV8ContextDataExplodes) {
   auto* process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
   auto* other_process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.other_process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->other_process.get()));
   std::unique_ptr<ExecutionContextData> ec_data =
       std::make_unique<ExecutionContextData>(
-          process_data, mock_graph_.frame->frame_token(), nullptr);
+          process_data, mock_graph_->frame->frame_token(), nullptr);
   std::unique_ptr<V8ContextData> v8_data;
   EXPECT_DCHECK_DEATH(v8_data = std::make_unique<V8ContextData>(
                           other_process_data,
@@ -120,19 +123,19 @@
 
 TEST_F(V8ContextTrackerInternalTest, ExecutionContextDataShouldDestroy) {
   auto* process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
 
   // With no references "ShouldDestroy" should return true.
   std::unique_ptr<ExecutionContextData> ec_data =
       std::make_unique<ExecutionContextData>(
-          process_data, mock_graph_.frame->frame_token(), nullptr);
+          process_data, mock_graph_->frame->frame_token(), nullptr);
   EXPECT_FALSE(ec_data->remote_frame_data());
   EXPECT_EQ(0u, ec_data->v8_context_count());
   EXPECT_TRUE(ec_data->ShouldDestroy());
 
   // Adding a RemoteFrameData reference should mark "ShouldDestroy" as false.
   auto* other_process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.other_process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->other_process.get()));
   std::unique_ptr<RemoteFrameData> rf_data = std::make_unique<RemoteFrameData>(
       other_process_data, blink::RemoteFrameToken(), ec_data.get());
   EXPECT_TRUE(ec_data->remote_frame_data());
@@ -177,18 +180,18 @@
 TEST_F(V8ContextTrackerInternalTest,
        ExecutionContextDataTornDownByRemoteFrameData) {
   auto* process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
 
   // Create an ExecutionContextData.
   std::unique_ptr<ExecutionContextData> ec_data =
       std::make_unique<ExecutionContextData>(
-          process_data, mock_graph_.frame->frame_token(), nullptr);
+          process_data, mock_graph_->frame->frame_token(), nullptr);
   auto* raw_ec_data = ec_data.get();
   EXPECT_FALSE(ec_data->IsTracked());
 
   // Create a RemoteFrameData.
   auto* other_process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.other_process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->other_process.get()));
   std::unique_ptr<RemoteFrameData> rf_data = std::make_unique<RemoteFrameData>(
       other_process_data, blink::RemoteFrameToken(), ec_data.get());
   auto* raw_rf_data = rf_data.get();
@@ -220,12 +223,12 @@
 TEST_F(V8ContextTrackerInternalTest,
        ExecutionContextDataTornDownByV8ContextData) {
   auto* process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
 
   // Create an ExecutionContextData.
   std::unique_ptr<ExecutionContextData> ec_data =
       std::make_unique<ExecutionContextData>(
-          process_data, mock_graph_.frame->frame_token(), nullptr);
+          process_data, mock_graph_->frame->frame_token(), nullptr);
   auto* raw_ec_data = ec_data.get();
   EXPECT_FALSE(ec_data->IsTracked());
 
@@ -261,11 +264,11 @@
 
 TEST_F(V8ContextTrackerInternalTest, ContextCounts) {
   auto* process_data = ProcessData::GetOrCreate(
-      static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+      static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
 
   std::unique_ptr<ExecutionContextData> ec_data =
       std::make_unique<ExecutionContextData>(
-          process_data, mock_graph_.frame->frame_token(), nullptr);
+          process_data, mock_graph_->frame->frame_token(), nullptr);
   auto* raw_ec_data = ec_data.get();
 
   std::unique_ptr<V8ContextData> v8_data1 = std::make_unique<V8ContextData>(
@@ -343,9 +346,9 @@
     Super::SetUp();
 
     process_data_ = ProcessData::GetOrCreate(
-        static_cast<ProcessNodeImpl*>(mock_graph_.process.get()));
+        static_cast<ProcessNodeImpl*>(mock_graph_->process.get()));
     other_process_data_ = ProcessData::GetOrCreate(
-        static_cast<ProcessNodeImpl*>(mock_graph_.other_process.get()));
+        static_cast<ProcessNodeImpl*>(mock_graph_->other_process.get()));
 
     EXPECT_EQ(0u, data_store()->GetExecutionContextDataCount());
     EXPECT_EQ(0u, data_store()->GetRemoteFrameDataCount());
@@ -354,7 +357,7 @@
     // Create an ExecutionContextData.
     std::unique_ptr<ExecutionContextData> ec_data =
         std::make_unique<ExecutionContextData>(
-            process_data_, mock_graph_.frame->frame_token(), nullptr);
+            process_data_, mock_graph_->frame->frame_token(), nullptr);
     ec_data_ = ec_data.get();
 
     // Create a RemoteFrameData.
diff --git a/components/performance_manager/v8_memory/v8_context_tracker_unittest.cc b/components/performance_manager/v8_memory/v8_context_tracker_unittest.cc
index bfcfb8a3..989a88c 100644
--- a/components/performance_manager/v8_memory/v8_context_tracker_unittest.cc
+++ b/components/performance_manager/v8_memory/v8_context_tracker_unittest.cc
@@ -55,18 +55,21 @@
 
 class V8ContextTrackerTest : public GraphTestHarness {
  public:
-  V8ContextTrackerTest()
-      : registry(graph()->PassToGraph(
-            std::make_unique<
-                execution_context::ExecutionContextRegistryImpl>())),
-        tracker(graph()->PassToGraph(std::make_unique<V8ContextTracker>())),
-        mock_graph(graph()) {}
+  V8ContextTrackerTest() = default;
 
   ~V8ContextTrackerTest() override = default;
 
-  execution_context::ExecutionContextRegistry* const registry = nullptr;
-  V8ContextTracker* const tracker = nullptr;
-  MockSinglePageWithMultipleProcessesGraph mock_graph;
+  void OnGraphCreated(GraphImpl* graph_impl) override {
+    registry_ = graph_impl->PassToGraph(
+        std::make_unique<execution_context::ExecutionContextRegistryImpl>());
+    tracker_ = graph_impl->PassToGraph(std::make_unique<V8ContextTracker>());
+    mock_graph_ =
+        std::make_unique<MockSinglePageWithMultipleProcessesGraph>(graph());
+  }
+
+  execution_context::ExecutionContextRegistry* registry_ = nullptr;
+  V8ContextTracker* tracker_ = nullptr;
+  std::unique_ptr<MockSinglePageWithMultipleProcessesGraph> mock_graph_;
 };
 
 using V8ContextTrackerDeathTest = V8ContextTrackerTest;
@@ -92,8 +95,8 @@
 TEST_F(V8ContextTrackerDeathTest, MissingExecutionContextForMainFrameExplodes) {
   // A main-frame should not have iframe data, and it must have an execution
   // context token. So this should fail.
-  EXPECT_DCHECK_DEATH(tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  EXPECT_DCHECK_DEATH(tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
@@ -107,67 +110,67 @@
       /* token */ kFrameMainWorld,
       /* world_type */ mojom::V8ContextWorldType::kMain,
       /* world_name */ absl::nullopt,
-      /* execution_context_token */ mock_graph.frame->frame_token());
+      /* execution_context_token */ mock_graph_->frame->frame_token());
 
-  tracker->OnV8ContextCreated(ProcessNodeImpl::CreatePassKeyForTesting(),
-                              mock_graph.process.get(), v8_desc, nullptr);
+  tracker_->OnV8ContextCreated(ProcessNodeImpl::CreatePassKeyForTesting(),
+                               mock_graph_->process.get(), v8_desc, nullptr);
 
   // Trying to create the context a second time should explode.
-  EXPECT_DCHECK_DEATH(
-      tracker->OnV8ContextCreated(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                  mock_graph.process.get(), v8_desc, nullptr));
+  EXPECT_DCHECK_DEATH(tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
+      v8_desc, nullptr));
 }
 
 TEST_F(V8ContextTrackerDeathTest, MissingContextExplodes) {
   // There was no OnV8ContextCreated called first, so this should explode.
-  EXPECT_DCHECK_DEATH(
-      tracker->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                   mock_graph.process.get(), kFrameMainWorld));
+  EXPECT_DCHECK_DEATH(tracker_->OnV8ContextDetached(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
+      kFrameMainWorld));
 
   // Similarly with a destroyed notification.
-  EXPECT_DCHECK_DEATH(
-      tracker->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                    mock_graph.process.get(), kFrameMainWorld));
+  EXPECT_DCHECK_DEATH(tracker_->OnV8ContextDestroyed(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
+      kFrameMainWorld));
 }
 
 TEST_F(V8ContextTrackerDeathTest, DoubleRemoteFrameCreatedExplodes) {
-  tracker->OnRemoteIframeAttachedForTesting(
-      mock_graph.child_frame.get(), mock_graph.frame.get(),
+  tracker_->OnRemoteIframeAttachedForTesting(
+      mock_graph_->child_frame.get(), mock_graph_->frame.get(),
       kChildFrameRemoteToken, GetFakeIframeAttributionDataPtr());
 
-  EXPECT_DCHECK_DEATH(tracker->OnRemoteIframeAttachedForTesting(
-      mock_graph.child_frame.get(), mock_graph.frame.get(),
+  EXPECT_DCHECK_DEATH(tracker_->OnRemoteIframeAttachedForTesting(
+      mock_graph_->child_frame.get(), mock_graph_->frame.get(),
       kChildFrameRemoteToken, GetFakeIframeAttributionDataPtr()));
 }
 
 TEST_F(V8ContextTrackerDeathTest, RemoteFrameWithBadParentExplodes) {
   // child_frame's real parent is frame.
-  EXPECT_DCHECK_DEATH(tracker->OnRemoteIframeAttachedForTesting(
-      mock_graph.child_frame.get(), mock_graph.child_frame.get(),
+  EXPECT_DCHECK_DEATH(tracker_->OnRemoteIframeAttachedForTesting(
+      mock_graph_->child_frame.get(), mock_graph_->child_frame.get(),
       kChildFrameRemoteToken, GetFakeIframeAttributionDataPtr()));
 }
 
 TEST_F(V8ContextTrackerDeathTest, IframeAttributionDataForMainFrameExplodes) {
-  EXPECT_DCHECK_DEATH(tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  EXPECT_DCHECK_DEATH(tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
           /* world_name */ absl::nullopt,
-          /* execution_context_token */ mock_graph.frame->frame_token()),
+          /* execution_context_token */ mock_graph_->frame->frame_token()),
       GetFakeIframeAttributionDataPtr()));
 }
 
 TEST_F(V8ContextTrackerDeathTest,
        NoIframeAttributionDataForInProcessChildFrameExplodes) {
-  // Create a child of mock_graph.frame that is in the same process.
+  // Create a child of mock_graph_->frame that is in the same process.
   TestNodeWrapper<FrameNodeImpl> child2_frame(graph()->CreateFrameNodeAutoId(
-      mock_graph.process.get(), mock_graph.page.get(), mock_graph.frame.get(),
-      3));
+      mock_graph_->process.get(), mock_graph_->page.get(),
+      mock_graph_->frame.get(), 3));
   // This should explode because synchronous iframe data is expected, but not
   // provided.
-  EXPECT_DCHECK_DEATH(tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  EXPECT_DCHECK_DEATH(tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kChildFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
@@ -178,243 +181,244 @@
 
 TEST_F(V8ContextTrackerDeathTest, MultipleMainContextsForExecutionContext) {
   // Create a main-frame with two main worlds.
-  tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
           /* world_name */ absl::nullopt,
-          /* execution_context_token */ mock_graph.frame->frame_token()),
+          /* execution_context_token */ mock_graph_->frame->frame_token()),
       /* iframe_attribution_data */ nullptr);
 
-  EXPECT_DCHECK_DEATH(tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  EXPECT_DCHECK_DEATH(tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ blink::V8ContextToken(),
           /* world_type */ mojom::V8ContextWorldType::kMain,
           /* world_name */ absl::nullopt,
-          /* execution_context_token */ mock_graph.frame->frame_token()),
+          /* execution_context_token */ mock_graph_->frame->frame_token()),
       /* iframe_attribution_data */ nullptr));
 }
 
 TEST_F(V8ContextTrackerTest, NormalV8ContextLifecycleWithExecutionContext) {
-  EXPECT_THAT(tracker, CountsMatch(0, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(0, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
-  tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
           /* world_name */ absl::nullopt,
-          /* execution_context_token */ mock_graph.frame->frame_token()),
+          /* execution_context_token */ mock_graph_->frame->frame_token()),
       /* iframe_attribution_data */ nullptr);
-  EXPECT_THAT(tracker, CountsMatch(1, 1));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(1, 1));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
-  tracker->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
-                               mock_graph.process.get(), kFrameMainWorld);
-  EXPECT_THAT(tracker, CountsMatch(1, 1));
-  EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+  tracker_->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                mock_graph_->process.get(), kFrameMainWorld);
+  EXPECT_THAT(tracker_, CountsMatch(1, 1));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
 
-  tracker->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                mock_graph.process.get(), kFrameMainWorld);
-  EXPECT_THAT(tracker, CountsMatch(0, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  tracker_->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                 mock_graph_->process.get(), kFrameMainWorld);
+  EXPECT_THAT(tracker_, CountsMatch(0, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 }
 
 TEST_F(V8ContextTrackerTest, NormalV8ContextLifecycleNoExecutionContext) {
-  EXPECT_THAT(tracker, CountsMatch(0, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(0, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
-  tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kRegExp,
           /* world_name */ absl::nullopt,
           /* execution_context_token */ absl::nullopt),
       /* iframe_attribution_data */ nullptr);
-  EXPECT_THAT(tracker, CountsMatch(1, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(1, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
-  tracker->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
-                               mock_graph.process.get(), kFrameMainWorld);
-  EXPECT_THAT(tracker, CountsMatch(1, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+  tracker_->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                mock_graph_->process.get(), kFrameMainWorld);
+  EXPECT_THAT(tracker_, CountsMatch(1, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
 
-  tracker->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                mock_graph.process.get(), kFrameMainWorld);
-  EXPECT_THAT(tracker, CountsMatch(0, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  tracker_->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                 mock_graph_->process.get(), kFrameMainWorld);
+  EXPECT_THAT(tracker_, CountsMatch(0, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 }
 
 TEST_F(V8ContextTrackerTest, MultipleV8ContextsForExecutionContext) {
-  EXPECT_THAT(tracker, CountsMatch(0, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(0, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
   // Create a main-frame main world context, and an isolated world.
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextCreated(
-        ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+    tracker_->OnV8ContextCreated(
+        ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
         mojom::V8ContextDescription(
             /* token */ kFrameMainWorld,
             /* world_type */ mojom::V8ContextWorldType::kMain,
             /* world_name */ absl::nullopt,
-            /* execution_context_token */ mock_graph.frame->frame_token()),
+            /* execution_context_token */ mock_graph_->frame->frame_token()),
         /* iframe_attribution_data */ nullptr);
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextCreated(
-        ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+    tracker_->OnV8ContextCreated(
+        ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
         mojom::V8ContextDescription(
             /* token */ kFrameIsolatedWorld,
             /* world_type */ mojom::V8ContextWorldType::kExtension,
             /* world_name */ kExtensionId,
-            /* execution_context_token */ mock_graph.frame->frame_token()),
+            /* execution_context_token */ mock_graph_->frame->frame_token()),
         /* iframe_attribution_data */ nullptr);
-    EXPECT_THAT(tracker, CountsMatch(2, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   // Create a child-frame main world context, and an isolated world. This child
   // is cross-process so expects no iframe data at creation.
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextCreated(
+    tracker_->OnV8ContextCreated(
         ProcessNodeImpl::CreatePassKeyForTesting(),
-        mock_graph.other_process.get(),
+        mock_graph_->other_process.get(),
         mojom::V8ContextDescription(
             /* token */ kChildFrameMainWorld,
             /* world_type */ mojom::V8ContextWorldType::kMain,
             /* world_name */ absl::nullopt,
             /* execution_context_token */
-            mock_graph.child_frame->frame_token()),
+            mock_graph_->child_frame->frame_token()),
         /* iframe_attribution_data */ nullptr);
-    EXPECT_THAT(tracker, CountsMatch(3, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(3, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextCreated(
+    tracker_->OnV8ContextCreated(
         ProcessNodeImpl::CreatePassKeyForTesting(),
-        mock_graph.other_process.get(),
+        mock_graph_->other_process.get(),
         mojom::V8ContextDescription(
             /* token */ kChildFrameIsolatedWorld,
             /* world_type */ mojom::V8ContextWorldType::kExtension,
             /* world_name */ kExtensionId,
             /* execution_context_token */
-            mock_graph.child_frame->frame_token()),
+            mock_graph_->child_frame->frame_token()),
         /* iframe_attribution_data */ nullptr);
-    EXPECT_THAT(tracker, CountsMatch(4, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(4, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   // Provide iframe data for the child frame.
   {
     SCOPED_TRACE("");
-    tracker->OnRemoteIframeAttachedForTesting(
-        mock_graph.child_frame.get(), mock_graph.frame.get(),
+    tracker_->OnRemoteIframeAttachedForTesting(
+        mock_graph_->child_frame.get(), mock_graph_->frame.get(),
         kChildFrameRemoteToken, GetFakeIframeAttributionDataPtr());
-    EXPECT_THAT(tracker, CountsMatch(4, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(4, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   // Detach the child frame contexts.
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                 mock_graph.other_process.get(),
-                                 kChildFrameIsolatedWorld);
-    EXPECT_THAT(tracker, CountsMatch(4, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    tracker_->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                  mock_graph_->other_process.get(),
+                                  kChildFrameIsolatedWorld);
+    EXPECT_THAT(tracker_, CountsMatch(4, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
   }
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                 mock_graph.other_process.get(),
-                                 kChildFrameMainWorld);
-    EXPECT_THAT(tracker, CountsMatch(4, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(2, 0));
+    tracker_->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                  mock_graph_->other_process.get(),
+                                  kChildFrameMainWorld);
+    EXPECT_THAT(tracker_, CountsMatch(4, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(2, 0));
   }
 
   // Destroy the child frame main world context.
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                  mock_graph.other_process.get(),
-                                  kChildFrameMainWorld);
-    EXPECT_THAT(tracker, CountsMatch(3, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    tracker_->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                   mock_graph_->other_process.get(),
+                                   kChildFrameMainWorld);
+    EXPECT_THAT(tracker_, CountsMatch(3, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
   }
 
   // Detach the main frame contexts, main and isolated.
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                 mock_graph.process.get(), kFrameMainWorld);
-    EXPECT_THAT(tracker, CountsMatch(3, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(2, 0));
+    tracker_->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                  mock_graph_->process.get(), kFrameMainWorld);
+    EXPECT_THAT(tracker_, CountsMatch(3, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(2, 0));
   }
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                 mock_graph.process.get(), kFrameIsolatedWorld);
-    EXPECT_THAT(tracker, CountsMatch(3, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(3, 0));
+    tracker_->OnV8ContextDetached(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                  mock_graph_->process.get(),
+                                  kFrameIsolatedWorld);
+    EXPECT_THAT(tracker_, CountsMatch(3, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(3, 0));
   }
 
   // Destroy the main frame isolated world.
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                  mock_graph.process.get(),
-                                  kFrameIsolatedWorld);
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(2, 0));
+    tracker_->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                   mock_graph_->process.get(),
+                                   kFrameIsolatedWorld);
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(2, 0));
   }
 
   // Destroy the child frame isolated world..
   {
     SCOPED_TRACE("");
-    tracker->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
-                                  mock_graph.other_process.get(),
-                                  kChildFrameIsolatedWorld);
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    tracker_->OnV8ContextDestroyed(ProcessNodeImpl::CreatePassKeyForTesting(),
+                                   mock_graph_->other_process.get(),
+                                   kChildFrameIsolatedWorld);
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
   }
 
   // Destroy the remote iframe reference to the child frame, which should
   // finally tear down the ExecutionContext as well.
   {
     SCOPED_TRACE("");
-    tracker->OnRemoteIframeDetachedForTesting(mock_graph.frame.get(),
-                                              kChildFrameRemoteToken);
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    tracker_->OnRemoteIframeDetachedForTesting(mock_graph_->frame.get(),
+                                               kChildFrameRemoteToken);
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
   }
 }
 
 TEST_F(V8ContextTrackerTest, AllEventOrders) {
-  EXPECT_THAT(tracker, CountsMatch(0, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(0, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
   // Create a main frame. This exists for the duration of the test, and we
   // repeatedly attach/detach child frames to it.
-  tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
           /* world_name */ absl::nullopt,
-          /* execution_context_token */ mock_graph.frame->frame_token()),
+          /* execution_context_token */ mock_graph_->frame->frame_token()),
       /* iframe_attribution_data */ nullptr);
-  EXPECT_THAT(tracker, CountsMatch(1, 1));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(1, 1));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
   // Bind lambdas for all the events that can occur to a frame in its lifetime.
   // This test will explore all possible valid combinations of these events.
@@ -422,51 +426,52 @@
   // Creates a child frame V8Context.
   auto v8create = [self = this]() {
     SCOPED_TRACE("");
-    self->tracker->OnV8ContextCreated(
+    self->tracker_->OnV8ContextCreated(
         ProcessNodeImpl::CreatePassKeyForTesting(),
-        self->mock_graph.other_process.get(),
+        self->mock_graph_->other_process.get(),
         mojom::V8ContextDescription(
             /* token */ kChildFrameMainWorld,
             /* world_type */ mojom::V8ContextWorldType::kMain,
             /* world_name */ absl::nullopt,
             /* execution_context_token */
-            self->mock_graph.child_frame->frame_token()),
+            self->mock_graph_->child_frame->frame_token()),
         /* iframe_attribution_data */ nullptr);
   };
 
   // Detaches a child frame V8Context.
   auto v8detach = [self = this]() {
     SCOPED_TRACE("");
-    self->tracker->OnV8ContextDetached(
+    self->tracker_->OnV8ContextDetached(
         ProcessNodeImpl::CreatePassKeyForTesting(),
-        self->mock_graph.other_process.get(), kChildFrameMainWorld);
+        self->mock_graph_->other_process.get(), kChildFrameMainWorld);
   };
 
   // Destroys a child frame V8Context.
   auto v8destroy = [self = this]() {
     SCOPED_TRACE("");
-    self->tracker->OnV8ContextDestroyed(
+    self->tracker_->OnV8ContextDestroyed(
         ProcessNodeImpl::CreatePassKeyForTesting(),
-        self->mock_graph.other_process.get(), kChildFrameMainWorld);
+        self->mock_graph_->other_process.get(), kChildFrameMainWorld);
   };
 
   // Attaches a child iframe. This is after frame resolution has occurred so it
   // is aimed at the frame that is represented by the remote frame token
-  // (hence mock_graph.child_frame). The actual "OnRemoteIframeAttached"
+  // (hence mock_graph_->child_frame). The actual "OnRemoteIframeAttached"
   // message originally arrives over the parent frame interface.
   auto iframeattach = [self = this]() {
     SCOPED_TRACE("");
-    self->tracker->OnRemoteIframeAttachedForTesting(
-        self->mock_graph.child_frame.get(), self->mock_graph.frame.get(),
+    self->tracker_->OnRemoteIframeAttachedForTesting(
+        self->mock_graph_->child_frame.get(), self->mock_graph_->frame.get(),
         kChildFrameRemoteToken, GetFakeIframeAttributionDataPtr());
   };
 
   // Detaches a child iframe. This message is sent over the interface associated
-  // with the parent frame that hosts the child frame (hence mock_graph.frame).
+  // with the parent frame that hosts the child frame (hence
+  // mock_graph_->frame).
   auto iframedetach = [self = this]() {
     SCOPED_TRACE("");
-    self->tracker->OnRemoteIframeDetachedForTesting(
-        self->mock_graph.frame.get(), kChildFrameRemoteToken);
+    self->tracker_->OnRemoteIframeDetachedForTesting(
+        self->mock_graph_->frame.get(), kChildFrameRemoteToken);
   };
 
   // The following tests look at all 10 possible orderings of the 3 ordered
@@ -475,264 +480,266 @@
   {
     SCOPED_TRACE("Case 1");
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 2");
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 3");
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 4");
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 5");
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 6");
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 7");
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 8");
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 9");
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 
   {
     SCOPED_TRACE("Case 10");
     iframeattach();
-    EXPECT_THAT(tracker, CountsMatch(1, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     iframedetach();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8create();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
     v8detach();
-    EXPECT_THAT(tracker, CountsMatch(2, 2));
-    EXPECT_THAT(tracker, DetachedCountsMatch(1, 0));
+    EXPECT_THAT(tracker_, CountsMatch(2, 2));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(1, 0));
     v8destroy();
-    EXPECT_THAT(tracker, CountsMatch(1, 1));
-    EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+    EXPECT_THAT(tracker_, CountsMatch(1, 1));
+    EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
   }
 }
 
 TEST_F(V8ContextTrackerTest, PublicApi) {
-  EXPECT_THAT(tracker, CountsMatch(0, 0));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(0, 0));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
   // Create a main frame.
 
-  EXPECT_FALSE(tracker->GetV8ContextState(kFrameMainWorld));
+  EXPECT_FALSE(tracker_->GetV8ContextState(kFrameMainWorld));
   EXPECT_FALSE(
-      tracker->GetExecutionContextState(mock_graph.frame->frame_token()));
+      tracker_->GetExecutionContextState(mock_graph_->frame->frame_token()));
 
-  tracker->OnV8ContextCreated(
-      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph.process.get(),
+  tracker_->OnV8ContextCreated(
+      ProcessNodeImpl::CreatePassKeyForTesting(), mock_graph_->process.get(),
       mojom::V8ContextDescription(
           /* token */ kFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
           /* world_name */ absl::nullopt,
-          /* execution_context_token */ mock_graph.frame->frame_token()),
+          /* execution_context_token */ mock_graph_->frame->frame_token()),
       /* iframe_attribution_data */ nullptr);
-  EXPECT_THAT(tracker, CountsMatch(1, 1));
-  EXPECT_THAT(tracker, DetachedCountsMatch(0, 0));
+  EXPECT_THAT(tracker_, CountsMatch(1, 1));
+  EXPECT_THAT(tracker_, DetachedCountsMatch(0, 0));
 
-  const auto* v8_state = tracker->GetV8ContextState(kFrameMainWorld);
+  const auto* v8_state = tracker_->GetV8ContextState(kFrameMainWorld);
   ASSERT_TRUE(v8_state);
   EXPECT_EQ(kFrameMainWorld, v8_state->description.token);
   EXPECT_EQ(mojom::V8ContextWorldType::kMain, v8_state->description.world_type);
   EXPECT_FALSE(v8_state->description.world_name);
   ASSERT_TRUE(v8_state->description.execution_context_token);
-  EXPECT_EQ(blink::ExecutionContextToken(mock_graph.frame->frame_token()),
+  EXPECT_EQ(blink::ExecutionContextToken(mock_graph_->frame->frame_token()),
             v8_state->description.execution_context_token.value());
   const auto* ec_state =
-      tracker->GetExecutionContextState(mock_graph.frame->frame_token());
+      tracker_->GetExecutionContextState(mock_graph_->frame->frame_token());
   ASSERT_TRUE(ec_state);
-  EXPECT_EQ(blink::ExecutionContextToken(mock_graph.frame->frame_token()),
+  EXPECT_EQ(blink::ExecutionContextToken(mock_graph_->frame->frame_token()),
             ec_state->token);
 
   // Create a child frame.
 
-  ASSERT_FALSE(tracker->GetV8ContextState(kChildFrameMainWorld));
-  ASSERT_FALSE(
-      tracker->GetExecutionContextState(mock_graph.child_frame->frame_token()));
+  ASSERT_FALSE(tracker_->GetV8ContextState(kChildFrameMainWorld));
+  ASSERT_FALSE(tracker_->GetExecutionContextState(
+      mock_graph_->child_frame->frame_token()));
 
-  tracker->OnV8ContextCreated(
+  tracker_->OnV8ContextCreated(
       ProcessNodeImpl::CreatePassKeyForTesting(),
-      mock_graph.other_process.get(),
+      mock_graph_->other_process.get(),
       mojom::V8ContextDescription(
           /* token */ kChildFrameMainWorld,
           /* world_type */ mojom::V8ContextWorldType::kMain,
           /* world_name */ absl::nullopt,
           /* execution_context_token */
-          mock_graph.child_frame->frame_token()),
+          mock_graph_->child_frame->frame_token()),
       /* iframe_attribution_data */ nullptr);
-  v8_state = tracker->GetV8ContextState(kChildFrameMainWorld);
+  v8_state = tracker_->GetV8ContextState(kChildFrameMainWorld);
   ASSERT_TRUE(v8_state);
   EXPECT_EQ(kChildFrameMainWorld, v8_state->description.token);
   EXPECT_EQ(mojom::V8ContextWorldType::kMain, v8_state->description.world_type);
   EXPECT_FALSE(v8_state->description.world_name);
   ASSERT_TRUE(v8_state->description.execution_context_token);
-  EXPECT_EQ(blink::ExecutionContextToken(mock_graph.child_frame->frame_token()),
-            v8_state->description.execution_context_token.value());
-  ec_state =
-      tracker->GetExecutionContextState(mock_graph.child_frame->frame_token());
+  EXPECT_EQ(
+      blink::ExecutionContextToken(mock_graph_->child_frame->frame_token()),
+      v8_state->description.execution_context_token.value());
+  ec_state = tracker_->GetExecutionContextState(
+      mock_graph_->child_frame->frame_token());
   ASSERT_TRUE(ec_state);
-  EXPECT_EQ(blink::ExecutionContextToken(mock_graph.child_frame->frame_token()),
-            ec_state->token);
+  EXPECT_EQ(
+      blink::ExecutionContextToken(mock_graph_->child_frame->frame_token()),
+      ec_state->token);
 
   // Provide iframe data for the child frame.
 
   ASSERT_FALSE(ec_state->iframe_attribution_data);
-  tracker->OnRemoteIframeAttachedForTesting(
-      mock_graph.child_frame.get(), mock_graph.frame.get(),
+  tracker_->OnRemoteIframeAttachedForTesting(
+      mock_graph_->child_frame.get(), mock_graph_->frame.get(),
       kChildFrameRemoteToken, GetFakeIframeAttributionDataPtr());
 
   const auto& iad = ec_state->iframe_attribution_data;