Commit ea5ca90e authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

PM: On-demand instantiate process data in FrozenFrameAggregator.

It's an eyesore that we're instantiating and describing this data
on non-renderer process nodes.

Bug: 1080647
Change-Id: I00ac8f6fc8732b66ffb42516c7d140113c7aa84a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218556Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772396}
parent b2d9b333
...@@ -158,11 +158,6 @@ void FrozenFrameAggregator::OnPageNodeAdded(const PageNode* page_node) { ...@@ -158,11 +158,6 @@ void FrozenFrameAggregator::OnPageNodeAdded(const PageNode* page_node) {
FrozenDataImpl::GetOrCreate(page_impl); FrozenDataImpl::GetOrCreate(page_impl);
} }
void FrozenFrameAggregator::OnProcessNodeAdded(
const ProcessNode* process_node) {
FrozenDataImpl::GetOrCreate(ProcessNodeImpl::FromNode(process_node));
}
base::Value FrozenFrameAggregator::DescribePageNodeData( base::Value FrozenFrameAggregator::DescribePageNodeData(
const PageNode* node) const { const PageNode* node) const {
FrozenDataImpl* data = FrozenDataImpl::Get(PageNodeImpl::FromNode(node)); FrozenDataImpl* data = FrozenDataImpl::Get(PageNodeImpl::FromNode(node));
...@@ -227,7 +222,10 @@ void FrozenFrameAggregator::UpdateFrameCounts(FrameNodeImpl* frame_node, ...@@ -227,7 +222,10 @@ void FrozenFrameAggregator::UpdateFrameCounts(FrameNodeImpl* frame_node,
auto* page_node = frame_node->page_node(); auto* page_node = frame_node->page_node();
auto* process_node = frame_node->process_node(); auto* process_node = frame_node->process_node();
auto* page_data = FrozenDataImpl::Get(page_node); auto* page_data = FrozenDataImpl::Get(page_node);
auto* process_data = FrozenDataImpl::Get(process_node); auto* process_data = FrozenDataImpl::GetOrCreate(process_node);
// We should only have frames attached to renderer processes.
DCHECK_EQ(content::PROCESS_TYPE_RENDERER, process_node->process_type());
// Set the page lifecycle state based on the state of the frame tree. // Set the page lifecycle state based on the state of the frame tree.
if (page_data->ChangeFrameCounts(current_frame_delta, frozen_frame_delta)) { if (page_data->ChangeFrameCounts(current_frame_delta, frozen_frame_delta)) {
......
...@@ -47,9 +47,6 @@ class FrozenFrameAggregator : public FrameNode::ObserverDefaultImpl, ...@@ -47,9 +47,6 @@ class FrozenFrameAggregator : public FrameNode::ObserverDefaultImpl,
// PageNodeObserver implementation: // PageNodeObserver implementation:
void OnPageNodeAdded(const PageNode* page_node) override; void OnPageNodeAdded(const PageNode* page_node) override;
// ProcessNodeObserver implementation:
void OnProcessNodeAdded(const ProcessNode* process_node) override;
// NodeDataDescriber implementation: // NodeDataDescriber implementation:
base::Value DescribePageNodeData(const PageNode* node) const override; base::Value DescribePageNodeData(const PageNode* node) const override;
base::Value DescribeProcessNodeData(const ProcessNode* node) const override; base::Value DescribeProcessNodeData(const ProcessNode* node) const override;
......
...@@ -68,6 +68,11 @@ class FrozenFrameAggregatorTest : public GraphTestHarness { ...@@ -68,6 +68,11 @@ class FrozenFrameAggregatorTest : public GraphTestHarness {
ExpectData(process_node_.get(), current_frame_count, frozen_frame_count); ExpectData(process_node_.get(), current_frame_count, frozen_frame_count);
} }
void ExpectNoProcessData() {
EXPECT_EQ(nullptr,
FrozenFrameAggregator::Data::GetForTesting(process_node_.get()));
}
void ExpectRunning() { void ExpectRunning() {
EXPECT_EQ(LifecycleState::kRunning, page_node_.get()->lifecycle_state()); EXPECT_EQ(LifecycleState::kRunning, page_node_.get()->lifecycle_state());
} }
...@@ -94,11 +99,12 @@ TEST_F(FrozenFrameAggregatorTest, ProcessAggregation) { ...@@ -94,11 +99,12 @@ TEST_F(FrozenFrameAggregatorTest, ProcessAggregation) {
MockProcessNodeObserver obs; MockProcessNodeObserver obs;
graph()->AddProcessNodeObserver(&obs); graph()->AddProcessNodeObserver(&obs);
ExpectProcessData(0, 0); // The data should be created on first aggregation.
ExpectNoProcessData();
// Add a main frame. // Add a main frame.
auto f0 = CreateFrame(nullptr, 0); auto f0 = CreateFrame(nullptr, 0);
ExpectProcessData(0, 0); ExpectNoProcessData();
// Make the frame current. // Make the frame current.
f0.get()->SetIsCurrent(true); f0.get()->SetIsCurrent(true);
......
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