OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/tracing/process_metrics_memory_dump_manager.h" | |
6 | |
7 #include "base/trace_event/memory_dump_manager.h" | |
8 #include "base/trace_event/memory_dump_provider.h" | |
9 #include "components/tracing/process_metrics_memory_dump_provider.h" | |
10 | |
11 namespace tracing { | |
12 | |
13 // static | |
14 ProcessMetricsMemoryDumpManager* | |
15 ProcessMetricsMemoryDumpManager::GetInstance() { | |
16 return base::Singleton< | |
17 ProcessMetricsMemoryDumpManager, | |
18 base::LeakySingletonTraits<ProcessMetricsMemoryDumpManager>>::get(); | |
19 } | |
20 | |
21 void ProcessMetricsMemoryDumpManager::RegisterForProcess( | |
22 base::ProcessHandle process) { | |
23 #if !defined(OS_LINUX) | |
24 // Register dump provider for child processes only on linux. | |
25 if (process != base::kNullProcessHandle) | |
Primiano Tucci (use gerrit)
2015/11/17 10:44:12
not sure I understand this.
This is saying: on Non
ssid
2015/11/17 11:13:07
If I do not add this here then I would have to cha
ssid
2015/11/17 13:55:06
Done.
| |
26 return; | |
27 #endif | |
28 #if !defined(OS_NACL) | |
29 scoped_ptr<ProcessMetricsMemoryDumpProvider> metrics_provider( | |
30 new ProcessMetricsMemoryDumpProvider(process)); | |
31 base::trace_event::MemoryDumpProvider::Options options(process); | |
32 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | |
33 metrics_provider.get(), "ProcessMemoryMetrics", nullptr, options); | |
34 process_metrics_providers_map_.insert(process, metrics_provider.Pass()); | |
35 #endif | |
36 } | |
37 | |
38 void ProcessMetricsMemoryDumpManager::UnregisterForProcess( | |
39 base::ProcessHandle process) { | |
40 #if !defined(OS_NACL) | |
41 scoped_ptr<ProcessMetricsMemoryDumpProvider> provider = | |
42 process_metrics_providers_map_.take_and_erase(process); | |
43 DCHECK(provider); | |
44 base::trace_event::MemoryDumpManager::GetInstance() | |
45 ->UnregisterAndDeleteDumpProviderAsync(provider.Pass()); | |
46 #endif // defined(OS_LINUX) | |
47 } | |
48 | |
49 ProcessMetricsMemoryDumpManager::ProcessMetricsMemoryDumpManager() {} | |
50 ProcessMetricsMemoryDumpManager::~ProcessMetricsMemoryDumpManager() {} | |
51 | |
52 } // namespace tracing | |
OLD | NEW |