Chromium Code Reviews| 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 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_ | |
| 6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/gtest_prod_util.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/process/process_handle.h" | |
| 11 #include "base/trace_event/memory_dump_provider.h" | |
| 12 #include "build/build_config.h" | |
| 13 #include "components/tracing/tracing_export.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class ProcessMetrics; | |
| 17 } | |
| 18 | |
| 19 namespace tracing { | |
| 20 | |
| 21 // Dump provider which collects process-wide memory stats. | |
| 22 class TRACING_EXPORT ProcessMetricsMemoryDumpProvider | |
| 23 : public base::trace_event::MemoryDumpProvider { | |
| 24 public: | |
| 25 // Pass base::kNullProcessHandle to register for current process. | |
| 26 static void RegisterForProcess(base::ProcessHandle process); | |
|
Primiano Tucci (use gerrit)
2015/12/14 10:52:21
What is the rationale for passing ProcessHandle w.
ssid
2016/01/04 20:54:38
Hm the CreateProcessMetrics takes ProcessHandle an
| |
| 27 static void UnregisterForProcess(base::ProcessHandle process); | |
| 28 | |
| 29 ~ProcessMetricsMemoryDumpProvider() override; | |
| 30 | |
| 31 // MemoryDumpProvider implementation. | |
| 32 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | |
| 33 base::trace_event::ProcessMemoryDump* pmd) override; | |
| 34 | |
| 35 private: | |
| 36 FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest, | |
| 37 ParseProcSmaps); | |
| 38 FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest, DumpRSS); | |
| 39 | |
| 40 ProcessMetricsMemoryDumpProvider(base::ProcessHandle process); | |
| 41 | |
| 42 void DumpProcessTotals(const base::trace_event::MemoryDumpArgs& args, | |
| 43 base::trace_event::ProcessMemoryDump* pmd); | |
| 44 void DumpProcessMemoryMaps(const base::trace_event::MemoryDumpArgs& args, | |
| 45 base::trace_event::ProcessMemoryDump* pmd); | |
| 46 | |
| 47 static uint64 rss_bytes_for_testing; | |
| 48 | |
| 49 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
| 50 static FILE* proc_smaps_for_testing; | |
| 51 #endif | |
| 52 | |
| 53 base::ProcessHandle process_; | |
| 54 scoped_ptr<base::ProcessMetrics> process_metrics_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(ProcessMetricsMemoryDumpProvider); | |
| 57 }; | |
| 58 | |
| 59 } // namespace tracing | |
| 60 | |
| 61 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_ | |
| OLD | NEW |