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