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

Side by Side Diff: components/tracing/process_metrics_memory_dump_provider.h

Issue 1617263002: Revert of [tracing] Dump child processes' memory metrics in browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: Created 4 years, 11 months 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 #ifndef COMPONENTS_TRACING_PROCESS_MEMORY_METRICS_DUMP_PROVIDER_H_
6 #define COMPONENTS_TRACING_PROCESS_MEMORY_METRICS_DUMP_PROVIDER_H_
7
8 #include "base/gtest_prod_util.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/process/process_handle.h"
12 #include "base/trace_event/memory_dump_provider.h"
13 #include "build/build_config.h"
14 #include "components/tracing/tracing_export.h"
15
16 namespace base {
17 class ProcessMetrics;
18 }
19
20 namespace tracing {
21
22 // Dump provider which collects process-wide memory stats.
23 class TRACING_EXPORT ProcessMetricsMemoryDumpProvider
24 : public base::trace_event::MemoryDumpProvider {
25 public:
26 // Pass base::kNullProcessId to register for current process.
27 static void RegisterForProcess(base::ProcessId process);
28 static void UnregisterForProcess(base::ProcessId process);
29
30 ~ProcessMetricsMemoryDumpProvider() override;
31
32 // MemoryDumpProvider implementation.
33 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
34 base::trace_event::ProcessMemoryDump* pmd) override;
35
36 private:
37 FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest,
38 ParseProcSmaps);
39 FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest, DumpRSS);
40
41 ProcessMetricsMemoryDumpProvider(base::ProcessId process);
42
43 bool DumpProcessTotals(const base::trace_event::MemoryDumpArgs& args,
44 base::trace_event::ProcessMemoryDump* pmd);
45 bool DumpProcessMemoryMaps(const base::trace_event::MemoryDumpArgs& args,
46 base::trace_event::ProcessMemoryDump* pmd);
47
48 static uint64_t rss_bytes_for_testing;
49
50 #if defined(OS_LINUX) || defined(OS_ANDROID)
51 static FILE* proc_smaps_for_testing;
52 #endif
53
54 base::ProcessId process_;
55 scoped_ptr<base::ProcessMetrics> process_metrics_;
56
57 // The peak may not be resettable on all the processes if the linux kernel is
58 // older than http://bit.ly/reset_rss or only on child processes if yama LSM
59 // sandbox is enabled.
60 bool is_rss_peak_resettable_;
61
62 DISALLOW_COPY_AND_ASSIGN(ProcessMetricsMemoryDumpProvider);
63 };
64
65 } // namespace tracing
66
67 #endif // COMPONENTS_TRACING_PROCESS_MEMORY_METRICS_DUMP_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698