Index: base/debug/trace_event.cc |
diff --git a/base/debug/trace_event.cc b/base/debug/trace_event.cc |
index d467055be9646f6aea8216eaf80f89a0b68a48e4..d765f5195bd747eced80ad0de4578fd50698ec29 100644 |
--- a/base/debug/trace_event.cc |
+++ b/base/debug/trace_event.cc |
@@ -104,6 +104,8 @@ const char* GetPhaseStr(TraceEventPhase phase) { |
return "I"; |
case TRACE_EVENT_PHASE_END: |
return "E"; |
+ case TRACE_EVENT_PHASE_METADATA: |
+ return "M"; |
default: |
NOTREACHED() << "Invalid phase argument"; |
return "?"; |
@@ -295,8 +297,10 @@ void TraceLog::SetEnabled(bool enabled) { |
g_categories[i].enabled = enabled; |
} |
} // release lock |
- if (!enabled) |
+ if (!enabled) { |
+ AddCurrentMetadataEvents(); |
Flush(); |
+ } |
} |
float TraceLog::GetBufferPercentFull() const { |
@@ -419,6 +423,33 @@ void TraceLog::AddTraceEventEtw(TraceEventPhase phase, |
} |
} |
+void TraceLog::SetCurrentThreadName(const char* name) { |
+ AutoLock lock(lock_); |
+ thread_names_[PlatformThread::CurrentId()] = name; |
+} |
+ |
+void TraceLog::AddCurrentMetadataEvents() { |
+ const TraceCategory* metadata_category = GetCategoryInternal("__metadata"); |
joth
2011/07/26 09:53:17
static const?
|
+#ifdef USE_UNRELIABLE_NOW |
+ TimeTicks now = TimeTicks::HighResNow(); |
jbates
2011/07/26 20:57:00
can we replace the timestamp with 0 for metadata e
|
+#else |
+ TimeTicks now = TimeTicks::Now(); |
+#endif |
+ for(base::hash_map<PlatformThreadId, std::string>::iterator it = |
+ thread_names_.begin(); |
+ it != thread_names_.end(); |
+ it++) { |
+ logged_events_.push_back( |
+ TraceEvent(static_cast<unsigned long>(base::GetCurrentProcId()), |
+ it->first, |
+ now, base::debug::TRACE_EVENT_PHASE_METADATA, |
+ metadata_category, "thread_name", |
+ "name", it->second.c_str(), |
+ NULL, 0, |
+ true)); |
joth
2011/07/26 09:53:17
you can pass false here. (The only thing that need
|
+ } |
+} |
+ |
void TraceLog::Resurrect() { |
StaticMemorySingletonTraits<TraceLog>::Resurrect(); |
} |