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

Unified Diff: base/trace_event/memory_tracing_observer.h

Issue 2820433005: memory-infra: Start disentangling tracing from memory-infra (Closed)
Patch Set: add todo Created 3 years, 8 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
« no previous file with comments | « base/trace_event/memory_dump_manager_unittest.cc ('k') | base/trace_event/memory_tracing_observer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_tracing_observer.h
diff --git a/base/trace_event/memory_tracing_observer.h b/base/trace_event/memory_tracing_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..1efea18c4d552509fa5d2c59c0015f165a287a28
--- /dev/null
+++ b/base/trace_event/memory_tracing_observer.h
@@ -0,0 +1,45 @@
+// Copyright 2017 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_MEMORY_TRACING_OBSERVER_H_
+#define BASE_TRACE_EVENT_MEMORY_TRACING_OBSERVER_H_
+
+#include "base/macros.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/trace_event.h"
+
+namespace base {
+
+namespace trace_event {
+
+// Observes TraceLog for Enable/Disable events and when they occur Enables and
+// Disables the MemoryDumpManager with the correct state based on reading the
+// trace log. Also provides a method for adding a dump to the trace.
+class BASE_EXPORT MemoryTracingObserver
+ : public TraceLog::EnabledStateObserver {
+ public:
+ static const char* const kTraceCategory;
+
+ MemoryTracingObserver(TraceLog*, MemoryDumpManager*);
+ ~MemoryTracingObserver() override;
+
+ // TraceLog::EnabledStateObserver implementation.
+ void OnTraceLogEnabled() override;
+ void OnTraceLogDisabled() override;
+
+ bool AddDumpToTraceIfEnabled(const MemoryDumpRequestArgs*,
+ const ProcessId,
+ const ProcessMemoryDump*);
+
+ private:
+ MemoryDumpManager* const memory_dump_manager_;
+ TraceLog* const trace_log_;
+
+ DISALLOW_COPY_AND_ASSIGN(MemoryTracingObserver);
+};
+
+} // namespace trace_event
+} // namespace base
+
+#endif // BASE_TRACE_EVENT_MEMORY_TRACING_OBSERVER_H_
« no previous file with comments | « base/trace_event/memory_dump_manager_unittest.cc ('k') | base/trace_event/memory_tracing_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698