Chromium Code Reviews| Index: base/trace_event/memory_dump_manager.cc |
| diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc |
| index f9ba3ae5a134b23dcef8cfcb99a9e24a9e25fb44..924d4bd6ebc69ddab79a6ae4680307fc53f2cc17 100644 |
| --- a/base/trace_event/memory_dump_manager.cc |
| +++ b/base/trace_event/memory_dump_manager.cc |
| @@ -43,7 +43,7 @@ namespace { |
| const char kTraceCategory[] = TRACE_DISABLED_BY_DEFAULT("memory-infra"); |
| // Throttle mmaps at a rate of once every kHeavyMmapsDumpsRate standard dumps. |
| -const int kHeavyMmapsDumpsRate = 8; // 250 ms * 8 = 2000 ms. |
| +const int kHeavyDumpsRate = 8; // 250 ms * 8 = 2000 ms. |
| const int kDumpIntervalMs = 250; |
| const int kTraceEventNumArgs = 1; |
| const char* kTraceEventArgNames[] = {"dumps"}; |
| @@ -55,13 +55,16 @@ MemoryDumpManager* g_instance_for_testing = nullptr; |
| MemoryDumpProvider* g_mmaps_dump_provider = nullptr; |
| void RequestPeriodicGlobalDump() { |
| - MemoryDumpType dump_type = g_periodic_dumps_count == 0 |
| - ? MemoryDumpType::PERIODIC_INTERVAL_WITH_MMAPS |
| - : MemoryDumpType::PERIODIC_INTERVAL; |
| - if (++g_periodic_dumps_count == kHeavyMmapsDumpsRate) |
| + MemoryDumpArgs::LevelOfDetail dump_level_of_detail = |
| + g_periodic_dumps_count == 0 ? MemoryDumpArgs::LEVEL_OF_DETAIL_HIGH |
| + : MemoryDumpArgs::LEVEL_OF_DETAIL_LOW; |
| + if (++g_periodic_dumps_count == kHeavyDumpsRate) |
| g_periodic_dumps_count = 0; |
| - MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type); |
| + MemoryDumpArgs dump_args = {dump_level_of_detail}; |
| + MemoryDumpType dump_type = MemoryDumpType::PERIODIC_INTERVAL; |
|
petrcermak
2015/08/03 16:15:03
nit: No need to declare this variable. You could j
ssid
2015/08/03 16:24:09
Done.
|
| + |
| + MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type, dump_args); |
| } |
| } // namespace |
| @@ -180,9 +183,9 @@ void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) { |
| did_unregister_dump_provider_ = true; |
| } |
| -void MemoryDumpManager::RequestGlobalDump( |
| - MemoryDumpType dump_type, |
| - const MemoryDumpCallback& callback) { |
| +void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type, |
| + const MemoryDumpArgs& dump_args, |
| + 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()) |
| @@ -204,15 +207,16 @@ void MemoryDumpManager::RequestGlobalDump( |
| if (delegate) { |
| // The delegate is in charge to coordinate the request among all the |
| // processes and call the CreateLocalDumpPoint on the local process. |
| - MemoryDumpRequestArgs args = {guid, dump_type}; |
| + MemoryDumpRequestArgs args = {guid, dump_type, dump_args}; |
| delegate->RequestGlobalMemoryDump(args, callback); |
| } else if (!callback.is_null()) { |
| callback.Run(guid, false /* success */); |
| } |
| } |
| -void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type) { |
| - RequestGlobalDump(dump_type, MemoryDumpCallback()); |
| +void MemoryDumpManager::RequestGlobalDump(MemoryDumpType dump_type, |
| + const MemoryDumpArgs& dump_args) { |
| + RequestGlobalDump(dump_type, dump_args, MemoryDumpCallback()); |
| } |
| void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args, |
| @@ -273,15 +277,6 @@ void MemoryDumpManager::ContinueAsyncProcessDump( |
| mdp = mdp_info->dump_provider; |
| if (mdp_info->disabled) { |
| skip_dump = true; |
| - } else if (mdp == g_mmaps_dump_provider && |
| - pmd_async_state->req_args.dump_type != |
| - MemoryDumpType::PERIODIC_INTERVAL_WITH_MMAPS && |
| - pmd_async_state->req_args.dump_type != |
| - MemoryDumpType::EXPLICITLY_TRIGGERED) { |
| - // Mmaps dumping is very heavyweight and cannot be performed at the same |
| - // rate of other dumps. TODO(primiano): this is a hack and should be |
| - // cleaned up as part of crbug.com/499731. |
| - skip_dump = true; |
| } else if (mdp_info->task_runner && |
| !mdp_info->task_runner->BelongsToCurrentThread()) { |
| // It's time to hop onto another thread. |
| @@ -312,13 +307,9 @@ void MemoryDumpManager::ContinueAsyncProcessDump( |
| bool finalize = false; |
| bool dump_successful = false; |
| - // TODO(ssid): Change RequestGlobalDump to use MemoryDumpArgs along with |
| - // MemoryDumpType to get request for light / heavy dump, and remove this |
| - // constant. |
| if (!skip_dump) { |
| - MemoryDumpArgs dump_args = {MemoryDumpArgs::LEVEL_OF_DETAIL_HIGH}; |
| - dump_successful = |
| - mdp->OnMemoryDump(dump_args, &pmd_async_state->process_memory_dump); |
| + dump_successful = mdp->OnMemoryDump(pmd_async_state->req_args.dump_args, |
| + &pmd_async_state->process_memory_dump); |
| } |
| { |