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

Unified Diff: base/trace_event/memory_tracing_observer.h

Issue 2820433005: memory-infra: Start disentangling tracing from memory-infra (Closed)
Patch Set: update for comments 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
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..fe996b60fbd52ef493a32e241932acf9ca008a7a
--- /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;
+ bool AddDumpToTraceIfEnabled(const MemoryDumpRequestArgs*,
Primiano Tucci (use gerrit) 2017/04/21 13:14:17 nit: now that is not a static move this down, ctor
hjd 2017/04/21 13:42:32 Done.
+ const ProcessId,
+ const ProcessMemoryDump*);
+
+ MemoryTracingObserver(TraceLog*, MemoryDumpManager*);
+ ~MemoryTracingObserver() override;
+
+ // TraceLog::EnabledStateObserver implementation.
+ void OnTraceLogEnabled() override;
+ void OnTraceLogDisabled() override;
+
+ private:
+ bool enabled_;
+ 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_

Powered by Google App Engine
This is Rietveld 408576698