Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: components/tracing/process_metrics_memory_dump_manager.cc

Issue 1417003003: [tracing] Dump child processes' memory metrics in browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: dNits. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698