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

Unified Diff: base/trace_event/memory_tracing_observer.h

Issue 2820433005: memory-infra: Start disentangling tracing from memory-infra (Closed)
Patch Set: pass config in 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..65135ecb5b6da90c547151b92dd3c031f5c4287d
--- /dev/null
+++ b/base/trace_event/memory_tracing_observer.h
@@ -0,0 +1,42 @@
+// 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/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 sets the correct state in
+// MemoryDumpManager to handle XXX.
Primiano Tucci (use gerrit) 2017/04/21 10:10:27 xxx? :)
hjd 2017/04/21 11:51:58 Done.
+class BASE_EXPORT MemoryTracingObserver
+ : public TraceLog::EnabledStateObserver {
+ public:
+ static const char* const kTraceCategory;
+ static void MaybeAddDumpToTrace(const MemoryDumpRequestArgs*,
Primiano Tucci (use gerrit) 2017/04/21 10:10:27 plz make this non-static. It's always weird to see
hjd 2017/04/21 11:51:58 Done.
+ const ProcessId,
+ const ProcessMemoryDump*);
+
+ MemoryTracingObserver(TraceLog*, MemoryDumpManager*);
Primiano Tucci (use gerrit) 2017/04/21 10:10:27 since we don't have any testing need, I'd just use
hjd 2017/04/21 11:51:58 It seems to me that using the singletons directly
Primiano Tucci (use gerrit) 2017/04/21 13:14:16 I might be overlooking some future plan, but is th
+ ~MemoryTracingObserver() override;
+
+ // TraceLog::EnabledStateObserver implementation.
+ void OnTraceLogEnabled() override;
+ void OnTraceLogDisabled() override;
+
+ private:
+ static bool IsMemoryInfraTracingEnabled();
Primiano Tucci (use gerrit) 2017/04/21 10:10:27 I think this can be just a method in the anonymous
hjd 2017/04/21 11:51:58 Done.
+ bool enabled_;
Primiano Tucci (use gerrit) 2017/04/21 10:10:27 nit: add a blank line between functions and var de
hjd 2017/04/21 11:51:58 Done.
+ MemoryDumpManager* memory_dump_manager_;
Primiano Tucci (use gerrit) 2017/04/21 10:10:27 make both const variables (not pointers), as they
hjd 2017/04/21 11:51:58 See comment above,
+ TraceLog* trace_log_;
+};
Primiano Tucci (use gerrit) 2017/04/21 10:10:27 DISALLOW_COPY_AND_ASSIGN ( +include base/macros.h)
hjd 2017/04/21 11:51:58 Done.
+
+} // namespace trace_event
+} // namespace base
+
+#endif // BASE_TRACE_EVENT_MEMORY_TRACING_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698