| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "shell/task_runners.h" | 5 #include "shell/task_runners.h" |
| 6 | 6 |
| 7 #include "base/threading/sequenced_worker_pool.h" | 7 #include "base/threading/sequenced_worker_pool.h" |
| 8 | 8 |
| 9 namespace mojo { | |
| 10 namespace shell { | 9 namespace shell { |
| 11 | 10 |
| 12 namespace { | 11 namespace { |
| 13 | 12 |
| 14 const size_t kMaxBlockingPoolThreads = 3; | 13 const size_t kMaxBlockingPoolThreads = 3; |
| 15 | 14 |
| 16 scoped_ptr<base::Thread> CreateIOThread(const char* name) { | 15 scoped_ptr<base::Thread> CreateIOThread(const char* name) { |
| 17 scoped_ptr<base::Thread> thread(new base::Thread(name)); | 16 scoped_ptr<base::Thread> thread(new base::Thread(name)); |
| 18 base::Thread::Options options; | 17 base::Thread::Options options; |
| 19 options.message_loop_type = base::MessageLoop::TYPE_IO; | 18 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 20 thread->StartWithOptions(options); | 19 thread->StartWithOptions(options); |
| 21 return thread.Pass(); | 20 return thread.Pass(); |
| 22 } | 21 } |
| 23 | 22 |
| 24 } // namespace | 23 } // namespace |
| 25 | 24 |
| 26 TaskRunners::TaskRunners( | 25 TaskRunners::TaskRunners( |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& shell_runner) | 26 const scoped_refptr<base::SingleThreadTaskRunner>& shell_runner) |
| 28 : shell_runner_(shell_runner), | 27 : shell_runner_(shell_runner), |
| 29 io_thread_(CreateIOThread("io_thread")), | 28 io_thread_(CreateIOThread("io_thread")), |
| 30 blocking_pool_(new base::SequencedWorkerPool(kMaxBlockingPoolThreads, | 29 blocking_pool_(new base::SequencedWorkerPool(kMaxBlockingPoolThreads, |
| 31 "blocking_pool")) { | 30 "blocking_pool")) { |
| 32 } | 31 } |
| 33 | 32 |
| 34 TaskRunners::~TaskRunners() { | 33 TaskRunners::~TaskRunners() { |
| 35 blocking_pool_->Shutdown(); | 34 blocking_pool_->Shutdown(); |
| 36 } | 35 } |
| 37 | 36 |
| 38 } // namespace shell | 37 } // namespace shell |
| 39 } // namespace mojo | |
| OLD | NEW |