Commit 4e141241 authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

[PM] Make the node creation functions static.

Since they don't need access to the PerformanceManager instance on the
main thread, they can be implemented by calling CallOnGraphImpl(), which
is static.

Bug: 1013127
Change-Id: I3cdb2bc77f2258e013bdc3dd384f1527c08f1d1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108086
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarSigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751863}
parent 4bb6b3b8
......@@ -33,8 +33,7 @@ void BrowserChildProcessWatcher::Initialize() {
DCHECK(gpu_process_nodes_.empty());
browser_process_node_ =
PerformanceManagerImpl::GetInstance()->CreateProcessNode(
RenderProcessHostProxy());
PerformanceManagerImpl::CreateProcessNode(RenderProcessHostProxy());
OnProcessLaunched(base::Process::Current(), browser_process_node_.get());
BrowserChildProcessObserver::Add(this);
}
......@@ -51,15 +50,14 @@ void BrowserChildProcessWatcher::TearDown() {
nodes.push_back(std::move(node.second));
gpu_process_nodes_.clear();
PerformanceManagerImpl::GetInstance()->BatchDeleteNodes(std::move(nodes));
PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes));
}
void BrowserChildProcessWatcher::BrowserChildProcessLaunchedAndConnected(
const content::ChildProcessData& data) {
if (data.process_type == content::PROCESS_TYPE_GPU) {
std::unique_ptr<ProcessNodeImpl> gpu_node =
PerformanceManagerImpl::GetInstance()->CreateProcessNode(
RenderProcessHostProxy());
PerformanceManagerImpl::CreateProcessNode(RenderProcessHostProxy());
OnProcessLaunched(data.GetProcess(), gpu_node.get());
gpu_process_nodes_[data.id] = std::move(gpu_node);
}
......@@ -74,7 +72,7 @@ void BrowserChildProcessWatcher::BrowserChildProcessHostDisconnected(
// launch-and-connect notification arrives.
// See https://crbug.com/942500.
if (it != gpu_process_nodes_.end()) {
PerformanceManagerImpl::GetInstance()->DeleteNode(std::move(it->second));
PerformanceManagerImpl::DeleteNode(std::move(it->second));
gpu_process_nodes_.erase(it);
}
}
......@@ -101,7 +99,7 @@ void BrowserChildProcessWatcher::GPUProcessExited(int id, int exit_code) {
if (base::Contains(gpu_process_nodes_, id)) {
auto* process_node = gpu_process_nodes_[id].get();
DCHECK(PerformanceManagerImpl::GetInstance());
DCHECK(PerformanceManagerImpl::IsAvailable());
PerformanceManagerImpl::GetTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&ProcessNodeImpl::SetProcessExitStatus,
base::Unretained(process_node), exit_code));
......@@ -122,7 +120,7 @@ void BrowserChildProcessWatcher::OnProcessLaunched(
process.CreationTime();
#endif
DCHECK(PerformanceManagerImpl::GetInstance());
DCHECK(PerformanceManagerImpl::IsAvailable());
PerformanceManagerImpl::GetTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&ProcessNodeImpl::SetProcess,
base::Unretained(process_node),
......
......@@ -96,6 +96,7 @@ void PerformanceManagerImpl::Destroy(
GetTaskRunner()->DeleteSoon(FROM_HERE, instance.release());
}
// static
std::unique_ptr<FrameNodeImpl> PerformanceManagerImpl::CreateFrameNode(
ProcessNodeImpl* process_node,
PageNodeImpl* page_node,
......@@ -112,6 +113,7 @@ std::unique_ptr<FrameNodeImpl> PerformanceManagerImpl::CreateFrameNode(
browsing_instance_id, site_instance_id);
}
// static
std::unique_ptr<PageNodeImpl> PerformanceManagerImpl::CreatePageNode(
const WebContentsProxy& contents_proxy,
const std::string& browser_context_id,
......@@ -123,12 +125,14 @@ std::unique_ptr<PageNodeImpl> PerformanceManagerImpl::CreatePageNode(
visible_url, is_visible, is_audible);
}
// static
std::unique_ptr<ProcessNodeImpl> PerformanceManagerImpl::CreateProcessNode(
RenderProcessHostProxy proxy) {
return CreateNodeImpl<ProcessNodeImpl>(
base::OnceCallback<void(ProcessNodeImpl*)>(), proxy);
}
// static
std::unique_ptr<WorkerNodeImpl> PerformanceManagerImpl::CreateWorkerNode(
const std::string& browser_context_id,
WorkerNode::WorkerType worker_type,
......@@ -139,20 +143,22 @@ std::unique_ptr<WorkerNodeImpl> PerformanceManagerImpl::CreateWorkerNode(
worker_type, process_node, dev_tools_token);
}
// static
void PerformanceManagerImpl::DeleteNode(std::unique_ptr<NodeBase> node) {
GetTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&PerformanceManagerImpl::DeleteNodeImpl,
base::Unretained(this), node.release()));
CallOnGraphImpl(
FROM_HERE,
base::BindOnce(&PerformanceManagerImpl::DeleteNodeImpl, node.release()));
}
// static
void PerformanceManagerImpl::BatchDeleteNodes(
std::vector<std::unique_ptr<NodeBase>> nodes) {
// Move the nodes vector to the heap.
auto nodes_ptr = std::make_unique<std::vector<std::unique_ptr<NodeBase>>>(
std::move(nodes));
GetTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&PerformanceManagerImpl::BatchDeleteNodesImpl,
base::Unretained(this), nodes_ptr.release()));
CallOnGraphImpl(FROM_HERE,
base::BindOnce(&PerformanceManagerImpl::BatchDeleteNodesImpl,
nodes_ptr.release()));
}
PerformanceManagerImpl::PerformanceManagerImpl() {
......@@ -175,6 +181,7 @@ void AddNodeAndInvokeCreationCallback(
} // namespace
// static
template <typename NodeType, typename... Args>
std::unique_ptr<NodeType> PerformanceManagerImpl::CreateNodeImpl(
base::OnceCallback<void(NodeType*)> creation_callback,
......@@ -188,32 +195,35 @@ std::unique_ptr<NodeType> PerformanceManagerImpl::CreateNodeImpl(
return new_node;
}
void PerformanceManagerImpl::DeleteNodeImpl(NodeBase* node_ptr) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// static
void PerformanceManagerImpl::DeleteNodeImpl(NodeBase* node_ptr,
GraphImpl* graph) {
// Must be done first to avoid leaking |node_ptr|.
std::unique_ptr<NodeBase> node(node_ptr);
graph_.RemoveNode(node.get());
graph->RemoveNode(node.get());
}
namespace {
void RemoveFrameAndChildrenFromGraph(FrameNodeImpl* frame_node) {
void RemoveFrameAndChildrenFromGraph(FrameNodeImpl* frame_node,
GraphImpl* graph) {
// Recurse on the first child while there is one.
while (!frame_node->child_frame_nodes().empty())
RemoveFrameAndChildrenFromGraph(*(frame_node->child_frame_nodes().begin()));
while (!frame_node->child_frame_nodes().empty()) {
RemoveFrameAndChildrenFromGraph(*(frame_node->child_frame_nodes().begin()),
graph);
}
// Now that all children are deleted, delete this frame.
frame_node->graph()->RemoveNode(frame_node);
graph->RemoveNode(frame_node);
}
} // namespace
// static
void PerformanceManagerImpl::BatchDeleteNodesImpl(
std::vector<std::unique_ptr<NodeBase>>* nodes_ptr) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::vector<std::unique_ptr<NodeBase>>* nodes_ptr,
GraphImpl* graph) {
// Must be done first to avoid leaking |nodes_ptr|.
std::unique_ptr<std::vector<std::unique_ptr<NodeBase>>> nodes(nodes_ptr);
......@@ -225,11 +235,12 @@ void PerformanceManagerImpl::BatchDeleteNodesImpl(
auto* page_node = PageNodeImpl::FromNodeBase(node.get());
// Delete the main frame nodes until no more exist.
while (!page_node->main_frame_nodes().empty())
while (!page_node->main_frame_nodes().empty()) {
RemoveFrameAndChildrenFromGraph(
*(page_node->main_frame_nodes().begin()));
*(page_node->main_frame_nodes().begin()), graph);
}
graph_.RemoveNode(page_node);
graph->RemoveNode(page_node);
break;
}
case ProcessNodeImpl::Type(): {
......@@ -243,7 +254,7 @@ void PerformanceManagerImpl::BatchDeleteNodesImpl(
break;
case WorkerNodeImpl::Type(): {
auto* worker_node = WorkerNodeImpl::FromNodeBase(node.get());
graph_.RemoveNode(worker_node);
graph->RemoveNode(worker_node);
break;
}
case SystemNodeImpl::Type():
......@@ -257,7 +268,7 @@ void PerformanceManagerImpl::BatchDeleteNodesImpl(
// Remove the process nodes from the graph.
for (auto* process_node : process_nodes)
graph_.RemoveNode(process_node);
graph->RemoveNode(process_node);
// When |nodes| goes out of scope, all nodes are deleted.
}
......
......@@ -73,7 +73,7 @@ class PerformanceManagerImpl : public PerformanceManager {
// May be called from any sequence. If a |creation_callback| is provided it
// will be run on the performance manager sequence immediately after creating
// the node.
std::unique_ptr<FrameNodeImpl> CreateFrameNode(
static std::unique_ptr<FrameNodeImpl> CreateFrameNode(
ProcessNodeImpl* process_node,
PageNodeImpl* page_node,
FrameNodeImpl* parent_frame_node,
......@@ -84,15 +84,15 @@ class PerformanceManagerImpl : public PerformanceManager {
int32_t site_instance_id,
FrameNodeCreationCallback creation_callback =
FrameNodeCreationCallback());
std::unique_ptr<PageNodeImpl> CreatePageNode(
static std::unique_ptr<PageNodeImpl> CreatePageNode(
const WebContentsProxy& contents_proxy,
const std::string& browser_context_id,
const GURL& visible_url,
bool is_visible,
bool is_audible);
std::unique_ptr<ProcessNodeImpl> CreateProcessNode(
static std::unique_ptr<ProcessNodeImpl> CreateProcessNode(
RenderProcessHostProxy proxy);
std::unique_ptr<WorkerNodeImpl> CreateWorkerNode(
static std::unique_ptr<WorkerNodeImpl> CreateWorkerNode(
const std::string& browser_context_id,
WorkerNode::WorkerType worker_type,
ProcessNodeImpl* process_node,
......@@ -100,12 +100,12 @@ class PerformanceManagerImpl : public PerformanceManager {
// Destroys a node returned from the creation functions above.
// May be called from any sequence.
void DeleteNode(std::unique_ptr<NodeBase> node);
static void DeleteNode(std::unique_ptr<NodeBase> node);
// Each node in |nodes| must have been returned from one of the creation
// functions above. This function takes care of removing them from the graph
// in topological order and destroying them.
void BatchDeleteNodes(std::vector<std::unique_ptr<NodeBase>> nodes);
static void BatchDeleteNodes(std::vector<std::unique_ptr<NodeBase>> nodes);
// Returns the performance manager TaskRunner.
// TODO(chrisha): Hide this after the last consumer stops using it!
......@@ -123,7 +123,7 @@ class PerformanceManagerImpl : public PerformanceManager {
PerformanceManagerImpl();
template <typename NodeType, typename... Args>
std::unique_ptr<NodeType> CreateNodeImpl(
static std::unique_ptr<NodeType> CreateNodeImpl(
base::OnceCallback<void(NodeType*)> creation_callback,
Args&&... constructor_args);
......@@ -133,8 +133,10 @@ class PerformanceManagerImpl : public PerformanceManager {
// Note that this function has similar semantics to
// SequencedTaskRunner::DeleteSoon(). The node/vector of nodes is passed via a
// regular pointer so that they are not deleted if the task is not executed.
void DeleteNodeImpl(NodeBase* node_ptr);
void BatchDeleteNodesImpl(std::vector<std::unique_ptr<NodeBase>>* nodes_ptr);
static void DeleteNodeImpl(NodeBase* node_ptr, GraphImpl* graph);
static void BatchDeleteNodesImpl(
std::vector<std::unique_ptr<NodeBase>>* nodes_ptr,
GraphImpl* graph);
void OnStartImpl(GraphImplCallback graph_callback);
static void RunCallbackWithGraphImpl(GraphImplCallback graph_callback);
......
......@@ -34,20 +34,13 @@ class PerformanceManagerImplTest : public testing::Test {
}
void TearDown() override {
if (performance_manager_) {
PerformanceManagerImpl::Destroy(std::move(performance_manager_));
// Make sure destruction unregisters the instance.
EXPECT_EQ(nullptr, PerformanceManagerImpl::GetInstance());
}
PerformanceManagerImpl::Destroy(std::move(performance_manager_));
// Make sure destruction unregisters the instance.
EXPECT_EQ(nullptr, PerformanceManagerImpl::GetInstance());
task_environment_.RunUntilIdle();
}
protected:
PerformanceManagerImpl* performance_manager() {
return performance_manager_.get();
}
private:
std::unique_ptr<PerformanceManagerImpl> performance_manager_;
base::test::TaskEnvironment task_environment_;
......@@ -59,58 +52,58 @@ TEST_F(PerformanceManagerImplTest, InstantiateNodes) {
int next_render_frame_id = 0;
std::unique_ptr<ProcessNodeImpl> process_node =
performance_manager()->CreateProcessNode(RenderProcessHostProxy());
PerformanceManagerImpl::CreateProcessNode(RenderProcessHostProxy());
EXPECT_NE(nullptr, process_node.get());
std::unique_ptr<PageNodeImpl> page_node =
performance_manager()->CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
PerformanceManagerImpl::CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
EXPECT_NE(nullptr, page_node.get());
// Create a node of each type.
std::unique_ptr<FrameNodeImpl> frame_node =
performance_manager()->CreateFrameNode(
PerformanceManagerImpl::CreateFrameNode(
process_node.get(), page_node.get(), nullptr, 0,
++next_render_frame_id, base::UnguessableToken::Create(), 0, 0);
EXPECT_NE(nullptr, frame_node.get());
performance_manager()->DeleteNode(std::move(frame_node));
performance_manager()->DeleteNode(std::move(page_node));
performance_manager()->DeleteNode(std::move(process_node));
PerformanceManagerImpl::DeleteNode(std::move(frame_node));
PerformanceManagerImpl::DeleteNode(std::move(page_node));
PerformanceManagerImpl::DeleteNode(std::move(process_node));
}
TEST_F(PerformanceManagerImplTest, BatchDeleteNodes) {
int next_render_frame_id = 0;
// Create a page node and a small hierarchy of frames.
std::unique_ptr<ProcessNodeImpl> process_node =
performance_manager()->CreateProcessNode(RenderProcessHostProxy());
PerformanceManagerImpl::CreateProcessNode(RenderProcessHostProxy());
std::unique_ptr<PageNodeImpl> page_node =
performance_manager()->CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
PerformanceManagerImpl::CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
std::unique_ptr<FrameNodeImpl> parent1_frame =
performance_manager()->CreateFrameNode(
PerformanceManagerImpl::CreateFrameNode(
process_node.get(), page_node.get(), nullptr, 0,
++next_render_frame_id, base::UnguessableToken::Create(), 0, 0);
std::unique_ptr<FrameNodeImpl> parent2_frame =
performance_manager()->CreateFrameNode(
PerformanceManagerImpl::CreateFrameNode(
process_node.get(), page_node.get(), nullptr, 1,
++next_render_frame_id, base::UnguessableToken::Create(), 0, 0);
std::unique_ptr<FrameNodeImpl> child1_frame =
performance_manager()->CreateFrameNode(
PerformanceManagerImpl::CreateFrameNode(
process_node.get(), page_node.get(), parent1_frame.get(), 2,
++next_render_frame_id, base::UnguessableToken::Create(), 0, 0);
std::unique_ptr<FrameNodeImpl> child2_frame =
performance_manager()->CreateFrameNode(
PerformanceManagerImpl::CreateFrameNode(
process_node.get(), page_node.get(), parent2_frame.get(), 3,
++next_render_frame_id, base::UnguessableToken::Create(), 0, 0);
std::vector<std::unique_ptr<NodeBase>> nodes;
for (size_t i = 0; i < 10; ++i) {
nodes.push_back(performance_manager()->CreateFrameNode(
nodes.push_back(PerformanceManagerImpl::CreateFrameNode(
process_node.get(), page_node.get(), child1_frame.get(), 0,
++next_render_frame_id, base::UnguessableToken::Create(), 0, 0));
nodes.push_back(performance_manager()->CreateFrameNode(
nodes.push_back(PerformanceManagerImpl::CreateFrameNode(
process_node.get(), page_node.get(), child1_frame.get(), 1,
++next_render_frame_id, base::UnguessableToken::Create(), 0, 0));
}
......@@ -122,14 +115,14 @@ TEST_F(PerformanceManagerImplTest, BatchDeleteNodes) {
nodes.push_back(std::move(child1_frame));
nodes.push_back(std::move(child2_frame));
performance_manager()->BatchDeleteNodes(std::move(nodes));
PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes));
}
TEST_F(PerformanceManagerImplTest, CallOnGraphImpl) {
// Create a page node for something to target.
std::unique_ptr<PageNodeImpl> page_node =
performance_manager()->CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
PerformanceManagerImpl::CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
base::RunLoop run_loop;
base::OnceClosure quit_closure = run_loop.QuitClosure();
EXPECT_FALSE(PerformanceManagerImpl::OnPMTaskRunnerForTesting());
......@@ -143,14 +136,14 @@ TEST_F(PerformanceManagerImplTest, CallOnGraphImpl) {
PerformanceManagerImpl::CallOnGraphImpl(FROM_HERE, std::move(graph_callback));
run_loop.Run();
performance_manager()->DeleteNode(std::move(page_node));
PerformanceManagerImpl::DeleteNode(std::move(page_node));
}
TEST_F(PerformanceManagerImplTest, CallOnGraphAndReplyWithResult) {
// Create a page node for something to target.
std::unique_ptr<PageNodeImpl> page_node =
performance_manager()->CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
PerformanceManagerImpl::CreatePageNode(WebContentsProxy(), std::string(),
GURL(), false, false);
base::RunLoop run_loop;
EXPECT_FALSE(PerformanceManagerImpl::OnPMTaskRunnerForTesting());
......@@ -172,7 +165,7 @@ TEST_F(PerformanceManagerImplTest, CallOnGraphAndReplyWithResult) {
FROM_HERE, std::move(task), std::move(reply));
run_loop.Run();
performance_manager()->DeleteNode(std::move(page_node));
PerformanceManagerImpl::DeleteNode(std::move(page_node));
EXPECT_TRUE(reply_called);
}
......
......@@ -27,9 +27,8 @@ namespace performance_manager {
PerformanceManagerTabHelper::PerformanceManagerTabHelper(
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
performance_manager_(PerformanceManagerImpl::GetInstance()) {
page_node_ = performance_manager_->CreatePageNode(
: content::WebContentsObserver(web_contents) {
page_node_ = PerformanceManagerImpl::CreatePageNode(
WebContentsProxy(weak_factory_.GetWeakPtr()),
web_contents->GetBrowserContext()->UniqueId(),
web_contents->GetVisibleURL(),
......@@ -70,7 +69,7 @@ void PerformanceManagerTabHelper::TearDown() {
frames_.clear();
// Delete the page and its entire frame tree from the graph.
performance_manager_->BatchDeleteNodes(std::move(nodes));
PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes));
if (destruction_observer_) {
destruction_observer_->OnPerformanceManagerTabHelperDestroying(
......@@ -113,20 +112,22 @@ void PerformanceManagerTabHelper::RenderFrameCreated(
// Create the frame node, and provide a callback that will run in the graph to
// initialize it.
std::unique_ptr<FrameNodeImpl> frame = performance_manager_->CreateFrameNode(
process_node, page_node_.get(), parent_frame_node,
render_frame_host->GetFrameTreeNodeId(),
render_frame_host->GetRoutingID(),
render_frame_host->GetDevToolsFrameToken(),
site_instance->GetBrowsingInstanceId(), site_instance->GetId(),
base::BindOnce(
[](const GURL& url, bool is_current, FrameNodeImpl* frame_node) {
if (!url.is_empty())
frame_node->OnNavigationCommitted(url, /* same_document */ false);
frame_node->SetIsCurrent(is_current);
},
render_frame_host->GetLastCommittedURL(),
render_frame_host->IsCurrent()));
std::unique_ptr<FrameNodeImpl> frame =
PerformanceManagerImpl::CreateFrameNode(
process_node, page_node_.get(), parent_frame_node,
render_frame_host->GetFrameTreeNodeId(),
render_frame_host->GetRoutingID(),
render_frame_host->GetDevToolsFrameToken(),
site_instance->GetBrowsingInstanceId(), site_instance->GetId(),
base::BindOnce(
[](const GURL& url, bool is_current, FrameNodeImpl* frame_node) {
if (!url.is_empty())
frame_node->OnNavigationCommitted(url,
/* same_document */ false);
frame_node->SetIsCurrent(is_current);
},
render_frame_host->GetLastCommittedURL(),
render_frame_host->IsCurrent()));
frames_[render_frame_host] = std::move(frame);
}
......@@ -151,7 +152,7 @@ void PerformanceManagerTabHelper::RenderFrameDeleted(
observer.OnBeforeFrameNodeRemoved(this, frame_node.get());
// Then delete the node.
performance_manager_->DeleteNode(std::move(frame_node));
PerformanceManagerImpl::DeleteNode(std::move(frame_node));
frames_.erase(it);
}
......
......@@ -24,7 +24,6 @@ namespace performance_manager {
class FrameNodeImpl;
class PageNodeImpl;
class PerformanceManagerImpl;
// This tab helper maintains a page node, and its associated tree of frame nodes
// in the performance manager graph. It also sources a smattering of attributes
......@@ -119,8 +118,6 @@ class PerformanceManagerTabHelper
void OnMainFrameNavigation(int64_t navigation_id);
// The performance manager for this process, if any.
PerformanceManagerImpl* const performance_manager_;
std::unique_ptr<PageNodeImpl> page_node_;
ukm::SourceId ukm_source_id_ = ukm::kInvalidSourceId;
......
......@@ -30,12 +30,12 @@ RenderProcessUserData::RenderProcessUserData(
content::RenderProcessHost* render_process_host)
: host_(render_process_host) {
host_->AddObserver(this);
process_node_ = PerformanceManagerImpl::GetInstance()->CreateProcessNode(
process_node_ = PerformanceManagerImpl::CreateProcessNode(
RenderProcessHostProxy(host_->GetID()));
}
RenderProcessUserData::~RenderProcessUserData() {
PerformanceManagerImpl::GetInstance()->DeleteNode(std::move(process_node_));
PerformanceManagerImpl::DeleteNode(std::move(process_node_));
host_->RemoveObserver(this);
if (destruction_observer_) {
......
......@@ -112,7 +112,7 @@ void WorkerWatcher::TearDown() {
nodes.push_back(std::move(node.second));
shared_worker_nodes_.clear();
PerformanceManagerImpl::GetInstance()->BatchDeleteNodes(std::move(nodes));
PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes));
dedicated_worker_service_observer_.RemoveAll();
shared_worker_service_observer_.RemoveAll();
......@@ -124,7 +124,7 @@ void WorkerWatcher::OnWorkerStarted(
content::GlobalFrameRoutingId ancestor_render_frame_host_id) {
// TODO(https://crbug.com/993029): Plumb through the URL and the DevTools
// token.
auto worker_node = PerformanceManagerImpl::GetInstance()->CreateWorkerNode(
auto worker_node = PerformanceManagerImpl::CreateWorkerNode(
browser_context_id_, WorkerNode::WorkerType::kDedicated,
process_node_source_->GetProcessNode(worker_process_id),
base::UnguessableToken::Create());
......@@ -147,7 +147,7 @@ void WorkerWatcher::OnBeforeWorkerTerminated(
#if DCHECK_IS_ON()
DCHECK(!base::Contains(clients_to_remove_, worker_node.get()));
#endif // DCHECK_IS_ON()
PerformanceManagerImpl::GetInstance()->DeleteNode(std::move(worker_node));
PerformanceManagerImpl::DeleteNode(std::move(worker_node));
dedicated_worker_nodes_.erase(it);
}
......@@ -162,7 +162,7 @@ void WorkerWatcher::OnWorkerStarted(
content::SharedWorkerId shared_worker_id,
int worker_process_id,
const base::UnguessableToken& dev_tools_token) {
auto worker_node = PerformanceManagerImpl::GetInstance()->CreateWorkerNode(
auto worker_node = PerformanceManagerImpl::CreateWorkerNode(
browser_context_id_, WorkerNode::WorkerType::kShared,
process_node_source_->GetProcessNode(worker_process_id), dev_tools_token);
bool inserted =
......@@ -180,7 +180,7 @@ void WorkerWatcher::OnBeforeWorkerTerminated(
#if DCHECK_IS_ON()
DCHECK(!base::Contains(clients_to_remove_, worker_node.get()));
#endif // DCHECK_IS_ON()
PerformanceManagerImpl::GetInstance()->DeleteNode(std::move(worker_node));
PerformanceManagerImpl::DeleteNode(std::move(worker_node));
shared_worker_nodes_.erase(it);
}
......
......@@ -308,7 +308,7 @@ TestProcessNodeSource::~TestProcessNodeSource() {
std::unique_ptr<ProcessNodeImpl> process_node = std::move(kv.second);
nodes.push_back(std::move(process_node));
}
PerformanceManagerImpl::GetInstance()->BatchDeleteNodes(std::move(nodes));
PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes));
process_node_map_.clear();
}
......@@ -323,8 +323,8 @@ int TestProcessNodeSource::CreateProcessNode() {
int render_process_id = GenerateNextId();
// Create the process node and insert it into the map.
auto process_node = PerformanceManagerImpl::GetInstance()->CreateProcessNode(
RenderProcessHostProxy());
auto process_node =
PerformanceManagerImpl::CreateProcessNode(RenderProcessHostProxy());
bool inserted =
process_node_map_.insert({render_process_id, std::move(process_node)})
.second;
......@@ -376,12 +376,11 @@ class TestFrameNodeSource : public FrameNodeSource {
};
TestFrameNodeSource::TestFrameNodeSource()
: page_node_(PerformanceManagerImpl::GetInstance()->CreatePageNode(
WebContentsProxy(),
"page_node_context_id",
GURL(),
false,
false)) {}
: page_node_(PerformanceManagerImpl::CreatePageNode(WebContentsProxy(),
"page_node_context_id",
GURL(),
false,
false)) {}
TestFrameNodeSource::~TestFrameNodeSource() {
std::vector<std::unique_ptr<NodeBase>> nodes;
......@@ -389,7 +388,7 @@ TestFrameNodeSource::~TestFrameNodeSource() {
nodes.reserve(frame_node_map_.size());
for (auto& kv : frame_node_map_)
nodes.push_back(std::move(kv.second));
PerformanceManagerImpl::GetInstance()->BatchDeleteNodes(std::move(nodes));
PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes));
frame_node_map_.clear();
}
......@@ -427,7 +426,7 @@ content::GlobalFrameRoutingId TestFrameNodeSource::CreateFrameNode(
int frame_id = GenerateNextId();
content::GlobalFrameRoutingId render_frame_host_id(render_process_id,
frame_id);
auto frame_node = PerformanceManagerImpl::GetInstance()->CreateFrameNode(
auto frame_node = PerformanceManagerImpl::CreateFrameNode(
process_node, page_node_.get(), nullptr, 0, frame_id,
base::UnguessableToken::Null(), 0, 0);
......@@ -448,7 +447,7 @@ void TestFrameNodeSource::DeleteFrameNode(
// Notify the subscriber then delete the node.
InvokeAndRemoveCallback(frame_node);
PerformanceManagerImpl::GetInstance()->DeleteNode(std::move(it->second));
PerformanceManagerImpl::DeleteNode(std::move(it->second));
frame_node_map_.erase(it);
}
......@@ -482,10 +481,6 @@ class WorkerWatcherTest : public testing::Test {
content::DedicatedWorkerId dedicated_worker_id);
WorkerNodeImpl* GetSharedWorkerNode(content::SharedWorkerId shared_worker_id);
PerformanceManagerImpl* performance_manager() {
return performance_manager_.get();
}
TestDedicatedWorkerService* dedicated_worker_service() {
return &dedicated_worker_service_;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment