Index: base/message_loop.cc |
diff --git a/base/message_loop.cc b/base/message_loop.cc |
index e3f6ea3440251bfcb43901ed4a32826381aa5171..75ecd85bd0760640a27a1109a0edb796d1a91c30 100644 |
--- a/base/message_loop.cc |
+++ b/base/message_loop.cc |
@@ -15,6 +15,7 @@ |
#include "base/message_pump_default.h" |
#include "base/metrics/histogram.h" |
#include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
+#include "base/threading/platform_thread.h" |
#include "base/threading/thread_local.h" |
#include "base/time.h" |
#include "base/tracked_objects.h" |
@@ -122,10 +123,11 @@ MessageLoop::DestructionObserver::~DestructionObserver() { |
//------------------------------------------------------------------------------ |
-MessageLoop::MessageLoop(Type type) |
+MessageLoop::MessageLoop(Type type, const char* thread_name) |
: type_(type), |
nestable_tasks_allowed_(true), |
exception_restoration_(false), |
+ thread_name_(thread_name ? thread_name : ""), |
message_histogram_(NULL), |
state_(NULL), |
should_leak_tasks_(true), |
@@ -166,6 +168,10 @@ MessageLoop::MessageLoop(Type type) |
DCHECK_EQ(TYPE_DEFAULT, type_); |
pump_ = new base::MessagePumpDefault(); |
} |
+ if (!thread_name_.empty()) |
+ base::PlatformThread::SetName(thread_name_.c_str()); |
+ // Tell the name to race detector. |
+ ANNOTATE_THREAD_NAME(thread_name_.c_str()); |
} |
MessageLoop::~MessageLoop() { |