| Index: content/browser/browser_thread_impl.cc
|
| diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc
|
| index 4b85b616cac113a76d6efae2fa73259e5f64ea60..45ceda398d60d6700edb6bab6e7e0fc1aa9af3e7 100644
|
| --- a/content/browser/browser_thread_impl.cc
|
| +++ b/content/browser/browser_thread_impl.cc
|
| @@ -31,19 +31,44 @@ namespace content {
|
|
|
| base::Lock BrowserThreadImpl::lock_;
|
|
|
| -BrowserThread* BrowserThreadImpl::browser_threads_[ID_COUNT];
|
| +BrowserThreadImpl* BrowserThreadImpl::browser_threads_[ID_COUNT];
|
|
|
| -BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier)
|
| - : BrowserThread(identifier) {
|
| +BrowserThreadImpl::BrowserThreadImpl(ID identifier)
|
| + : Thread(browser_thread_names[identifier]),
|
| + identifier_(identifier) {
|
| + Initialize();
|
| }
|
|
|
| -BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier,
|
| +BrowserThreadImpl::BrowserThreadImpl(ID identifier,
|
| MessageLoop* message_loop)
|
| - : BrowserThread(identifier, message_loop) {
|
| + : Thread(message_loop->thread_name().c_str()),
|
| + identifier_(identifier) {
|
| + set_message_loop(message_loop);
|
| + Initialize();
|
| +}
|
| +
|
| +void BrowserThreadImpl::Initialize() {
|
| + base::AutoLock lock(lock_);
|
| + DCHECK(identifier_ >= 0 && identifier_ < ID_COUNT);
|
| + DCHECK(browser_threads_[identifier_] == NULL);
|
| + browser_threads_[identifier_] = this;
|
| }
|
|
|
| BrowserThreadImpl::~BrowserThreadImpl() {
|
| + // All Thread subclasses must call Stop() in the destructor. This is
|
| + // doubly important here as various bits of code check they are on
|
| + // the right BrowserThread.
|
| Stop();
|
| +
|
| + base::AutoLock lock(lock_);
|
| + browser_threads_[identifier_] = NULL;
|
| +#ifndef NDEBUG
|
| + // Double check that the threads are ordered correctly in the enumeration.
|
| + for (int i = identifier_ + 1; i < ID_COUNT; ++i) {
|
| + DCHECK(!browser_threads_[i]) <<
|
| + "Threads must be listed in the reverse order that they die";
|
| + }
|
| +#endif
|
| }
|
|
|
| // static
|
| @@ -125,18 +150,6 @@ bool BrowserThreadImpl::PostTaskHelper(
|
| return !!message_loop;
|
| }
|
|
|
| -// TODO(joi): Remove
|
| -DeprecatedBrowserThread::DeprecatedBrowserThread(BrowserThread::ID identifier)
|
| - : BrowserThread(identifier) {
|
| -}
|
| -DeprecatedBrowserThread::DeprecatedBrowserThread(BrowserThread::ID identifier,
|
| - MessageLoop* message_loop)
|
| - : BrowserThread(identifier, message_loop) {
|
| -}
|
| -DeprecatedBrowserThread::~DeprecatedBrowserThread() {
|
| - Stop();
|
| -}
|
| -
|
| // An implementation of MessageLoopProxy to be used in conjunction
|
| // with BrowserThread.
|
| class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy {
|
| @@ -201,44 +214,6 @@ class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy {
|
| DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy);
|
| };
|
|
|
| -BrowserThread::BrowserThread(ID identifier)
|
| - : Thread(browser_thread_names[identifier]),
|
| - identifier_(identifier) {
|
| - Initialize();
|
| -}
|
| -
|
| -BrowserThread::BrowserThread(ID identifier,
|
| - MessageLoop* message_loop)
|
| - : Thread(message_loop->thread_name().c_str()),
|
| - identifier_(identifier) {
|
| - set_message_loop(message_loop);
|
| - Initialize();
|
| -}
|
| -
|
| -void BrowserThread::Initialize() {
|
| - base::AutoLock lock(BrowserThreadImpl::lock_);
|
| - DCHECK(identifier_ >= 0 && identifier_ < ID_COUNT);
|
| - DCHECK(BrowserThreadImpl::browser_threads_[identifier_] == NULL);
|
| - BrowserThreadImpl::browser_threads_[identifier_] = this;
|
| -}
|
| -
|
| -BrowserThread::~BrowserThread() {
|
| - // Stop the thread here, instead of the parent's class destructor. This is so
|
| - // that if there are pending tasks that run, code that checks that it's on the
|
| - // correct BrowserThread succeeds.
|
| - Stop();
|
| -
|
| - base::AutoLock lock(BrowserThreadImpl::lock_);
|
| - BrowserThreadImpl::browser_threads_[identifier_] = NULL;
|
| -#ifndef NDEBUG
|
| - // Double check that the threads are ordered correctly in the enumeration.
|
| - for (int i = identifier_ + 1; i < ID_COUNT; ++i) {
|
| - DCHECK(!BrowserThreadImpl::browser_threads_[i]) <<
|
| - "Threads must be listed in the reverse order that they die";
|
| - }
|
| -#endif
|
| -}
|
| -
|
| // static
|
| bool BrowserThread::IsWellKnownThread(ID identifier) {
|
| base::AutoLock lock(BrowserThreadImpl::lock_);
|
| @@ -380,4 +355,11 @@ BrowserThread::GetMessageLoopProxyForThread(
|
| return proxy;
|
| }
|
|
|
| +base::Thread* BrowserThread::UnsafeGetBrowserThread(ID identifier) {
|
| + base::AutoLock lock(BrowserThreadImpl::lock_);
|
| + base::Thread* thread = BrowserThreadImpl::browser_threads_[identifier];
|
| + DCHECK(thread);
|
| + return thread;
|
| +}
|
| +
|
| } // namespace content
|
|
|