0

[tracing] Non-functional refactor of memory dump arg names

This CL is just cleaning up the inconsistencies accumulated
w.r.t. of names used in the TraceConfig vs enum names in
the codebase.
Also this simplifies the complex and unnecessary wrapping in
of the level of details argument in the RequestGlobalMemoryDump()
API.

BUG=
TBR=jochen@chromium.org,reed@google.com

Review URL: https://codereview.chromium.org/1337943003

Cr-Commit-Position: refs/heads/master@{#348715}
This commit is contained in:
primiano
2015-09-14 13:44:25 -07:00
committed by Commit bot
parent 7914825989
commit 82baa9afc6
23 changed files with 146 additions and 146 deletions

@ -13,7 +13,7 @@ namespace trace_event {
TEST(JavaHeapDumpProviderTest, JavaHeapDump) {
auto jhdp = JavaHeapDumpProvider::GetInstance();
scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump(nullptr));
MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
jhdp->OnMemoryDump(dump_args, pmd.get());
}

@ -126,7 +126,7 @@ TEST(MemoryAllocatorDumpTest, GuidGeneration) {
TEST(MemoryAllocatorDumpTest, DumpIntoProcessMemoryDump) {
FakeMemoryAllocatorDumpProvider fmadp;
ProcessMemoryDump pmd(make_scoped_refptr(new MemoryDumpSessionState()));
MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
fmadp.OnMemoryDump(dump_args, &pmd);

@ -48,21 +48,20 @@ uint32 g_heavy_dumps_rate = 0;
MemoryDumpManager* g_instance_for_testing = nullptr;
void RequestPeriodicGlobalDump() {
MemoryDumpArgs::LevelOfDetail dump_level_of_detail;
MemoryDumpLevelOfDetail level_of_detail;
if (g_heavy_dumps_rate == 0) {
dump_level_of_detail = MemoryDumpArgs::LevelOfDetail::LOW;
level_of_detail = MemoryDumpLevelOfDetail::LIGHT;
} else {
dump_level_of_detail = g_periodic_dumps_count == 0
? MemoryDumpArgs::LevelOfDetail::HIGH
: MemoryDumpArgs::LevelOfDetail::LOW;
level_of_detail = g_periodic_dumps_count == 0
? MemoryDumpLevelOfDetail::DETAILED
: MemoryDumpLevelOfDetail::LIGHT;
if (++g_periodic_dumps_count == g_heavy_dumps_rate)
g_periodic_dumps_count = 0;
}
MemoryDumpArgs dump_args = {dump_level_of_detail};
MemoryDumpManager::GetInstance()->RequestGlobalDump(
MemoryDumpType::PERIODIC_INTERVAL, dump_args);
MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
}
} // namespace
@ -204,9 +203,10 @@ void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) {
mdp_iter->unregistered = true;
}
void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type,
const MemoryDumpArgs& dump_args,
const MemoryDumpCallback& callback) {
void MemoryDumpManager::RequestGlobalDump(
MemoryDumpType dump_type,
MemoryDumpLevelOfDetail level_of_detail,
const MemoryDumpCallback& callback) {
// Bail out immediately if tracing is not enabled at all.
if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) {
if (!callback.is_null())
@ -230,13 +230,14 @@ void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type,
// The delegate will coordinate the IPC broadcast and at some point invoke
// CreateProcessDump() to get a dump for the current process.
MemoryDumpRequestArgs args = {guid, dump_type, dump_args};
MemoryDumpRequestArgs args = {guid, dump_type, level_of_detail};
delegate->RequestGlobalMemoryDump(args, callback);
}
void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type,
const MemoryDumpArgs& dump_args) {
RequestGlobalDump(dump_type, dump_args, MemoryDumpCallback());
void MemoryDumpManager::RequestGlobalDump(
MemoryDumpType dump_type,
MemoryDumpLevelOfDetail level_of_detail) {
RequestGlobalDump(dump_type, level_of_detail, MemoryDumpCallback());
}
void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
@ -319,8 +320,9 @@ void MemoryDumpManager::ContinueAsyncProcessDump(
bool dump_successful = false;
if (!skip_dump) {
dump_successful = mdp->OnMemoryDump(pmd_async_state->req_args.dump_args,
&pmd_async_state->process_memory_dump);
MemoryDumpArgs args = {pmd_async_state->req_args.level_of_detail};
dump_successful =
mdp->OnMemoryDump(args, &pmd_async_state->process_memory_dump);
}
{
@ -448,7 +450,7 @@ void MemoryDumpManager::OnTraceLogEnabled() {
DCHECK_LE(config_list.size(), 2u);
for (const TraceConfig::MemoryDumpTriggerConfig& config : config_list) {
DCHECK(config.periodic_interval_ms);
if (config.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH)
if (config.level_of_detail == MemoryDumpLevelOfDetail::DETAILED)
heavy_dump_period_ms = config.periodic_interval_ms;
min_timer_period_ms =
std::min(min_timer_period_ms, config.periodic_interval_ms);

@ -67,18 +67,17 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// Requests a memory dump. The dump might happen or not depending on the
// filters and categories specified when enabling tracing.
// The |dump_args| is used to specify the dump's level of detail.
// The optional |callback| is executed asynchronously, on an arbitrary thread,
// to notify about the completion of the global dump (i.e. after all the
// processes have dumped) and its success (true iff all the dumps were
// successful).
void RequestGlobalDump(MemoryDumpType dump_type,
const MemoryDumpArgs& dump_args,
MemoryDumpLevelOfDetail level_of_detail,
const MemoryDumpCallback& callback);
// Same as above (still asynchronous), but without callback.
void RequestGlobalDump(MemoryDumpType dump_type,
const MemoryDumpArgs& dump_args);
MemoryDumpLevelOfDetail level_of_detail);
// TraceLog::EnabledStateObserver implementation.
void OnTraceLogEnabled() override;

@ -27,27 +27,14 @@ using testing::Return;
namespace base {
namespace trace_event {
namespace {
MemoryDumpArgs g_high_detail_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
MemoryDumpArgs g_low_detail_args = {MemoryDumpArgs::LevelOfDetail::LOW};
} // namespace
// GTest matchers for MemoryDumpRequestArgs arguments.
MATCHER(IsHighDetail, "") {
return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH;
MATCHER(IsDetailedDump, "") {
return arg.level_of_detail == MemoryDumpLevelOfDetail::DETAILED;
}
MATCHER(IsLowDetail, "") {
return arg.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW;
}
// GTest matchers for MemoryDumpArgs arguments.
MATCHER(IsHighDetailArgs, "") {
return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::HIGH;
}
MATCHER(IsLowDetailArgs, "") {
return arg.dump_args.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW;
MATCHER(IsLightDump, "") {
return arg.level_of_detail == MemoryDumpLevelOfDetail::LIGHT;
}
// Testing MemoryDumpManagerDelegate which, by default, short-circuits dump
@ -151,7 +138,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(0);
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
// Now repeat enabling the memory category and check that the dumper is
@ -161,7 +148,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true));
for (int i = 0; i < 3; ++i)
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
mdm_->UnregisterDumpProvider(&mdp);
@ -172,7 +159,7 @@ TEST_F(MemoryDumpManagerTest, SingleDumper) {
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
TraceLog::GetInstance()->SetDisabled();
}
@ -185,9 +172,9 @@ TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) {
mdm_->RegisterDumpProvider(&mdp);
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
EXPECT_CALL(mdp, OnMemoryDump(IsHighDetail(), _)).WillOnce(Return(true));
EXPECT_CALL(mdp, OnMemoryDump(IsDetailedDump(), _)).WillOnce(Return(true));
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
mdm_->UnregisterDumpProvider(&mdp);
@ -196,9 +183,9 @@ TEST_F(MemoryDumpManagerTest, CheckMemoryDumpArgs) {
mdm_->RegisterDumpProvider(&mdp);
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
EXPECT_CALL(mdp, OnMemoryDump(IsLowDetail(), _)).WillOnce(Return(true));
EXPECT_CALL(mdp, OnMemoryDump(IsLightDump(), _)).WillOnce(Return(true));
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_low_detail_args);
MemoryDumpLevelOfDetail::LIGHT);
DisableTracing();
mdm_->UnregisterDumpProvider(&mdp);
}
@ -231,7 +218,7 @@ TEST_F(MemoryDumpManagerTest, SharedSessionState) {
for (int i = 0; i < 2; ++i)
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
}
@ -249,7 +236,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).Times(0);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
// Invert: enable mdp1 and disable mdp2.
@ -260,7 +247,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).Times(0);
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
// Enable both mdp1 and mdp2.
@ -270,7 +257,7 @@ TEST_F(MemoryDumpManagerTest, MultipleDumpers) {
EXPECT_CALL(mdp1, OnMemoryDump(_, _)).WillOnce(Return(true));
EXPECT_CALL(mdp2, OnMemoryDump(_, _)).WillOnce(Return(true));
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
}
@ -287,7 +274,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
}
@ -298,7 +285,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
}
@ -310,7 +297,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(0);
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
}
@ -323,7 +310,7 @@ TEST_F(MemoryDumpManagerTest, RegistrationConsistency) {
EXPECT_CALL(mdp, OnMemoryDump(_, _)).WillOnce(Return(true));
EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
DisableTracing();
}
}
@ -370,7 +357,7 @@ TEST_F(MemoryDumpManagerTest, RespectTaskRunnerAffinity) {
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args, callback);
MemoryDumpLevelOfDetail::DETAILED, callback);
// This nested message loop (|run_loop|) will quit if and only if the
// |callback| passed to RequestGlobalDump() is invoked.
run_loop.Run();
@ -425,7 +412,7 @@ TEST_F(MemoryDumpManagerTest, DisableFailingDumpers) {
for (int i = 0; i < kNumDumps; i++) {
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
}
DisableTracing();
@ -461,7 +448,7 @@ TEST_F(MemoryDumpManagerTest, RegisterDumperWhileDumping) {
for (int i = 0; i < 4; i++) {
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
}
DisableTracing();
@ -497,7 +484,7 @@ TEST_F(MemoryDumpManagerTest, UnregisterDumperWhileDumping) {
for (int i = 0; i < 4; i++) {
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args);
MemoryDumpLevelOfDetail::DETAILED);
}
DisableTracing();
@ -550,7 +537,7 @@ TEST_F(MemoryDumpManagerTest, UnregisterDumperFromThreadWhileDumping) {
EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(1);
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args, callback);
MemoryDumpLevelOfDetail::DETAILED, callback);
run_loop.Run();
@ -577,7 +564,7 @@ TEST_F(MemoryDumpManagerTest, CallbackCalledOnFailure) {
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args, callback);
MemoryDumpLevelOfDetail::DETAILED, callback);
run_loop.Run();
}
EXPECT_FALSE(last_callback_success_);
@ -600,7 +587,7 @@ TEST_F(MemoryDumpManagerTest, InitializedAfterStartOfTracing) {
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args, callback);
MemoryDumpLevelOfDetail::DETAILED, callback);
run_loop.Run();
EXPECT_FALSE(last_callback_success_);
}
@ -616,7 +603,7 @@ TEST_F(MemoryDumpManagerTest, InitializedAfterStartOfTracing) {
Bind(&MemoryDumpManagerTest::DumpCallbackAdapter, Unretained(this),
MessageLoop::current()->task_runner(), run_loop.QuitClosure());
mdm_->RequestGlobalDump(MemoryDumpType::EXPLICITLY_TRIGGERED,
g_high_detail_args, callback);
MemoryDumpLevelOfDetail::DETAILED, callback);
run_loop.Run();
EXPECT_TRUE(last_callback_success_);
}
@ -693,13 +680,13 @@ TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) {
const int kHeavyDumpPeriodMs = kHeavyDumpRate * kLightDumpPeriodMs;
// The expected sequence with light=1ms, heavy=5ms is H,L,L,L,L,H,...
testing::InSequence sequence;
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _));
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _))
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _));
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
.Times(kHeavyDumpRate - 1);
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsHighDetailArgs(), _));
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _))
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsDetailedDump(), _));
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
.Times(kHeavyDumpRate - 2);
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLowDetailArgs(), _))
EXPECT_CALL(delegate, RequestGlobalMemoryDump(IsLightDump(), _))
.WillOnce(Invoke([quit_closure](const MemoryDumpRequestArgs& args,
const MemoryDumpCallback& callback) {
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);

@ -7,23 +7,17 @@
#include "base/base_export.h"
#include "base/macros.h"
#include "base/trace_event/memory_dump_request_args.h"
namespace base {
namespace trace_event {
class ProcessMemoryDump;
// Contains information about the type of memory dump the MemoryDumpProvider
// should generate on dump request. This is to control the size of dumps
// generated.
// Args passed to OnMemoryDump(). This is to avoid rewriting all the subclasses
// in the codebase when extending the MemoryDumpProvider API.
struct MemoryDumpArgs {
enum class LevelOfDetail {
LOW,
HIGH,
LAST = HIGH // For IPC Macros.
};
LevelOfDetail level_of_detail;
MemoryDumpLevelOfDetail level_of_detail;
};
// The contract interface that memory dump providers must implement.

@ -10,20 +10,41 @@ namespace base {
namespace trace_event {
// static
const char* MemoryDumpTypeToString(
const MemoryDumpType& dump_type) {
const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type) {
switch (dump_type) {
case MemoryDumpType::TASK_BEGIN:
return "TASK_BEGIN";
return "task_begin";
case MemoryDumpType::TASK_END:
return "TASK_END";
return "task_end";
case MemoryDumpType::PERIODIC_INTERVAL:
return "PERIODIC_INTERVAL";
return "periodic_interval";
case MemoryDumpType::EXPLICITLY_TRIGGERED:
return "EXPLICITLY_TRIGGERED";
return "explicitly_triggered";
}
NOTREACHED();
return "UNKNOWN";
return "unknown";
}
const char* MemoryDumpLevelOfDetailToString(
const MemoryDumpLevelOfDetail& level_of_detail) {
switch (level_of_detail) {
case MemoryDumpLevelOfDetail::LIGHT:
return "light";
case MemoryDumpLevelOfDetail::DETAILED:
return "detailed";
}
NOTREACHED();
return "unknown";
}
MemoryDumpLevelOfDetail StringToMemoryDumpLevelOfDetail(
const std::string& str) {
if (str == "light")
return MemoryDumpLevelOfDetail::LIGHT;
if (str == "detailed")
return MemoryDumpLevelOfDetail::DETAILED;
NOTREACHED();
return MemoryDumpLevelOfDetail::LAST;
}
} // namespace trace_event

@ -8,9 +8,10 @@
// This file defines the types and structs used to issue memory dump requests.
// These are also used in the IPCs for coordinating inter-process memory dumps.
#include <string>
#include "base/base_export.h"
#include "base/callback.h"
#include "base/trace_event/memory_dump_provider.h"
namespace base {
namespace trace_event {
@ -25,11 +26,18 @@ enum class MemoryDumpType {
LAST = EXPLICITLY_TRIGGERED // For IPC macros.
};
// Returns the name in string for the dump type given.
BASE_EXPORT const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type);
using MemoryDumpCallback = Callback<void(uint64 dump_guid, bool success)>;
// Tells the MemoryDumpProvider(s) how much detailed their dumps should be.
// MemoryDumpProvider instances must guarantee that level of detail does not
// affect the total size reported in the root node, but only the granularity of
// the child MemoryAllocatorDump(s).
enum class MemoryDumpLevelOfDetail {
LIGHT, // Few entries, typically a fixed number, per dump.
DETAILED, // Unrestricted amount of entries per dump.
LAST = DETAILED // For IPC Macros.
};
// Initial request arguments for a global memory dump. (see
// MemoryDumpManager::RequestGlobalMemoryDump()).
struct BASE_EXPORT MemoryDumpRequestArgs {
// Globally unique identifier. In multi-process dumps, all processes issue a
// local dump with the same guid. This allows the trace importers to
@ -37,10 +45,19 @@ struct BASE_EXPORT MemoryDumpRequestArgs {
uint64 dump_guid;
MemoryDumpType dump_type;
MemoryDumpArgs dump_args;
MemoryDumpLevelOfDetail level_of_detail;
};
using MemoryDumpCallback = Callback<void(uint64 dump_guid, bool success)>;
BASE_EXPORT const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type);
BASE_EXPORT const char* MemoryDumpLevelOfDetailToString(
const MemoryDumpLevelOfDetail& level_of_detail);
BASE_EXPORT MemoryDumpLevelOfDetail
StringToMemoryDumpLevelOfDetail(const std::string& str);
} // namespace trace_event
} // namespace base

@ -25,12 +25,8 @@ class ConvertableToTraceFormat;
class MemoryDumpManager;
class MemoryDumpSessionState;
// ProcessMemoryDump is as a strongly typed container which enforces the data
// model for each memory dump and holds the dumps produced by the
// MemoryDumpProvider(s) for a specific process.
// At trace generation time (i.e. when AsValue() is called), ProcessMemoryDump
// will compose a key-value dictionary of the various dumps obtained at trace
// dump point time.
// ProcessMemoryDump is as a strongly typed container which holds the dumps
// produced by the MemoryDumpProvider(s) for a specific process.
class BASE_EXPORT ProcessMemoryDump {
public:
struct MemoryAllocatorDumpEdge {

@ -168,7 +168,7 @@ ProcessMemoryMapsDumpProvider::~ProcessMemoryMapsDumpProvider() {
bool ProcessMemoryMapsDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
ProcessMemoryDump* pmd) {
// Snapshot of memory maps is not taken for light dump requests.
if (args.level_of_detail == MemoryDumpArgs::LevelOfDetail::LOW)
if (args.level_of_detail == MemoryDumpLevelOfDetail::LIGHT)
return true;
uint32 res = 0;

@ -110,7 +110,7 @@ TEST(ProcessMemoryMapsDumpProviderTest, ParseProcSmaps) {
const uint32 kProtR = ProcessMemoryMaps::VMRegion::kProtectionFlagsRead;
const uint32 kProtW = ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite;
const uint32 kProtX = ProcessMemoryMaps::VMRegion::kProtectionFlagsExec;
const MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
const MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
auto pmmdp = ProcessMemoryMapsDumpProvider::GetInstance();

@ -12,7 +12,7 @@ namespace base {
namespace trace_event {
TEST(ProcessMemoryTotalsDumpProviderTest, DumpRSS) {
const MemoryDumpArgs high_detail_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
const MemoryDumpArgs high_detail_args = {MemoryDumpLevelOfDetail::DETAILED};
auto pmtdp = ProcessMemoryTotalsDumpProvider::GetInstance();
scoped_ptr<ProcessMemoryDump> pmd_before(new ProcessMemoryDump(nullptr));
scoped_ptr<ProcessMemoryDump> pmd_after(new ProcessMemoryDump(nullptr));

@ -11,6 +11,7 @@
#include "base/strings/string_tokenizer.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/memory_dump_request_args.h"
#include "base/trace_event/trace_event.h"
namespace base {
@ -44,16 +45,14 @@ const char kMemoryDumpConfigParam[] = "memory_dump_config";
const char kTriggersParam[] = "triggers";
const char kPeriodicIntervalParam[] = "periodic_interval_ms";
const char kModeParam[] = "mode";
const char kDetailedParam[] = "detailed";
const char kLightParam[] = "light";
// Default configuration of memory dumps.
const TraceConfig::MemoryDumpTriggerConfig kDefaultHeavyMemoryDumpTrigger = {
2000, // periodic_interval_ms
MemoryDumpArgs::LevelOfDetail::HIGH};
MemoryDumpLevelOfDetail::DETAILED};
const TraceConfig::MemoryDumpTriggerConfig kDefaultLightMemoryDumpTrigger = {
250, // periodic_interval_ms
MemoryDumpArgs::LevelOfDetail::LOW};
MemoryDumpLevelOfDetail::LIGHT};
} // namespace
@ -465,7 +464,6 @@ void TraceConfig::SetMemoryDumpConfig(
continue;
MemoryDumpTriggerConfig dump_config;
std::string dump_type;
int interval = 0;
if (!trigger->GetInteger(kPeriodicIntervalParam, &interval)) {
@ -473,14 +471,10 @@ void TraceConfig::SetMemoryDumpConfig(
}
DCHECK_GT(interval, 0);
dump_config.periodic_interval_ms = static_cast<uint32>(interval);
dump_config.level_of_detail = MemoryDumpArgs::LevelOfDetail::LOW;
if (trigger->GetString(kModeParam, &dump_type)) {
if (dump_type == kDetailedParam) {
dump_config.level_of_detail = MemoryDumpArgs::LevelOfDetail::HIGH;
}
}
std::string level_of_detail_str;
trigger->GetString(kModeParam, &level_of_detail_str);
dump_config.level_of_detail =
StringToMemoryDumpLevelOfDetail(level_of_detail_str);
memory_dump_config_.push_back(dump_config);
}
}
@ -541,17 +535,8 @@ void TraceConfig::ToDict(base::DictionaryValue& dict) const {
new base::DictionaryValue());
trigger_dict->SetInteger(kPeriodicIntervalParam,
static_cast<int>(config.periodic_interval_ms));
switch (config.level_of_detail) {
case MemoryDumpArgs::LevelOfDetail::LOW:
trigger_dict->SetString(kModeParam, kLightParam);
break;
case MemoryDumpArgs::LevelOfDetail::HIGH:
trigger_dict->SetString(kModeParam, kDetailedParam);
break;
default:
NOTREACHED();
}
trigger_dict->SetString(
kModeParam, MemoryDumpLevelOfDetailToString(config.level_of_detail));
triggers_list->Append(trigger_dict.Pass());
}

@ -10,7 +10,7 @@
#include "base/base_export.h"
#include "base/gtest_prod_util.h"
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/memory_dump_request_args.h"
#include "base/values.h"
namespace base {
@ -40,7 +40,7 @@ class BASE_EXPORT TraceConfig {
// "memory-infra" category is enabled.
struct MemoryDumpTriggerConfig {
uint32 periodic_interval_ms;
MemoryDumpArgs::LevelOfDetail level_of_detail;
MemoryDumpLevelOfDetail level_of_detail;
};
typedef std::vector<MemoryDumpTriggerConfig> MemoryDumpConfig;

@ -498,11 +498,11 @@ TEST(TraceConfigTest, TraceConfigFromMemoryConfigString) {
EXPECT_EQ(2u, tc.memory_dump_config_.size());
EXPECT_EQ(200u, tc.memory_dump_config_[0].periodic_interval_ms);
EXPECT_EQ(MemoryDumpArgs::LevelOfDetail::LOW,
EXPECT_EQ(MemoryDumpLevelOfDetail::LIGHT,
tc.memory_dump_config_[0].level_of_detail);
EXPECT_EQ(2000u, tc.memory_dump_config_[1].periodic_interval_ms);
EXPECT_EQ(MemoryDumpArgs::LevelOfDetail::HIGH,
EXPECT_EQ(MemoryDumpLevelOfDetail::DETAILED,
tc.memory_dump_config_[1].level_of_detail);
}

@ -15,7 +15,7 @@ namespace trace_event {
TEST(WinHeapDumpProviderTest, OnMemoryDump) {
ProcessMemoryDump pmd(make_scoped_refptr(new MemoryDumpSessionState()));
MemoryDumpArgs dump_args = {MemoryDumpArgs::LevelOfDetail::HIGH};
MemoryDumpArgs dump_args = {MemoryDumpLevelOfDetail::DETAILED};
WinHeapDumpProvider* winheap_dump_provider =
WinHeapDumpProvider::GetInstance();

@ -29,16 +29,15 @@ IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(base::trace_event::MemoryDumpRequestArgs)
IPC_STRUCT_TRAITS_MEMBER(dump_guid)
IPC_STRUCT_TRAITS_MEMBER(dump_type)
IPC_STRUCT_TRAITS_MEMBER(dump_args)
IPC_STRUCT_TRAITS_MEMBER(level_of_detail)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(base::trace_event::MemoryDumpArgs)
IPC_STRUCT_TRAITS_MEMBER(level_of_detail)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(
base::trace_event::MemoryDumpArgs::LevelOfDetail,
base::trace_event::MemoryDumpArgs::LevelOfDetail::LAST)
IPC_ENUM_TRAITS_MAX_VALUE(base::trace_event::MemoryDumpLevelOfDetail,
base::trace_event::MemoryDumpLevelOfDetail::LAST)
IPC_ENUM_TRAITS_MAX_VALUE(
base::trace_event::MemoryDumpType,

@ -211,10 +211,9 @@ Response TracingHandler::RequestMemoryDump(DevToolsCommandId command_id) {
if (!IsRecording())
return Response::InternalError("Tracing is not started");
base::trace_event::MemoryDumpArgs dump_args = {
base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH};
base::trace_event::MemoryDumpManager::GetInstance()->RequestGlobalDump(
base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, dump_args,
base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED,
base::trace_event::MemoryDumpLevelOfDetail::DETAILED,
base::Bind(&TracingHandler::OnMemoryDumpFinished,
weak_factory_.GetWeakPtr(), command_id));
return Response::OK();

@ -38,9 +38,9 @@ class MockDumpProvider : public base::trace_event::MemoryDumpProvider {
class MemoryTracingTest : public ContentBrowserTest {
public:
void DoRequestGlobalDump(const base::trace_event::MemoryDumpCallback& cb) {
MemoryDumpArgs dump_args = { MemoryDumpArgs::LevelOfDetail::HIGH };
MemoryDumpManager::GetInstance()->RequestGlobalDump(
MemoryDumpType::EXPLICITLY_TRIGGERED, dump_args, cb);
MemoryDumpType::EXPLICITLY_TRIGGERED,
base::trace_event::MemoryDumpLevelOfDetail::DETAILED, cb);
}
// Used as callback argument for MemoryDumpManager::RequestGlobalDump():

@ -23,11 +23,13 @@ bool WebMemoryDumpProviderAdapter::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd) {
blink::WebMemoryDumpLevelOfDetail level;
switch (args.level_of_detail) {
case base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW:
level = blink::WebMemoryDumpLevelOfDetail::Low;
case base::trace_event::MemoryDumpLevelOfDetail::LIGHT:
// TODO(primiano): switch to actual constant once the corresponding
// rename lands in blink and rolls.
level = static_cast<blink::WebMemoryDumpLevelOfDetail>(0);
break;
case base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH:
level = blink::WebMemoryDumpLevelOfDetail::High;
case base::trace_event::MemoryDumpLevelOfDetail::DETAILED:
level = static_cast<blink::WebMemoryDumpLevelOfDetail>(1);
break;
default:
NOTREACHED();

@ -104,8 +104,7 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics(
heap_statistics.total_heap_size() - known_spaces_size);
// If light dump is requested, then object statistics are not dumped
if (args.level_of_detail ==
base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW)
if (args.level_of_detail == base::trace_event::MemoryDumpLevelOfDetail::LIGHT)
return;
// Dump statistics of the heap's live objects from last GC.

@ -24,7 +24,7 @@ TEST_F(V8MemoryDumpProviderTest, DumpStatistics) {
scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
new base::trace_event::ProcessMemoryDump(nullptr));
base::trace_event::MemoryDumpArgs dump_args = {
base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH};
base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
instance_->isolate_memory_dump_provider_for_testing()->OnMemoryDump(
dump_args, process_memory_dump.get());
const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&

@ -13,7 +13,7 @@ TEST(SkiaMemoryDumpProviderTest, OnMemoryDump) {
scoped_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
new base::trace_event::ProcessMemoryDump(nullptr));
base::trace_event::MemoryDumpArgs dump_args = {
base::trace_event::MemoryDumpArgs::LevelOfDetail::HIGH};
base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
SkiaMemoryDumpProvider::GetInstance()->OnMemoryDump(
dump_args, process_memory_dump.get());