| 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 #include "mojo/edk/base_edk/platform_handle_watcher_impl.h" |
| 8 #include "mojo/edk/base_edk/platform_task_runner_impl.h" | 9 #include "mojo/edk/base_edk/platform_task_runner_impl.h" |
| 10 #include "mojo/edk/util/make_unique.h" |
| 9 | 11 |
| 10 using mojo::util::MakeRefCounted; | 12 using mojo::util::MakeRefCounted; |
| 13 using mojo::util::MakeUnique; |
| 11 | 14 |
| 12 namespace shell { | 15 namespace shell { |
| 13 | 16 |
| 14 namespace { | 17 namespace { |
| 15 | 18 |
| 16 const size_t kMaxBlockingPoolThreads = 3; | 19 const size_t kMaxBlockingPoolThreads = 3; |
| 17 | 20 |
| 18 scoped_ptr<base::Thread> CreateIOThread(const char* name) { | 21 scoped_ptr<base::Thread> CreateIOThread(const char* name) { |
| 19 scoped_ptr<base::Thread> thread(new base::Thread(name)); | 22 scoped_ptr<base::Thread> thread(new base::Thread(name)); |
| 20 base::Thread::Options options; | 23 base::Thread::Options options; |
| 21 options.message_loop_type = base::MessageLoop::TYPE_IO; | 24 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 22 thread->StartWithOptions(options); | 25 thread->StartWithOptions(options); |
| 23 return thread; | 26 return thread; |
| 24 } | 27 } |
| 25 | 28 |
| 26 } // namespace | 29 } // namespace |
| 27 | 30 |
| 28 TaskRunners::TaskRunners( | 31 TaskRunners::TaskRunners( |
| 29 const scoped_refptr<base::SingleThreadTaskRunner>& shell_runner) | 32 const scoped_refptr<base::SingleThreadTaskRunner>& shell_runner) |
| 30 : shell_runner_( | 33 : shell_runner_( |
| 31 MakeRefCounted<base_edk::PlatformTaskRunnerImpl>(shell_runner)), | 34 MakeRefCounted<base_edk::PlatformTaskRunnerImpl>(shell_runner)), |
| 32 io_thread_(CreateIOThread("io_thread")), | 35 io_thread_(CreateIOThread("io_thread")), |
| 33 io_runner_(MakeRefCounted<base_edk::PlatformTaskRunnerImpl>( | 36 io_runner_(MakeRefCounted<base_edk::PlatformTaskRunnerImpl>( |
| 34 io_thread_->task_runner())), | 37 io_thread_->task_runner())), |
| 38 io_watcher_(MakeUnique<base_edk::PlatformHandleWatcherImpl>( |
| 39 static_cast<base::MessageLoopForIO*>(io_thread_->message_loop()))), |
| 35 blocking_pool_(new base::SequencedWorkerPool(kMaxBlockingPoolThreads, | 40 blocking_pool_(new base::SequencedWorkerPool(kMaxBlockingPoolThreads, |
| 36 "blocking_pool")) {} | 41 "blocking_pool")) {} |
| 37 | 42 |
| 38 TaskRunners::~TaskRunners() { | 43 TaskRunners::~TaskRunners() { |
| 39 blocking_pool_->Shutdown(); | 44 blocking_pool_->Shutdown(); |
| 40 } | 45 } |
| 41 | 46 |
| 42 } // namespace shell | 47 } // namespace shell |
| OLD | NEW |