| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/compiler_specific.h" |
| 9 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 11 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 13 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // An implementation of MessageLoopProxy to be used in conjunction | 179 // An implementation of MessageLoopProxy to be used in conjunction |
| 179 // with BrowserThread. | 180 // with BrowserThread. |
| 180 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { | 181 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { |
| 181 public: | 182 public: |
| 182 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) | 183 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) |
| 183 : id_(identifier) { | 184 : id_(identifier) { |
| 184 } | 185 } |
| 185 | 186 |
| 186 // MessageLoopProxy implementation. | 187 // MessageLoopProxy implementation. |
| 187 virtual bool PostTask(const tracked_objects::Location& from_here, | 188 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 188 const base::Closure& task) { | 189 const base::Closure& task) OVERRIDE { |
| 189 return BrowserThread::PostTask(id_, from_here, task); | 190 return BrowserThread::PostTask(id_, from_here, task); |
| 190 } | 191 } |
| 191 | 192 |
| 192 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 193 virtual bool PostDelayedTask( |
| 193 const base::Closure& task, int64 delay_ms) { | 194 const tracked_objects::Location& from_here, |
| 195 const base::Closure& task, int64 delay_ms) OVERRIDE{ |
| 194 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); | 196 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); |
| 195 } | 197 } |
| 196 | 198 |
| 197 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, | 199 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, |
| 198 const base::Closure& task) { | 200 const base::Closure& task) OVERRIDE { |
| 199 return BrowserThread::PostNonNestableTask(id_, from_here, task); | 201 return BrowserThread::PostNonNestableTask(id_, from_here, task); |
| 200 } | 202 } |
| 201 | 203 |
| 202 virtual bool PostNonNestableDelayedTask( | 204 virtual bool PostNonNestableDelayedTask( |
| 203 const tracked_objects::Location& from_here, | 205 const tracked_objects::Location& from_here, |
| 204 const base::Closure& task, | 206 const base::Closure& task, |
| 205 int64 delay_ms) { | 207 int64 delay_ms) OVERRIDE { |
| 206 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | 208 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, |
| 207 delay_ms); | 209 delay_ms); |
| 208 } | 210 } |
| 209 | 211 |
| 210 virtual bool BelongsToCurrentThread() { | 212 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { |
| 211 return BrowserThread::CurrentlyOn(id_); | 213 return BrowserThread::CurrentlyOn(id_); |
| 212 } | 214 } |
| 213 | 215 |
| 214 private: | 216 private: |
| 215 BrowserThread::ID id_; | 217 BrowserThread::ID id_; |
| 216 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); | 218 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); |
| 217 }; | 219 }; |
| 218 | 220 |
| 219 // static | 221 // static |
| 220 bool BrowserThread::PostBlockingPoolTask( | 222 bool BrowserThread::PostBlockingPoolTask( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 364 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 363 &globals.thread_delegates[identifier]); | 365 &globals.thread_delegates[identifier]); |
| 364 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 366 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 365 storage, reinterpret_cast<AtomicWord>(delegate)); | 367 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 366 | 368 |
| 367 // This catches registration when previously registered. | 369 // This catches registration when previously registered. |
| 368 DCHECK(!delegate || !old_pointer); | 370 DCHECK(!delegate || !old_pointer); |
| 369 } | 371 } |
| 370 | 372 |
| 371 } // namespace content | 373 } // namespace content |
| OLD | NEW |