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

Unified Diff: content/browser/browser_thread_impl.cc

Issue 1942053002: Deletes base::MessageLoop::set_thread_name(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed media_unittests 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
Index: content/browser/browser_thread_impl.cc
diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc
index 90b581882fb7bfb0fc35c332215e1a677b364f6b..1a1e37a72ce952cf269405e796b13cf2d60f9545 100644
--- a/content/browser/browser_thread_impl.cc
+++ b/content/browser/browser_thread_impl.cc
@@ -40,6 +40,14 @@ static const char* const g_browser_thread_names[BrowserThread::ID_COUNT] = {
"Chrome_IOThread", // IO
};
+static const char* GetThreadName(BrowserThread::ID thread) {
+ if (BrowserThread::UI < thread && thread < BrowserThread::ID_COUNT)
+ return g_browser_thread_names[thread];
+ if (thread == BrowserThread::UI)
+ return "Chrome_UIThread";
+ return "Unknown Thread";
+}
+
// An implementation of SingleThreadTaskRunner to be used in conjunction
// with BrowserThread.
class BrowserThreadTaskRunner : public base::SingleThreadTaskRunner {
@@ -65,6 +73,10 @@ class BrowserThreadTaskRunner : public base::SingleThreadTaskRunner {
return BrowserThread::CurrentlyOn(id_);
}
+ std::string GetThreadName() const override {
+ return content::GetThreadName(id_);
gab 2016/05/12 15:50:57 content:: is redundant here
+ }
+
protected:
~BrowserThreadTaskRunner() override {}
@@ -120,14 +132,13 @@ base::LazyInstance<BrowserThreadGlobals>::Leaky
} // namespace
BrowserThreadImpl::BrowserThreadImpl(ID identifier)
- : Thread(g_browser_thread_names[identifier]),
- identifier_(identifier) {
+ : Thread(GetThreadName(identifier)), identifier_(identifier) {
Initialize();
}
BrowserThreadImpl::BrowserThreadImpl(ID identifier,
base::MessageLoop* message_loop)
- : Thread(message_loop->thread_name()), identifier_(identifier) {
+ : Thread(GetThreadName(identifier)), identifier_(identifier) {
set_message_loop(message_loop);
Initialize();
}
@@ -417,21 +428,13 @@ bool BrowserThread::CurrentlyOn(ID identifier) {
base::MessageLoop::current();
}
-static const char* GetThreadName(BrowserThread::ID thread) {
- if (BrowserThread::UI < thread && thread < BrowserThread::ID_COUNT)
- return g_browser_thread_names[thread];
- if (thread == BrowserThread::UI)
- return "Chrome_UIThread";
- return "Unknown Thread";
-}
-
// static
std::string BrowserThread::GetDCheckCurrentlyOnErrorMessage(ID expected) {
- const base::MessageLoop* message_loop = base::MessageLoop::current();
+ base::MessageLoop* message_loop = base::MessageLoop::current();
ID actual_browser_thread;
- const char* actual_name = "Unknown Thread";
- if (message_loop && !message_loop->thread_name().empty()) {
- actual_name = message_loop->thread_name().c_str();
+ std::string actual_name("Unknown Thread");
gab 2016/05/12 15:50:57 435-440 can all be replaced by: std::string actua
+ if (message_loop) {
+ actual_name = message_loop->task_runner()->GetThreadName();
} else if (GetCurrentThreadIdentifier(&actual_browser_thread)) {
actual_name = GetThreadName(actual_browser_thread);
}

Powered by Google App Engine
This is Rietveld 408576698