Commit 505e8e8f authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

[PM] Process Metrics Decorator - Prevent a crash in unit tests

The Memory Instrumentation service isn't available in unit_tests, this
add a check to verify that the service exists before trying to calling
it.

Change-Id: I6f4ceb28fe828b8229888bbff5d58a445051cd5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783304Reviewed-by: default avatarSigurður Ásgeirsson <siggi@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694752}
parent be11a3e6
...@@ -52,8 +52,12 @@ void ProcessMetricsDecorator::RequestProcessesMemoryMetrics( ...@@ -52,8 +52,12 @@ void ProcessMetricsDecorator::RequestProcessesMemoryMetrics(
callback) { callback) {
auto* mem_instrumentation = auto* mem_instrumentation =
memory_instrumentation::MemoryInstrumentation::GetInstance(); memory_instrumentation::MemoryInstrumentation::GetInstance();
mem_instrumentation->RequestPrivateMemoryFootprint(base::kNullProcessId, // The memory instrumentation service is not available in unit tests unless
std::move(callback)); // explicitly created.
if (mem_instrumentation) {
mem_instrumentation->RequestPrivateMemoryFootprint(base::kNullProcessId,
std::move(callback));
}
} }
void ProcessMetricsDecorator::DidGetMemoryUsage( void ProcessMetricsDecorator::DidGetMemoryUsage(
......
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