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 | #include "shell/task_runners.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 6 | |
| 7 | #include "base/threading/sequenced_worker_pool.h" |
| 8 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 9 | namespace shell { |
| 10 | |
| 11 | namespace { |
| 12 | |
| 13 | const size_t kMaxBlockingPoolThreads = 3; |
| 14 | |
| 15 | scoped_ptr<base::Thread> CreateIOThread(const char* name) { |
| 16 | scoped_ptr<base::Thread> thread(new base::Thread(name)); |
| 17 | base::Thread::Options options; |
| 18 | options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 19 | thread->StartWithOptions(options); |
| 20 | return thread.Pass(); |
| 21 | } |
| 22 | |
| 23 | } // namespace |
| 24 | |
| 25 | TaskRunners::TaskRunners( |
| 26 | const scoped_refptr<base::SingleThreadTaskRunner>& shell_runner) |
| 27 | : shell_runner_(shell_runner), |
| 28 | io_thread_(CreateIOThread("io_thread")), |
| 29 | blocking_pool_(new base::SequencedWorkerPool(kMaxBlockingPoolThreads, |
| 30 | "blocking_pool")) { |
| 31 | } |
| 32 | |
| 33 | TaskRunners::~TaskRunners() { |
| 34 | blocking_pool_->Shutdown(); |
| 35 | } |
| 36 | |
| 37 | } // namespace shell |