| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // An implementation of MessageLoopProxy to be used in conjunction | 178 // An implementation of MessageLoopProxy to be used in conjunction |
| 178 // with BrowserThread. | 179 // with BrowserThread. |
| 179 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { | 180 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { |
| 180 public: | 181 public: |
| 181 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) | 182 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) |
| 182 : id_(identifier) { | 183 : id_(identifier) { |
| 183 } | 184 } |
| 184 | 185 |
| 185 // MessageLoopProxy implementation. | 186 // MessageLoopProxy implementation. |
| 186 virtual bool PostTask(const tracked_objects::Location& from_here, | 187 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 187 const base::Closure& task) { | 188 const base::Closure& task) OVERRIDE { |
| 188 return BrowserThread::PostTask(id_, from_here, task); | 189 return BrowserThread::PostTask(id_, from_here, task); |
| 189 } | 190 } |
| 190 | 191 |
| 191 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 192 virtual bool PostDelayedTask( |
| 192 const base::Closure& task, int64 delay_ms) { | 193 const tracked_objects::Location& from_here, |
| 194 const base::Closure& task, int64 delay_ms) OVERRIDE{ |
| 193 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); | 195 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); |
| 194 } | 196 } |
| 195 | 197 |
| 196 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, | 198 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, |
| 197 const base::Closure& task) { | 199 const base::Closure& task) OVERRIDE { |
| 198 return BrowserThread::PostNonNestableTask(id_, from_here, task); | 200 return BrowserThread::PostNonNestableTask(id_, from_here, task); |
| 199 } | 201 } |
| 200 | 202 |
| 201 virtual bool PostNonNestableDelayedTask( | 203 virtual bool PostNonNestableDelayedTask( |
| 202 const tracked_objects::Location& from_here, | 204 const tracked_objects::Location& from_here, |
| 203 const base::Closure& task, | 205 const base::Closure& task, |
| 204 int64 delay_ms) { | 206 int64 delay_ms) OVERRIDE { |
| 205 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | 207 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, |
| 206 delay_ms); | 208 delay_ms); |
| 207 } | 209 } |
| 208 | 210 |
| 209 virtual bool BelongsToCurrentThread() { | 211 virtual bool BelongsToCurrentThread() const OVERRIDE { |
| 210 return BrowserThread::CurrentlyOn(id_); | 212 return BrowserThread::CurrentlyOn(id_); |
| 211 } | 213 } |
| 212 | 214 |
| 213 private: | 215 private: |
| 214 BrowserThread::ID id_; | 216 BrowserThread::ID id_; |
| 215 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); | 217 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); |
| 216 }; | 218 }; |
| 217 | 219 |
| 218 // static | 220 // static |
| 219 bool BrowserThread::PostBlockingPoolTask( | 221 bool BrowserThread::PostBlockingPoolTask( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 363 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 362 &globals.thread_delegates[identifier]); | 364 &globals.thread_delegates[identifier]); |
| 363 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 365 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 364 storage, reinterpret_cast<AtomicWord>(delegate)); | 366 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 365 | 367 |
| 366 // This catches registration when previously registered. | 368 // This catches registration when previously registered. |
| 367 DCHECK(!delegate || !old_pointer); | 369 DCHECK(!delegate || !old_pointer); |
| 368 } | 370 } |
| 369 | 371 |
| 370 } // namespace content | 372 } // namespace content |
| OLD | NEW |