James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1 | // Copyright 2013 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 | |
James Robinson | b4b7af2 | 2014-12-05 11:21:01 -0800 | [diff] [blame] | 5 | #ifndef SHELL_TASK_RUNNERS_H_ |
| 6 | #define SHELL_TASK_RUNNERS_H_ |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 7 | |
| 8 | #include "base/macros.h" |
| 9 | #include "base/memory/ref_counted.h" |
| 10 | #include "base/memory/scoped_ptr.h" |
skyostil | b454cd3 | 2015-06-10 10:24:06 -0700 | [diff] [blame] | 11 | #include "base/single_thread_task_runner.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 12 | #include "base/threading/thread.h" |
| 13 | |
| 14 | namespace base { |
| 15 | class SequencedWorkerPool; |
| 16 | } |
| 17 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 18 | namespace shell { |
| 19 | |
| 20 | // A context object that contains the common task runners for the shell's main |
| 21 | // process. |
| 22 | class TaskRunners { |
| 23 | public: |
| 24 | explicit TaskRunners( |
| 25 | const scoped_refptr<base::SingleThreadTaskRunner>& shell_runner); |
| 26 | ~TaskRunners(); |
| 27 | |
| 28 | base::SingleThreadTaskRunner* shell_runner() const { |
| 29 | return shell_runner_.get(); |
| 30 | } |
| 31 | |
| 32 | base::SingleThreadTaskRunner* io_runner() const { |
| 33 | return io_thread_->message_loop_proxy().get(); |
| 34 | } |
| 35 | |
| 36 | base::SequencedWorkerPool* blocking_pool() const { |
| 37 | return blocking_pool_.get(); |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | scoped_refptr<base::SingleThreadTaskRunner> shell_runner_; |
| 42 | scoped_ptr<base::Thread> io_thread_; |
| 43 | |
| 44 | scoped_refptr<base::SequencedWorkerPool> blocking_pool_; |
| 45 | |
| 46 | DISALLOW_COPY_AND_ASSIGN(TaskRunners); |
| 47 | }; |
| 48 | |
| 49 | } // namespace shell |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 50 | |
James Robinson | b4b7af2 | 2014-12-05 11:21:01 -0800 | [diff] [blame] | 51 | #endif // SHELL_TASK_RUNNERS_H_ |