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

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..2bb04061ea63fd993d328f279fd89e57eb9e6afc 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)
+ {
+ previousState0_ = TraceEventSamplingState0Scope::current();
+ TraceEventSamplingState0Scope::forceCurrent(category_and_name);
+ }
+
+ ~TraceEventSamplingState0Scope()
+ {
+ TraceEventSamplingState0Scope::forceCurrent(previousState0_);
+ }
+
+ static inline const char* current()
scottmg 2013/07/03 02:16:10 In chromium code, these should be Current()
haraken 2013/07/03 02:38:50 Done.
+ {
+ return reinterpret_cast<const char*>(TRACE_EVENT_API_ATOMIC_LOAD(
+ TRACE_EVENT_API_THREAD_BUCKET(0)));
+ }
+
+ static inline void forceCurrent(const char* category_and_name)
scottmg 2013/07/03 02:16:10 and ForceCurrent. Maybe just "Set" would be fine t
haraken 2013/07/03 02:38:50 Done.
+ {
+ 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* previousState0_;
scottmg 2013/07/03 02:16:10 and previous_state0_
haraken 2013/07/03 02:38:50 Done.
+};
#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