Index: base/message_loop/message_loop.cc |
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc |
index 3fef91be460dc26bd81028d8e8a5d20477833091..abac00f156595a37cf2d76f8ecdf952c3f9ab17d 100644 |
--- a/base/message_loop/message_loop.cc |
+++ b/base/message_loop/message_loop.cc |
@@ -18,6 +18,7 @@ |
#include "base/metrics/statistics_recorder.h" |
#include "base/run_loop.h" |
#include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
+#include "base/threading/thread_id_name_manager.h" |
#include "base/threading/thread_local.h" |
#include "base/threading/thread_task_runner_handle.h" |
#include "base/time/time.h" |
@@ -398,7 +399,8 @@ MessageLoop::MessageLoop(Type type, MessagePumpFactoryCallback pump_factory) |
incoming_task_queue_(new internal::IncomingTaskQueue(this)), |
unbound_task_runner_( |
new internal::MessageLoopTaskRunner(incoming_task_queue_)), |
- task_runner_(unbound_task_runner_) { |
+ task_runner_(unbound_task_runner_), |
+ thread_id_(kInvalidThreadId) { |
// If type is TYPE_CUSTOM non-null pump_factory must be given. |
DCHECK(type_ != TYPE_CUSTOM || !pump_factory_.is_null()); |
} |
@@ -416,9 +418,14 @@ void MessageLoop::BindToCurrentThread() { |
incoming_task_queue_->StartScheduling(); |
unbound_task_runner_->BindToCurrentThread(); |
unbound_task_runner_ = nullptr; |
+ thread_id_ = PlatformThread::CurrentId(); |
gab
2016/05/20 20:25:39
This needs to be synchronized as it's set outside
alokp
2016/06/01 19:23:18
Done. Can you please check the barrier usage and m
|
SetThreadTaskRunnerHandle(); |
} |
+std::string MessageLoop::GetThreadName() const { |
+ return ThreadIdNameManager::GetInstance()->GetName(thread_id_); |
+} |
+ |
void MessageLoop::SetTaskRunner( |
scoped_refptr<SingleThreadTaskRunner> task_runner) { |
DCHECK_EQ(this, current()); |
@@ -557,9 +564,10 @@ void MessageLoop::StartHistogrammer() { |
#if !defined(OS_NACL) // NaCl build has no metrics code. |
if (enable_histogrammer_ && !message_histogram_ |
&& StatisticsRecorder::IsActive()) { |
- DCHECK(!thread_name_.empty()); |
+ std::string thread_name = GetThreadName(); |
+ DCHECK(!thread_name.empty()); |
message_histogram_ = LinearHistogram::FactoryGetWithRangeDescription( |
- "MsgLoop:" + thread_name_, |
+ "MsgLoop:" + thread_name, |
kLeastNonZeroMessageId, kMaxMessageId, |
kNumberOfDistinctMessagesDisplayed, |
HistogramBase::kHexRangePrintingFlag, |