Commit 42f14ace authored by Rohan Pavone's avatar Rohan Pavone Committed by Commit Bot

[DevTools] Adds level of detail as an optional argument to requestMemoryDump.

RequestMemoryDump, by default, specifies DETAILED memory dumps. This
 change allows different levels to be specified so the manual memory
dump requests, like through Telemetry, can run on platforms that do
not support detailed dumps (or that do not wish to request them).

Change-Id: Id65e80d7763abace3e3631ace9409ab6fa57b0bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500958Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Rohan Pavone <rohpavone@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822784}
parent 9a3d48bd
......@@ -16,6 +16,7 @@
#include "base/format_macros.h"
#include "base/json/json_writer.h"
#include "base/memory/ref_counted_memory.h"
#include "base/optional.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
......@@ -213,6 +214,17 @@ void FillFrameData(base::trace_event::TracedValue* data,
}
}
base::Optional<base::trace_event::MemoryDumpLevelOfDetail>
StringToMemoryDumpLevelOfDetail(const std::string& str) {
if (str == Tracing::MemoryDumpLevelOfDetailEnum::Detailed)
return {base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
if (str == Tracing::MemoryDumpLevelOfDetailEnum::Background)
return {base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND};
if (str == Tracing::MemoryDumpLevelOfDetailEnum::Light)
return {base::trace_event::MemoryDumpLevelOfDetail::LIGHT};
return {};
}
// We currently don't support concurrent tracing sessions, but are planning to.
// For the time being, we're using this flag as a workaround to prevent devtools
// users from accidentally starting two concurrent sessions.
......@@ -926,12 +938,23 @@ void TracingHandler::OnCategoriesReceived(
void TracingHandler::RequestMemoryDump(
Maybe<bool> deterministic,
Maybe<std::string> level_of_detail,
std::unique_ptr<RequestMemoryDumpCallback> callback) {
if (!IsTracing()) {
callback->sendFailure(Response::ServerError("Tracing is not started"));
return;
}
base::Optional<base::trace_event::MemoryDumpLevelOfDetail> memory_detail =
StringToMemoryDumpLevelOfDetail(level_of_detail.fromMaybe(
Tracing::MemoryDumpLevelOfDetailEnum::Detailed));
if (!memory_detail) {
callback->sendFailure(
Response::ServerError("Invalid levelOfDetail specified."));
return;
}
auto determinism = deterministic.fromMaybe(false)
? base::trace_event::MemoryDumpDeterminism::FORCE_GC
: base::trace_event::MemoryDumpDeterminism::NONE;
......@@ -943,8 +966,7 @@ void TracingHandler::RequestMemoryDump(
memory_instrumentation::MemoryInstrumentation::GetInstance()
->RequestGlobalDumpAndAppendToTrace(
base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED,
base::trace_event::MemoryDumpLevelOfDetail::DETAILED, determinism,
std::move(on_memory_dump_finished));
*memory_detail, determinism, std::move(on_memory_dump_finished));
}
void TracingHandler::OnMemoryDumpFinished(
......
......@@ -74,6 +74,7 @@ class TracingHandler : public DevToolsDomainHandler, public Tracing::Backend {
void GetCategories(std::unique_ptr<GetCategoriesCallback> callback) override;
void RequestMemoryDump(
Maybe<bool> deterministic,
Maybe<std::string> level_of_detail,
std::unique_ptr<RequestMemoryDumpCallback> callback) override;
Response RecordClockSyncMarker(const std::string& sync_id) override;
......
......@@ -7835,6 +7835,15 @@ experimental domain Tracing
none
gzip
# Details exposed when memory request explicitly declared.
# Keep consistent with memory_dump_request_args.h and
# memory_instrumentation.mojom
type MemoryDumpLevelOfDetail extends string
enum
background
light
detailed
# Stop trace events collection.
command end
......@@ -7855,6 +7864,8 @@ experimental domain Tracing
parameters
# Enables more deterministic results by forcing garbage collection
optional boolean deterministic
# Specifies level of details in memory dump. Defaults to "detailed".
optional MemoryDumpLevelOfDetail levelOfDetail
returns
# GUID of the resulting global memory dump.
string dumpGuid
......
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