Index: components/tracing/process_metrics_memory_dump_provider.h |
diff --git a/components/tracing/process_metrics_memory_dump_provider.h b/components/tracing/process_metrics_memory_dump_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a3d91b17bd75109773520411e82c88a1f03e3939 |
--- /dev/null |
+++ b/components/tracing/process_metrics_memory_dump_provider.h |
@@ -0,0 +1,54 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_ |
+#define BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_ |
+ |
+#include "base/gtest_prod_util.h" |
+#include "base/macros.h" |
+#include "base/trace_event/memory_dump_provider.h" |
+ |
+namespace base { |
+class ProcessMetrics; |
+} |
+ |
+namespace tracing { |
+ |
+// Dump provider which collects process-wide memory stats. |
+class BASE_EXPORT ProcessMetricsMemoryDumpProvider |
+ : public base::trace_event::MemoryDumpProvider { |
+ public: |
+ // Pass base::kNullProcessHandle for current process. |
+ ProcessMetricsMemoryDumpProvider(base::ProcessHandle process); |
+ ~ProcessMetricsMemoryDumpProvider() override; |
+ |
+ // MemoryDumpProvider implementation. |
+ bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
+ base::trace_event::ProcessMemoryDump* pmd) override; |
+ |
+ private: |
+ FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest, |
+ ParseProcSmaps); |
+ FRIEND_TEST_ALL_PREFIXES(ProcessMetricsMemoryDumpProviderTest, DumpRSS); |
+ |
+ void DumpProcessTotals(const base::trace_event::MemoryDumpArgs& args, |
+ base::trace_event::ProcessMemoryDump* pmd); |
+ void DumpProcessMemoryMaps(const base::trace_event::MemoryDumpArgs& args, |
+ base::trace_event::ProcessMemoryDump* pmd); |
+ |
+ static uint64 rss_bytes_for_testing; |
+ |
+#if defined(OS_LINUX) || defined(OS_ANDROID) |
+ static FILE* proc_smaps_for_testing; |
+#endif |
+ |
+ base::ProcessHandle process_; |
+ scoped_ptr<base::ProcessMetrics> process_metrics_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ProcessMetricsMemoryDumpProvider); |
+}; |
+ |
+} // namespace tracing |
+ |
+#endif // BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_ |