summaryrefslogtreecommitdiffstats
path: root/base/debug
diff options
context:
space:
mode:
authordsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 20:41:19 +0000
committerdsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 20:41:19 +0000
commit7d342e882772e35c4e60e640f3501a84fd0a5bec (patch)
treecb86e79488437edcd41452488555cace9a628ca4 /base/debug
parent02fd1dc91b2a4741356ed3a9694fcf977f6beda6 (diff)
downloadchromium_src-7d342e882772e35c4e60e640f3501a84fd0a5bec.zip
chromium_src-7d342e882772e35c4e60e640f3501a84fd0a5bec.tar.gz
chromium_src-7d342e882772e35c4e60e640f3501a84fd0a5bec.tar.bz2
Add ability to retrieve a thread_name given a thread_id.
The work to add GPU tracing needs the ability to map from a thread_id back to a thread_name in order to allow us to have the correct display on the chrome://tracing page. We want to be able to output our traces without having to post to a thread to handle the output, and to have the GPU traces differentiated from the GPU-process which will be doing the tracing calls. BUG=111509 TEST=Added tests in base_unittests Review URL: https://chromiumcodereview.appspot.com/11438022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178886 0039d316-1c4b-4281-b951-d872f2087c98
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_;