| Index: content/child/web_memory_dump_provider_adapter.cc
|
| diff --git a/content/child/web_memory_dump_provider_adapter.cc b/content/child/web_memory_dump_provider_adapter.cc
|
| index 860424c0f3725d0440520b779b2218e8adb3c6fe..051f155fd98162695d6bbd7890139f435f47d5d2 100644
|
| --- a/content/child/web_memory_dump_provider_adapter.cc
|
| +++ b/content/child/web_memory_dump_provider_adapter.cc
|
| @@ -6,49 +6,10 @@
|
|
|
| #include <stddef.h>
|
|
|
| -#include "base/containers/hash_tables.h"
|
| -#include "base/lazy_instance.h"
|
| -#include "base/synchronization/lock.h"
|
| -#include "base/trace_event/heap_profiler_allocation_context.h"
|
| -#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
|
| -#include "base/trace_event/heap_profiler_allocation_register.h"
|
| -#include "base/trace_event/heap_profiler_heap_dump_writer.h"
|
| -#include "base/trace_event/process_memory_dump.h"
|
| #include "base/trace_event/trace_event_argument.h"
|
| -#include "base/trace_event/trace_event_memory_overhead.h"
|
| #include "content/child/web_process_memory_dump_impl.h"
|
| #include "third_party/WebKit/public/platform/WebMemoryDumpProvider.h"
|
|
|
| -using namespace base;
|
| -using namespace base::trace_event;
|
| -
|
| -namespace {
|
| -
|
| -// TODO(ruuda): Move these into the dump providers once Blink can depend on
|
| -// base. See https://crbug.com/548254.
|
| -AllocationRegister* g_allocation_register = nullptr;
|
| -LazyInstance<Lock>::Leaky g_allocation_register_lock =
|
| - LAZY_INSTANCE_INITIALIZER;
|
| -bool g_heap_profiling_enabled = false;
|
| -
|
| -void ReportAllocation(void* address, size_t size, const char* type_name) {
|
| - AllocationContext context = AllocationContextTracker::GetContextSnapshot();
|
| - context.type_name = type_name;
|
| - AutoLock lock(g_allocation_register_lock.Get());
|
| -
|
| - if (g_allocation_register)
|
| - g_allocation_register->Insert(address, size, context);
|
| -}
|
| -
|
| -void ReportFree(void* address) {
|
| - AutoLock lock(g_allocation_register_lock.Get());
|
| -
|
| - if (g_allocation_register)
|
| - g_allocation_register->Remove(address);
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| namespace content {
|
|
|
| WebMemoryDumpProviderAdapter::WebMemoryDumpProviderAdapter(
|
| @@ -76,56 +37,13 @@ bool WebMemoryDumpProviderAdapter::OnMemoryDump(
|
| return false;
|
| }
|
| WebProcessMemoryDumpImpl web_pmd_impl(args.level_of_detail, pmd);
|
| -
|
| - if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED &&
|
| - web_memory_dump_provider_->supportsHeapProfiling() &&
|
| - g_heap_profiling_enabled) {
|
| - TraceEventMemoryOverhead overhead;
|
| - hash_map<AllocationContext, size_t> bytes_by_context;
|
| - {
|
| - AutoLock lock(g_allocation_register_lock.Get());
|
| - for (const auto& alloc_size : *g_allocation_register)
|
| - bytes_by_context[alloc_size.context] += alloc_size.size;
|
| -
|
| - g_allocation_register->EstimateTraceMemoryOverhead(&overhead);
|
| - }
|
| -
|
| - scoped_refptr<TracedValue> heap_dump = ExportHeapDump(
|
| - bytes_by_context, pmd->session_state()->stack_frame_deduplicator(),
|
| - pmd->session_state()->type_name_deduplicator());
|
| - pmd->AddHeapDump("partition_alloc", heap_dump);
|
| - overhead.DumpInto("tracing/heap_profiler", pmd);
|
| - }
|
| -
|
| return web_memory_dump_provider_->onMemoryDump(level, &web_pmd_impl);
|
| }
|
|
|
| void WebMemoryDumpProviderAdapter::OnHeapProfilingEnabled(bool enabled) {
|
| if (!web_memory_dump_provider_->supportsHeapProfiling())
|
| return;
|
| -
|
| - if (enabled) {
|
| - {
|
| - AutoLock lock(g_allocation_register_lock.Get());
|
| - if (!g_allocation_register)
|
| - g_allocation_register = new AllocationRegister();
|
| - }
|
| -
|
| - // Make this dump provider call the global hooks on every allocation / free.
|
| - // TODO(ruuda): Because bookkeeping is done here in the adapter, and not in
|
| - // the dump providers themselves, all dump providers in Blink share the
|
| - // same global allocation register. At the moment this is not a problem,
|
| - // because the only dump provider that supports heap profiling is the
|
| - // PartitionAlloc dump provider. When Blink can depend on base and this
|
| - // glue layer is removed, dump providers can have their own instance of the
|
| - // allocation register. Tracking bug: https://crbug.com/548254.
|
| - web_memory_dump_provider_->onHeapProfilingEnabled(ReportAllocation,
|
| - ReportFree);
|
| - } else {
|
| - web_memory_dump_provider_->onHeapProfilingEnabled(nullptr, nullptr);
|
| - }
|
| -
|
| - g_heap_profiling_enabled = enabled;
|
| + web_memory_dump_provider_->onHeapProfilingEnabled(enabled);
|
| }
|
|
|
| } // namespace content
|
|
|