Commit 1546dd6b authored by Joe Mason's avatar Joe Mason Committed by Chromium LUCI CQ

[PM] Rename WebMemoryAggregator to WebMemoryMeasurer

This class manages the memory request but does not actually do the
aggregation. crrev.com/c/2557730 will add another class that does the
aggregation after the response is received.

The unit tests are still named WebMemoryAggregator because they will
also test the new aggregator class which will be invoked by
WebMemoryMeasurer.

Bug: 1085129
Change-Id: I21a13a407cb96d720463e4d5b009098156324294
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2569675Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Commit-Queue: Joe Mason <joenotcharles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833341}
parent 057f9f76
...@@ -84,23 +84,22 @@ void WebMeasureMemory( ...@@ -84,23 +84,22 @@ void WebMeasureMemory(
const FrameNode* frame_node, const FrameNode* frame_node,
mojom::WebMemoryMeasurement::Mode mode, mojom::WebMemoryMeasurement::Mode mode,
base::OnceCallback<void(mojom::WebMemoryMeasurementPtr)> callback) { base::OnceCallback<void(mojom::WebMemoryMeasurementPtr)> callback) {
auto web_memory_aggregator = std::make_unique<WebMemoryAggregator>( auto measurer = std::make_unique<WebMemoryMeasurer>(
frame_node->GetFrameToken(), frame_node->GetFrameToken(),
WebMeasurementModeToRequestMeasurementMode(mode), std::move(callback)); WebMeasurementModeToRequestMeasurementMode(mode), std::move(callback));
// Create a measurement complete callback to own |web_memory_aggregator|. It // Create a measurement complete callback to own |measurer|. It
// will be deleted when the callback is executed or dropped. // will be deleted when the callback is executed or dropped.
V8DetailedMemoryRequestOneShot* request = web_memory_aggregator->request(); V8DetailedMemoryRequestOneShot* request = measurer->request();
auto measurement_complete_callback = auto measurement_complete_callback = base::BindOnce(
base::BindOnce(&WebMemoryAggregator::MeasurementComplete, &WebMemoryMeasurer::MeasurementComplete, std::move(measurer));
std::move(web_memory_aggregator));
// Start memory measurement for the process of the given frame. // Start memory measurement for the process of the given frame.
request->StartMeasurement(frame_node->GetProcessNode(), request->StartMeasurement(frame_node->GetProcessNode(),
std::move(measurement_complete_callback)); std::move(measurement_complete_callback));
} }
WebMemoryAggregator::WebMemoryAggregator( WebMemoryMeasurer::WebMemoryMeasurer(
const blink::LocalFrameToken& frame_token, const blink::LocalFrameToken& frame_token,
V8DetailedMemoryRequest::MeasurementMode mode, V8DetailedMemoryRequest::MeasurementMode mode,
MeasurementCallback callback) MeasurementCallback callback)
...@@ -108,9 +107,9 @@ WebMemoryAggregator::WebMemoryAggregator( ...@@ -108,9 +107,9 @@ WebMemoryAggregator::WebMemoryAggregator(
callback_(std::move(callback)), callback_(std::move(callback)),
request_(std::make_unique<V8DetailedMemoryRequestOneShot>(mode)) {} request_(std::make_unique<V8DetailedMemoryRequestOneShot>(mode)) {}
WebMemoryAggregator::~WebMemoryAggregator() = default; WebMemoryMeasurer::~WebMemoryMeasurer() = default;
void WebMemoryAggregator::MeasurementComplete( void WebMemoryMeasurer::MeasurementComplete(
const ProcessNode* process_node, const ProcessNode* process_node,
const V8DetailedMemoryProcessData*) { const V8DetailedMemoryProcessData*) {
std::move(callback_).Run(BuildMemoryUsageResult(frame_token_, process_node)); std::move(callback_).Run(BuildMemoryUsageResult(frame_token_, process_node));
......
...@@ -18,17 +18,19 @@ class ProcessNode; ...@@ -18,17 +18,19 @@ class ProcessNode;
namespace v8_memory { namespace v8_memory {
// A helper class for implementing WebMeasureMemory(). // A helper class for implementing WebMeasureMemory(). This manages a request
class WebMemoryAggregator { // object that sends a V8 detailed memory request to the renderer, and formats
// the result into a mojom::WebMemoryMeasurement.
class WebMemoryMeasurer {
public: public:
using MeasurementCallback = using MeasurementCallback =
base::OnceCallback<void(mojom::WebMemoryMeasurementPtr)>; base::OnceCallback<void(mojom::WebMemoryMeasurementPtr)>;
WebMemoryAggregator(const blink::LocalFrameToken&, WebMemoryMeasurer(const blink::LocalFrameToken&,
V8DetailedMemoryRequest::MeasurementMode, V8DetailedMemoryRequest::MeasurementMode,
MeasurementCallback); MeasurementCallback);
~WebMemoryAggregator(); ~WebMemoryMeasurer();
V8DetailedMemoryRequestOneShot* request() const { return request_.get(); } V8DetailedMemoryRequestOneShot* request() const { return request_.get(); }
......
...@@ -100,7 +100,7 @@ void WebMemoryAggregatorTest::MeasureAndVerify( ...@@ -100,7 +100,7 @@ void WebMemoryAggregatorTest::MeasureAndVerify(
FrameNodeImpl* frame, FrameNodeImpl* frame,
base::flat_map<std::string, Bytes> expected) { base::flat_map<std::string, Bytes> expected) {
bool measurement_done = false; bool measurement_done = false;
WebMemoryAggregator web_memory( WebMemoryMeasurer web_memory(
frame->frame_token(), V8DetailedMemoryRequest::MeasurementMode::kDefault, frame->frame_token(), V8DetailedMemoryRequest::MeasurementMode::kDefault,
base::BindLambdaForTesting([&measurement_done, &expected]( base::BindLambdaForTesting([&measurement_done, &expected](
mojom::WebMemoryMeasurementPtr result) { mojom::WebMemoryMeasurementPtr result) {
......
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