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

Unified Diff: base/message_loop/message_loop.cc

Issue 1942053002: Deletes base::MessageLoop::set_thread_name(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adds memory barrier Created 4 years, 7 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
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop.cc
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 7038178079fc1619eec2366fc521c335f4fcadab..016ac1901fa678f1652b8caf8c900ac45f35a524 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"
@@ -395,7 +396,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());
}
@@ -413,9 +415,15 @@ void MessageLoop::BindToCurrentThread() {
incoming_task_queue_->StartScheduling();
unbound_task_runner_->BindToCurrentThread();
unbound_task_runner_ = nullptr;
+ subtle::Release_Store(&thread_id_, PlatformThread::CurrentId());
SetThreadTaskRunnerHandle();
}
+std::string MessageLoop::GetThreadName() const {
+ return ThreadIdNameManager::GetInstance()->GetName(
+ subtle::Release_Load(&thread_id_));
gab 2016/06/03 15:31:17 I don't think you need to use an Atomic32. Instead
alokp 2016/06/03 16:34:56 Used subtle::MemoryBarrier() in the new patch. I d
gab 2016/06/07 00:30:59 I think it's reasonable to document in the header
alokp 2016/06/10 22:12:59 Done.
+}
+
void MessageLoop::SetTaskRunner(
scoped_refptr<SingleThreadTaskRunner> task_runner) {
DCHECK_EQ(this, current());
@@ -554,13 +562,12 @@ 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_,
- kLeastNonZeroMessageId, kMaxMessageId,
+ "MsgLoop:" + thread_name, kLeastNonZeroMessageId, kMaxMessageId,
kNumberOfDistinctMessagesDisplayed,
- HistogramBase::kHexRangePrintingFlag,
- event_descriptions_);
+ HistogramBase::kHexRangePrintingFlag, event_descriptions_);
}
#endif
}
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698