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

Unified Diff: components/tracing/process_metrics_memory_dump_provider.h

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: primiano's comments Created 4 years, 12 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 side-by-side diff with in-line comments
Download patch
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..6152ccc4e836558a2495d97d0fe066a4387a6acd
--- /dev/null
+++ b/components/tracing/process_metrics_memory_dump_provider.h
@@ -0,0 +1,61 @@
+// 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_
Primiano Tucci (use gerrit) 2016/01/05 11:55:17 This include guard needs to be adjusted to match t
ssid 2016/01/06 20:26:33 Done.
+#define BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_DUMP_PROVIDER_H_
+
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+#include "base/process/process_handle.h"
+#include "base/trace_event/memory_dump_provider.h"
+#include "build/build_config.h"
+#include "components/tracing/tracing_export.h"
+
+namespace base {
+class ProcessMetrics;
+}
+
+namespace tracing {
+
+// Dump provider which collects process-wide memory stats.
+class TRACING_EXPORT ProcessMetricsMemoryDumpProvider
+ : public base::trace_event::MemoryDumpProvider {
+ public:
+ // Pass base::kNullProcessHandle to register for current process.
+ static void RegisterForProcess(base::ProcessHandle process);
+ static void UnregisterForProcess(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);
+
+ ProcessMetricsMemoryDumpProvider(base::ProcessHandle process);
+
+ bool DumpProcessTotals(const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd);
+ bool DumpProcessMemoryMaps(const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd);
+
+ static uint64_t 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_
Primiano Tucci (use gerrit) 2016/01/05 11:55:17 ditto

Powered by Google App Engine
This is Rietveld 408576698