summaryrefslogtreecommitdiffstats
path: root/base/debug
diff options
context:
space:
mode:
Diffstat (limited to 'base/debug')
-rw-r--r--base/debug/trace_event_impl.cc4
-rw-r--r--base/debug/trace_event_unittest.cc9
2 files changed, 9 insertions, 4 deletions
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index e85db1d..411da1d 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -65,7 +65,9 @@ const int g_category_categories_exhausted = 1;
const int g_category_metadata = 2;
int g_category_index = 3; // skip initial 3 categories
-// The most-recently captured name of the current thread
+// The name of the current thread. This is used to decide if the current
+// thread name has changed. We combine all the seen thread names into the
+// output name for the thread.
LazyInstance<ThreadLocalPointer<const char> >::Leaky
g_current_thread_name = LAZY_INSTANCE_INITIALIZER;
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index cf16fa5..c42cc5d 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -79,15 +79,18 @@ class TraceEventTestFixture : public testing::Test {
}
virtual void SetUp() OVERRIDE {
- old_thread_name_ = PlatformThread::GetName();
+ const char* name = PlatformThread::GetName();
+ old_thread_name_ = name ? strdup(name) : NULL;
}
virtual void TearDown() OVERRIDE {
if (TraceLog::GetInstance())
EXPECT_FALSE(TraceLog::GetInstance()->IsEnabled());
- PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : "");
+ PlatformThread::SetName(old_thread_name_ ? old_thread_name_ : "");
+ free(old_thread_name_);
+ old_thread_name_ = NULL;
}
- const char* old_thread_name_;
+ char* old_thread_name_;
ListValue trace_parsed_;
base::debug::TraceResultBuffer trace_buffer_;
base::debug::TraceResultBuffer::SimpleOutput json_output_;