| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/chromoting_host_context.h" | 5 #include "remoting/host/chromoting_host_context.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 capture_task_runner_ = NULL; | 33 capture_task_runner_ = NULL; |
| 34 desktop_task_runner_ = NULL; | 34 desktop_task_runner_ = NULL; |
| 35 encode_task_runner_ = NULL; | 35 encode_task_runner_ = NULL; |
| 36 file_task_runner_ = NULL; | 36 file_task_runner_ = NULL; |
| 37 network_task_runner_ = NULL; | 37 network_task_runner_ = NULL; |
| 38 ui_task_runner_ = NULL; | 38 ui_task_runner_ = NULL; |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool ChromotingHostContext::Start() { | 41 bool ChromotingHostContext::Start() { |
| 42 // Start all the threads. | 42 // Start all the threads. |
| 43 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0); |
| 43 bool started = capture_thread_.Start() && encode_thread_.Start() && | 44 bool started = capture_thread_.Start() && encode_thread_.Start() && |
| 44 audio_thread_.StartWithOptions(base::Thread::Options( | 45 audio_thread_.StartWithOptions(io_thread_options) && |
| 45 MessageLoop::TYPE_IO, 0)) && | 46 network_thread_.StartWithOptions(io_thread_options) && |
| 46 network_thread_.StartWithOptions(base::Thread::Options( | 47 desktop_thread_.StartWithOptions(io_thread_options) && |
| 47 MessageLoop::TYPE_IO, 0)) && | 48 file_thread_.StartWithOptions(io_thread_options); |
| 48 desktop_thread_.Start() && | |
| 49 file_thread_.StartWithOptions( | |
| 50 base::Thread::Options(MessageLoop::TYPE_IO, 0)); | |
| 51 if (!started) | 49 if (!started) |
| 52 return false; | 50 return false; |
| 53 | 51 |
| 54 // Wrap worker threads with |AutoThreadTaskRunner| and have them reference | 52 // Wrap worker threads with |AutoThreadTaskRunner| and have them reference |
| 55 // the main thread via |ui_task_runner_|, to ensure that it remain active to | 53 // the main thread via |ui_task_runner_|, to ensure that it remain active to |
| 56 // Stop() them when no references remain. | 54 // Stop() them when no references remain. |
| 57 audio_task_runner_ = | 55 audio_task_runner_ = |
| 58 new AutoThreadTaskRunner(audio_thread_.message_loop_proxy(), | 56 new AutoThreadTaskRunner(audio_thread_.message_loop_proxy(), |
| 59 ui_task_runner_); | 57 ui_task_runner_); |
| 60 capture_task_runner_ = | 58 capture_task_runner_ = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 return ui_task_runner_; | 105 return ui_task_runner_; |
| 108 } | 106 } |
| 109 | 107 |
| 110 const scoped_refptr<net::URLRequestContextGetter>& | 108 const scoped_refptr<net::URLRequestContextGetter>& |
| 111 ChromotingHostContext::url_request_context_getter() { | 109 ChromotingHostContext::url_request_context_getter() { |
| 112 DCHECK(url_request_context_getter_.get()); | 110 DCHECK(url_request_context_getter_.get()); |
| 113 return url_request_context_getter_; | 111 return url_request_context_getter_; |
| 114 } | 112 } |
| 115 | 113 |
| 116 } // namespace remoting | 114 } // namespace remoting |
| OLD | NEW |