| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 input_task_runner_(input_task_runner), | 37 input_task_runner_(input_task_runner), |
| 38 network_task_runner_(network_task_runner), | 38 network_task_runner_(network_task_runner), |
| 39 video_capture_task_runner_(video_capture_task_runner), | 39 video_capture_task_runner_(video_capture_task_runner), |
| 40 video_encode_task_runner_(video_encode_task_runner), | 40 video_encode_task_runner_(video_encode_task_runner), |
| 41 url_request_context_getter_(url_request_context_getter) { | 41 url_request_context_getter_(url_request_context_getter) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 ChromotingHostContext::~ChromotingHostContext() { | 44 ChromotingHostContext::~ChromotingHostContext() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Copy() { | 47 std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Copy() const { |
| 48 return base::WrapUnique(new ChromotingHostContext( | 48 return base::WrapUnique(new ChromotingHostContext( |
| 49 ui_task_runner_, audio_task_runner_, file_task_runner_, | 49 ui_task_runner_, audio_task_runner_, file_task_runner_, |
| 50 input_task_runner_, network_task_runner_, video_capture_task_runner_, | 50 input_task_runner_, network_task_runner_, video_capture_task_runner_, |
| 51 video_encode_task_runner_, url_request_context_getter_)); | 51 video_encode_task_runner_, url_request_context_getter_)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 scoped_refptr<AutoThreadTaskRunner> ChromotingHostContext::audio_task_runner() | 54 scoped_refptr<AutoThreadTaskRunner> ChromotingHostContext::audio_task_runner() |
| 55 const { | 55 const { |
| 56 return audio_task_runner_; | 56 return audio_task_runner_; |
| 57 } | 57 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 scoped_refptr<AutoThreadTaskRunner> file_task_runner = | 108 scoped_refptr<AutoThreadTaskRunner> file_task_runner = |
| 109 AutoThread::CreateWithType("ChromotingFileThread", ui_task_runner, | 109 AutoThread::CreateWithType("ChromotingFileThread", ui_task_runner, |
| 110 base::MessageLoop::TYPE_IO); | 110 base::MessageLoop::TYPE_IO); |
| 111 | 111 |
| 112 scoped_refptr<AutoThreadTaskRunner> network_task_runner = | 112 scoped_refptr<AutoThreadTaskRunner> network_task_runner = |
| 113 AutoThread::CreateWithType("ChromotingNetworkThread", ui_task_runner, | 113 AutoThread::CreateWithType("ChromotingNetworkThread", ui_task_runner, |
| 114 base::MessageLoop::TYPE_IO); | 114 base::MessageLoop::TYPE_IO); |
| 115 network_task_runner->PostTask(FROM_HERE, | 115 network_task_runner->PostTask(FROM_HERE, |
| 116 base::Bind(&DisallowBlockingOperations)); | 116 base::Bind(&DisallowBlockingOperations)); |
| 117 | 117 |
| 118 return base::WrapUnique(new ChromotingHostContext( | 118 return Create(ui_task_runner, audio_task_runner, file_task_runner, |
| 119 ui_task_runner, audio_task_runner, file_task_runner, | |
| 120 AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner, | 119 AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner, |
| 121 base::MessageLoop::TYPE_IO), | 120 base::MessageLoop::TYPE_IO), |
| 122 network_task_runner, | 121 network_task_runner, |
| 123 AutoThread::Create("ChromotingCaptureThread", ui_task_runner), | 122 AutoThread::Create("ChromotingCaptureThread", ui_task_runner), |
| 124 AutoThread::Create("ChromotingEncodeThread", ui_task_runner), | 123 AutoThread::Create("ChromotingEncodeThread", ui_task_runner)); |
| 125 make_scoped_refptr( | 124 } |
| 126 new URLRequestContextGetter(network_task_runner, file_task_runner)))); | 125 |
| 126 // static |
| 127 std::unique_ptr<ChromotingHostContext> ChromotingHostContext::CreateForTest( |
| 128 scoped_refptr<AutoThreadTaskRunner> task_runner) { |
| 129 return Create(task_runner, task_runner, task_runner, task_runner, task_runner, |
| 130 task_runner, task_runner); |
| 127 } | 131 } |
| 128 | 132 |
| 129 #if defined(OS_CHROMEOS) | 133 #if defined(OS_CHROMEOS) |
| 130 | 134 |
| 131 // static | 135 // static |
| 132 std::unique_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS( | 136 std::unique_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS( |
| 133 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 137 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
| 134 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 138 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 135 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 139 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 136 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) { | 140 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 157 AutoThread::Create("ChromotingAudioThread", file_auto_task_runner), | 161 AutoThread::Create("ChromotingAudioThread", file_auto_task_runner), |
| 158 file_auto_task_runner, | 162 file_auto_task_runner, |
| 159 ui_auto_task_runner, // input_task_runner | 163 ui_auto_task_runner, // input_task_runner |
| 160 io_auto_task_runner, // network_task_runner | 164 io_auto_task_runner, // network_task_runner |
| 161 ui_auto_task_runner, // video_capture_task_runner | 165 ui_auto_task_runner, // video_capture_task_runner |
| 162 AutoThread::Create("ChromotingEncodeThread", file_auto_task_runner), | 166 AutoThread::Create("ChromotingEncodeThread", file_auto_task_runner), |
| 163 url_request_context_getter)); | 167 url_request_context_getter)); |
| 164 } | 168 } |
| 165 #endif // defined(OS_CHROMEOS) | 169 #endif // defined(OS_CHROMEOS) |
| 166 | 170 |
| 171 // static |
| 172 std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Create( |
| 173 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, |
| 174 scoped_refptr<AutoThreadTaskRunner> audio_task_runner, |
| 175 scoped_refptr<AutoThreadTaskRunner> file_task_runner, |
| 176 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
| 177 scoped_refptr<AutoThreadTaskRunner> network_task_runner, |
| 178 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner, |
| 179 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner) { |
| 180 if (ui_task_runner && audio_task_runner && file_task_runner && |
| 181 input_task_runner && network_task_runner && video_capture_task_runner && |
| 182 video_encode_task_runner) { |
| 183 return base::WrapUnique(new ChromotingHostContext( |
| 184 ui_task_runner, audio_task_runner, file_task_runner, input_task_runner, |
| 185 network_task_runner, video_capture_task_runner, video_encode_task_runner, |
| 186 make_scoped_refptr( |
| 187 new URLRequestContextGetter(network_task_runner, file_task_runner)))); |
| 188 |
| 189 } |
| 190 return std::unique_ptr<ChromotingHostContext>(); |
| 191 } |
| 192 |
| 167 } // namespace remoting | 193 } // namespace remoting |
| OLD | NEW |