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

Unified Diff: base/message_loop.cc

Issue 7529003: Make base::MessageLoops have names at construction time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make message loop name optional. Created 9 years, 5 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.h ('k') | base/threading/thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « base/message_loop.h ('k') | base/threading/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698