Chromium Code Reviews| Index: content/browser/tracing/background_memory_tracing_observer.cc |
| diff --git a/content/browser/tracing/background_memory_tracing_observer.cc b/content/browser/tracing/background_memory_tracing_observer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c4e4a13eca6b59b09dcbf9837523a6ca6f20abcd |
| --- /dev/null |
| +++ b/content/browser/tracing/background_memory_tracing_observer.cc |
| @@ -0,0 +1,35 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/tracing/background_memory_tracing_observer.h" |
| + |
| +#include "base/trace_event/memory_dump_manager.h" |
| + |
| +namespace content { |
| + |
| +// static |
| +BackgroundMemoryTracingObserver* |
| +BackgroundMemoryTracingObserver::GetInstance() { |
| + static auto* instance = new BackgroundMemoryTracingObserver; |
|
oystein (OOO til 10th of July)
2017/03/28 20:11:18
Why isn't this a global base::LazyInstance? I don'
ssid
2017/03/28 21:02:03
I think thread safe statics are the new way to use
oystein (OOO til 10th of July)
2017/03/28 21:06:47
Ah good to know, missed that. Thanks!
|
| + return instance; |
| +} |
| + |
| +BackgroundMemoryTracingObserver::BackgroundMemoryTracingObserver() {} |
| +BackgroundMemoryTracingObserver::~BackgroundMemoryTracingObserver() {} |
| + |
| +void BackgroundMemoryTracingObserver::OnScenarioActivated( |
| + const BackgroundTracingConfigImpl& config) {} |
| + |
| +void BackgroundMemoryTracingObserver::OnTracingEnabled( |
| + BackgroundTracingConfigImpl::CategoryPreset preset) { |
| + if (preset == |
| + BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_MEMORY_LIGHT) { |
| + auto* dump_manager = base::trace_event::MemoryDumpManager::GetInstance(); |
| + dump_manager->RequestGlobalDump( |
| + base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, |
| + base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND); |
| + } |
| +} |
| + |
| +} // namespace content |