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/trace_event/memory_dump_provider.h" |
| 11 |
| 12 namespace base { |
| 13 class ProcessMetrics; |
| 14 } |
| 15 |
| 16 namespace tracing { |
| 17 |
| 18 // Dump provider which collects process-wide memory stats. |
| 19 class BASE_EXPORT ProcessMetricsMemoryDumpProvider |
| 20 : public base::trace_event::MemoryDumpProvider { |
| 21 public: |
| 22 // Pass base::kNullProcessHandle for current process. |
| 23 ProcessMetricsMemoryDumpProvider(base::ProcessHandle process); |
| 24 ~ProcessMetricsMemoryDumpProvider() override; |
| 25 |
| 26 // MemoryDumpProvider implementation. |
| 27 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 28 base::trace_event::ProcessMemoryDump* pmd) override; |
| 29 |
| 30 private: |
| 31 FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest, |
| 32 ParseProcSmaps); |
| 33 FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest, DumpRSS); |
| 34 |
| 35 void DumpProcessTotals(const base::trace_event::MemoryDumpArgs& args, |
| 36 base::trace_event::ProcessMemoryDump* pmd); |
| 37 void DumpProcessMemoryMaps(const base::trace_event::MemoryDumpArgs& args, |
| 38 base::trace_event::ProcessMemoryDump* pmd); |
| 39 |
| 40 static uint64 rss_bytes_for_testing; |
| 41 |
| 42 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 43 static FILE* proc_smaps_for_testing; |
| 44 #endif |
| 45 |
| 46 base::ProcessHandle process_; |
| 47 scoped_ptr<base::ProcessMetrics> process_metrics_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(ProcessMetricsMemoryDumpProvider); |
| 50 }; |
| 51 |
| 52 } // namespace tracing |
| 53 |
| 54 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_ |
OLD | NEW |