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

Unified Diff: base/debug/trace_event_system.h

Issue 15418002: Record Chrome trace events in tcmalloc heap profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add system stats tracing to Chrome Created 7 years, 5 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/debug/trace_event_impl.cc ('k') | base/debug/trace_event_system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_system.h
diff --git a/base/debug/trace_event_system.h b/base/debug/trace_event_system.h
new file mode 100644
index 0000000000000000000000000000000000000000..59711ea843f319c9867118db5f2f28654ce6341e
--- /dev/null
+++ b/base/debug/trace_event_system.h
@@ -0,0 +1,70 @@
+// Copyright 2013 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_DEBUG_TRACE_EVENT_SYSTEM_H_
+#define BASE_DEBUG_TRACE_EVENT_SYSTEM_H_
+
+#include "base/base_export.h"
+#include "base/debug/trace_event_impl.h"
+#include "base/gtest_prod_util.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/process/process_metrics.h"
+#include "base/timer/timer.h"
+
+namespace base {
+
+class MessageLoopProxy;
+
+namespace debug {
+
+// Watches for chrome://tracing to be enabled or disabled. When tracing is
+// enabled, also enables system events profiling. This class is the preferred
+// way to turn system tracing on and off.
+class BASE_EXPORT TraceSystemController
+ : public TraceLog::EnabledStateObserver {
+ public:
+ // |message_loop_proxy| must be a proxy to the primary thread for the client
+ // process, e.g. the UI thread in a browser.
+ explicit TraceSystemController(
+ scoped_refptr<MessageLoopProxy> message_loop_proxy);
+ virtual ~TraceSystemController();
+
+ // base::debug::TraceLog::EnabledStateChangedObserver overrides:
+ virtual void OnTraceLogEnabled() OVERRIDE;
+ virtual void OnTraceLogDisabled() OVERRIDE;
+
+ // Starts system profiling.
+ void StartProfiling();
+
+ // Ends system profiling.
+ void StopProfiling();
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(TraceSystemTest, TraceSystemController);
+
+ bool IsTimerRunningForTest() const;
+
+ // Ensures the observer starts and stops tracing on the primary thread.
+ scoped_refptr<MessageLoopProxy> message_loop_proxy_;
+
+ // Timer to schedule system profile dumps.
+ RepeatingTimer<TraceSystemController> dump_timer_;
+
+ WeakPtrFactory<TraceSystemController> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(TraceSystemController);
+};
+
+#ifdef OS_LINUX
+// Converts system memory profiling stats in |input| to
+// trace event compatible JSON and appends to |output|. Visible for testing.
+BASE_EXPORT void AppendSystemProfileAsTraceFormat(SystemMemoryInfoKB *meminfo,
+ std::string* output);
+#endif
+
+} // namespace debug
+} // namespace base
+
+#endif // BASE_DEBUG_TRACE_EVENT_SYSTEM_H_
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/debug/trace_event_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698