Index: base/message_loop/message_loop.cc |
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc |
index 93b9d0a2ec44bcc64567d197996faad652a242ff..f22eb9845a1a37bf51b3b163567474d35c314f9d 100644 |
--- a/base/message_loop/message_loop.cc |
+++ b/base/message_loop/message_loop.cc |
@@ -418,21 +418,13 @@ void MessageLoop::BindToCurrentThread() { |
unbound_task_runner_->BindToCurrentThread(); |
unbound_task_runner_ = nullptr; |
SetThreadTaskRunnerHandle(); |
- { |
- // Save the current thread's ID for potential use by other threads |
- // later from GetThreadName(). |
- thread_id_ = PlatformThread::CurrentId(); |
- subtle::MemoryBarrier(); |
- } |
+ thread_id_ = PlatformThread::CurrentId(); |
} |
std::string MessageLoop::GetThreadName() const { |
- if (thread_id_ == kInvalidThreadId) { |
- // |thread_id_| may already have been initialized but this thread might not |
- // have received the update yet. |
- subtle::MemoryBarrier(); |
- DCHECK_NE(kInvalidThreadId, thread_id_); |
- } |
+ DCHECK_NE(kInvalidThreadId, thread_id_) |
+ << "GetThreadName() must only be called after BindToCurrentThread()'s " |
+ << "side-effects have been synchronized with this thread."; |
return ThreadIdNameManager::GetInstance()->GetName(thread_id_); |
} |