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

Unified Diff: base/debug/trace_event.h

Issue 18587004: Add a sampling tracing to RenderWidget::DoDeferredUpdate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « no previous file | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event.h
diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h
index aa4cc759b79eeabca051ff795c07455cf56eb3c2..367044040282a62777e031d858e4d8d0df9de74d 100644
--- a/base/debug/trace_event.h
+++ b/base/debug/trace_event.h
@@ -299,9 +299,16 @@
// want the inconsistency/expense of storing two pointers.
// |thread_bucket| is [0..2] and is used to statically isolate samples in one
// thread from others.
-#define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \
- TRACE_EVENT_API_ATOMIC_STORE( \
- TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \
+#define TRACE_EVENT_SAMPLING_STATE0(category, name) \
+ INTERNAL_TRACE_EVENT_SAMPLING_STATE(0, category, name)
+#define TRACE_EVENT_SAMPLING_STATE1(category, name) \
+ INTERNAL_TRACE_EVENT_SAMPLING_STATE(1, category, name)
+#define TRACE_EVENT_SAMPLING_STATE2(category, name) \
+ INTERNAL_TRACE_EVENT_SAMPLING_STATE(2, category, name)
+
+#define INTERNAL_TRACE_EVENT_SAMPLING_STATE(thread_bucket, category, name) \
+ TRACE_EVENT_API_ATOMIC_STORE( \
+ TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \
reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category "\0" name));
// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
@@ -763,6 +770,40 @@ TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state1;
TRACE_EVENT_API_CLASS_EXPORT extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state2;
#define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \
g_trace_state##thread_bucket
+
+// TraceEventSamplingState0Scope records the current sampling state
+// and sets a new sampling state. When the scope exists, it restores
+// the sampling state having recorded.
+class TraceEventSamplingState0Scope {
+public:
+ TraceEventSamplingState0Scope(const char* category_and_name)
scottmg 2013/07/03 02:40:45 sorry, i missed the other formatting, should be tw
haraken 2013/07/03 02:46:04 Done.
+ {
+ previous_state0_ = TraceEventSamplingState0Scope::Current();
+ TraceEventSamplingState0Scope::Set(category_and_name);
+ }
+
+ ~TraceEventSamplingState0Scope()
+ {
+ TraceEventSamplingState0Scope::Set(previous_state0_);
+ }
+
+ static inline const char* Current()
+ {
+ return reinterpret_cast<const char*>(TRACE_EVENT_API_ATOMIC_LOAD(
+ TRACE_EVENT_API_THREAD_BUCKET(0)));
+ }
+
+ static inline void Set(const char* category_and_name)
+ {
+ TRACE_EVENT_API_ATOMIC_STORE(
+ TRACE_EVENT_API_THREAD_BUCKET(0),
+ reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(
+ const_cast<char*>(category_and_name)));
+ }
+
+private:
+ const char* previous_state0_;
+};
#endif
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « no previous file | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698