| 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 | 178 |
| 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 PostDelayedTask( |
| 188 const base::Closure& task) { | 189 const tracked_objects::Location& from_here, |
| 189 return BrowserThread::PostTask(id_, from_here, task); | 190 const base::Closure& task, int64 delay_ms) OVERRIDE{ |
| 190 } | |
| 191 | |
| 192 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | |
| 193 const base::Closure& task, int64 delay_ms) { | |
| 194 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); | 191 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); |
| 195 } | 192 } |
| 196 | 193 |
| 197 virtual bool PostNonNestableTask(const tracked_objects::Location& from_here, | |
| 198 const base::Closure& task) { | |
| 199 return BrowserThread::PostNonNestableTask(id_, from_here, task); | |
| 200 } | |
| 201 | |
| 202 virtual bool PostNonNestableDelayedTask( | 194 virtual bool PostNonNestableDelayedTask( |
| 203 const tracked_objects::Location& from_here, | 195 const tracked_objects::Location& from_here, |
| 204 const base::Closure& task, | 196 const base::Closure& task, |
| 205 int64 delay_ms) { | 197 int64 delay_ms) OVERRIDE { |
| 206 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | 198 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, |
| 207 delay_ms); | 199 delay_ms); |
| 208 } | 200 } |
| 209 | 201 |
| 210 virtual bool BelongsToCurrentThread() { | 202 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { |
| 211 return BrowserThread::CurrentlyOn(id_); | 203 return BrowserThread::CurrentlyOn(id_); |
| 212 } | 204 } |
| 213 | 205 |
| 214 private: | 206 private: |
| 215 BrowserThread::ID id_; | 207 BrowserThread::ID id_; |
| 216 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); | 208 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); |
| 217 }; | 209 }; |
| 218 | 210 |
| 219 // static | 211 // static |
| 220 bool BrowserThread::PostBlockingPoolTask( | 212 bool BrowserThread::PostBlockingPoolTask( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 354 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 363 &globals.thread_delegates[identifier]); | 355 &globals.thread_delegates[identifier]); |
| 364 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 356 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 365 storage, reinterpret_cast<AtomicWord>(delegate)); | 357 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 366 | 358 |
| 367 // This catches registration when previously registered. | 359 // This catches registration when previously registered. |
| 368 DCHECK(!delegate || !old_pointer); | 360 DCHECK(!delegate || !old_pointer); |
| 369 } | 361 } |
| 370 | 362 |
| 371 } // namespace content | 363 } // namespace content |
| OLD | NEW |