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

Unified Diff: base/threading/platform_thread_win.cc

Issue 7495031: trace_event support for thread names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks to pass all trybots. Created 9 years, 4 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
Index: base/threading/platform_thread_win.cc
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index 56d73811c0fc5fd63e0f6d76a606306d4ad4669b..e2d90d8eccce67674247cecdfd8b9dac7224844c 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -5,13 +5,17 @@
#include "base/threading/platform_thread.h"
#include "base/logging.h"
+#include "base/threading/thread_local.h"
#include "base/threading/thread_restrictions.h"
+
#include "base/win/windows_version.h"
namespace base {
namespace {
+static ThreadLocalPointer<char> current_thread_name;
+
// The information on how to set the thread name comes from
// a MSDN article: http://msdn2.microsoft.com/en-us/library/xcb2z8hs.aspx
const DWORD kVCThreadNameException = 0x406D1388;
@@ -94,6 +98,8 @@ void PlatformThread::Sleep(int duration_ms) {
// static
void PlatformThread::SetName(const char* name) {
+ current_thread_name.Set(const_cast<char*>(name));
+
// The debugger needs to be around to catch the name in the exception. If
// there isn't a debugger, we are just needlessly throwing an exception.
if (!::IsDebuggerPresent())
@@ -113,6 +119,11 @@ void PlatformThread::SetName(const char* name) {
}
// static
+const char* PlatformThread::GetName() {
+ return current_thread_name.Get();
+}
+
+// static
bool PlatformThread::Create(size_t stack_size, Delegate* delegate,
PlatformThreadHandle* thread_handle) {
DCHECK(thread_handle);
« base/threading/platform_thread_mac.mm ('K') | « base/threading/platform_thread_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698