| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_TASK_RUNNER_H_ | |
| 6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_TASK_RUNNER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback_forward.h" | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/sequenced_task_runner.h" | |
| 13 #include "base/threading/sequenced_worker_pool.h" | |
| 14 #include "base/time.h" | |
| 15 | |
| 16 namespace tracked_objects { | |
| 17 class Location; | |
| 18 } // namespace tracked_objects | |
| 19 | |
| 20 namespace base { | |
| 21 | |
| 22 // A SequencedTaskRunner which posts tasks to a SequencedWorkerPool with a | |
| 23 // fixed sequence token. | |
| 24 // | |
| 25 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). | |
| 26 class BASE_EXPORT SequencedWorkerPoolTaskRunner : public SequencedTaskRunner { | |
| 27 public: | |
| 28 SequencedWorkerPoolTaskRunner(const scoped_refptr<SequencedWorkerPool>& pool, | |
| 29 SequencedWorkerPool::SequenceToken token); | |
| 30 | |
| 31 // TaskRunner implementation | |
| 32 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | |
| 33 const Closure& task, | |
| 34 TimeDelta delay) OVERRIDE; | |
| 35 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | |
| 36 | |
| 37 // SequencedTaskRunner implementation | |
| 38 virtual bool PostNonNestableDelayedTask( | |
| 39 const tracked_objects::Location& from_here, | |
| 40 const Closure& task, | |
| 41 TimeDelta delay) OVERRIDE; | |
| 42 | |
| 43 private: | |
| 44 virtual ~SequencedWorkerPoolTaskRunner(); | |
| 45 | |
| 46 // Helper function for posting a delayed task. Asserts that the delay is | |
| 47 // zero because non-zero delays are not yet supported. | |
| 48 bool PostDelayedTaskAssertZeroDelay( | |
| 49 const tracked_objects::Location& from_here, | |
| 50 const Closure& task, | |
| 51 TimeDelta delay); | |
| 52 | |
| 53 const scoped_refptr<SequencedWorkerPool> pool_; | |
| 54 | |
| 55 const SequencedWorkerPool::SequenceToken token_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolTaskRunner); | |
| 58 }; | |
| 59 | |
| 60 } // namespace base | |
| 61 | |
| 62 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_TASK_RUNNER_H_ | |
| OLD | NEW |