| 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..669a29387f4bfbcdd506b08f00d961f4eb92bbfa 100644
|
| --- a/content/browser/browser_thread_impl.cc
|
| +++ b/content/browser/browser_thread_impl.cc
|
| @@ -15,6 +15,7 @@
|
| #include "base/macros.h"
|
| #include "base/profiler/scoped_tracker.h"
|
| #include "base/single_thread_task_runner.h"
|
| +#include "base/threading/platform_thread.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "build/build_config.h"
|
| #include "content/public/browser/browser_thread_delegate.h"
|
| @@ -40,6 +41,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 {
|
| @@ -120,14 +129,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,24 +425,12 @@ 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();
|
| - 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();
|
| - } else if (GetCurrentThreadIdentifier(&actual_browser_thread)) {
|
| - actual_name = GetThreadName(actual_browser_thread);
|
| - }
|
| + std::string actual_name = base::PlatformThread::GetName();
|
| + if (actual_name.empty())
|
| + actual_name = "Unknown Thread";
|
| +
|
| std::string result = "Must be called on ";
|
| result += GetThreadName(expected);
|
| result += "; actually called on ";
|
|
|