| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/browser_thread_impl.h" | 5 #include "content/browser/browser_thread_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier) | 36 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier) |
| 37 : BrowserThread(identifier) { | 37 : BrowserThread(identifier) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier, | 40 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier, |
| 41 MessageLoop* message_loop) | 41 MessageLoop* message_loop) |
| 42 : BrowserThread(identifier, message_loop) { | 42 : BrowserThread(identifier, message_loop) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 BrowserThreadImpl::~BrowserThreadImpl() { | 45 BrowserThreadImpl::~BrowserThreadImpl() { |
| 46 // Subclasses of base::Thread() (or at least the most-derived | |
| 47 // subclass) must call Stop() in their destructor, otherwise the | |
| 48 // vtable for the object can change while the thread's message loop | |
| 49 // is still running, and it uses the object's vtable (it calls the | |
| 50 // virtual method Run). | |
| 51 Stop(); | 46 Stop(); |
| 52 } | 47 } |
| 53 | 48 |
| 54 // static | 49 // static |
| 55 bool BrowserThreadImpl::PostTaskHelper( | 50 bool BrowserThreadImpl::PostTaskHelper( |
| 56 BrowserThread::ID identifier, | 51 BrowserThread::ID identifier, |
| 57 const tracked_objects::Location& from_here, | 52 const tracked_objects::Location& from_here, |
| 58 Task* task, | 53 Task* task, |
| 59 int64 delay_ms, | 54 int64 delay_ms, |
| 60 bool nestable) { | 55 bool nestable) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 127 |
| 133 // TODO(joi): Remove | 128 // TODO(joi): Remove |
| 134 DeprecatedBrowserThread::DeprecatedBrowserThread(BrowserThread::ID identifier) | 129 DeprecatedBrowserThread::DeprecatedBrowserThread(BrowserThread::ID identifier) |
| 135 : BrowserThread(identifier) { | 130 : BrowserThread(identifier) { |
| 136 } | 131 } |
| 137 DeprecatedBrowserThread::DeprecatedBrowserThread(BrowserThread::ID identifier, | 132 DeprecatedBrowserThread::DeprecatedBrowserThread(BrowserThread::ID identifier, |
| 138 MessageLoop* message_loop) | 133 MessageLoop* message_loop) |
| 139 : BrowserThread(identifier, message_loop) { | 134 : BrowserThread(identifier, message_loop) { |
| 140 } | 135 } |
| 141 DeprecatedBrowserThread::~DeprecatedBrowserThread() { | 136 DeprecatedBrowserThread::~DeprecatedBrowserThread() { |
| 137 Stop(); |
| 142 } | 138 } |
| 143 | 139 |
| 144 // An implementation of MessageLoopProxy to be used in conjunction | 140 // An implementation of MessageLoopProxy to be used in conjunction |
| 145 // with BrowserThread. | 141 // with BrowserThread. |
| 146 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { | 142 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { |
| 147 public: | 143 public: |
| 148 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) | 144 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) |
| 149 : id_(identifier) { | 145 : id_(identifier) { |
| 150 } | 146 } |
| 151 | 147 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // static | 374 // static |
| 379 scoped_refptr<base::MessageLoopProxy> | 375 scoped_refptr<base::MessageLoopProxy> |
| 380 BrowserThread::GetMessageLoopProxyForThread( | 376 BrowserThread::GetMessageLoopProxyForThread( |
| 381 ID identifier) { | 377 ID identifier) { |
| 382 scoped_refptr<base::MessageLoopProxy> proxy( | 378 scoped_refptr<base::MessageLoopProxy> proxy( |
| 383 new BrowserThreadMessageLoopProxy(identifier)); | 379 new BrowserThreadMessageLoopProxy(identifier)); |
| 384 return proxy; | 380 return proxy; |
| 385 } | 381 } |
| 386 | 382 |
| 387 } // namespace content | 383 } // namespace content |
| OLD | NEW |