| 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 "remoting/base/auto_thread.h" | 10 #include "remoting/base/auto_thread.h" |
| 11 #include "remoting/base/url_request_context_getter.h" | 11 #include "remoting/base/url_request_context_getter.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 | 14 |
| 15 ChromotingHostContext::ChromotingHostContext( | 15 ChromotingHostContext::ChromotingHostContext( |
| 16 AutoThreadTaskRunner* ui_task_runner) | 16 AutoThreadTaskRunner* ui_task_runner) |
| 17 : ui_task_runner_(ui_task_runner) { | 17 : ui_task_runner_(ui_task_runner) { |
| 18 #if defined(OS_WIN) | |
| 19 // On Windows the AudioCapturer requires COM, so we run a single-threaded | |
| 20 // apartment, which requires a UI thread. | |
| 21 audio_task_runner_ = | |
| 22 AutoThread::CreateWithLoopAndComInitTypes("ChromotingAudioThread", | |
| 23 ui_task_runner_, | |
| 24 base::MessageLoop::TYPE_UI, | |
| 25 AutoThread::COM_INIT_STA); | |
| 26 #else // !defined(OS_WIN) | |
| 27 audio_task_runner_ = AutoThread::CreateWithType( | |
| 28 "ChromotingAudioThread", ui_task_runner_, base::MessageLoop::TYPE_IO); | |
| 29 #endif // !defined(OS_WIN) | |
| 30 | |
| 31 file_task_runner_ = AutoThread::CreateWithType( | |
| 32 "ChromotingFileThread", ui_task_runner_, base::MessageLoop::TYPE_IO); | |
| 33 input_task_runner_ = AutoThread::CreateWithType( | |
| 34 "ChromotingInputThread", ui_task_runner_, base::MessageLoop::TYPE_IO); | |
| 35 network_task_runner_ = AutoThread::CreateWithType( | |
| 36 "ChromotingNetworkThread", ui_task_runner_, base::MessageLoop::TYPE_IO); | |
| 37 video_capture_task_runner_ = | |
| 38 AutoThread::Create("ChromotingCaptureThread", ui_task_runner_); | |
| 39 video_encode_task_runner_ = AutoThread::Create( | |
| 40 "ChromotingEncodeThread", ui_task_runner_); | |
| 41 | |
| 42 url_request_context_getter_ = new URLRequestContextGetter( | |
| 43 network_task_runner_, file_task_runner_); | |
| 44 } | 18 } |
| 45 | 19 |
| 46 ChromotingHostContext::~ChromotingHostContext() { | 20 ChromotingHostContext::~ChromotingHostContext() { |
| 47 } | 21 } |
| 48 | 22 |
| 49 scoped_ptr<ChromotingHostContext> ChromotingHostContext::Create( | |
| 50 scoped_refptr<AutoThreadTaskRunner> ui_task_runner) { | |
| 51 DCHECK(ui_task_runner->BelongsToCurrentThread()); | |
| 52 | |
| 53 scoped_ptr<ChromotingHostContext> context( | |
| 54 new ChromotingHostContext(ui_task_runner.get())); | |
| 55 if (!context->audio_task_runner_.get() || !context->file_task_runner_.get() || | |
| 56 !context->input_task_runner_.get() || | |
| 57 !context->network_task_runner_.get() || | |
| 58 !context->video_capture_task_runner_.get() || | |
| 59 !context->video_encode_task_runner_.get() || | |
| 60 !context->url_request_context_getter_.get()) { | |
| 61 context.reset(); | |
| 62 } | |
| 63 | |
| 64 return context.Pass(); | |
| 65 } | |
| 66 | |
| 67 scoped_refptr<AutoThreadTaskRunner> | 23 scoped_refptr<AutoThreadTaskRunner> |
| 68 ChromotingHostContext::audio_task_runner() { | 24 ChromotingHostContext::audio_task_runner() { |
| 69 return audio_task_runner_; | 25 return audio_task_runner_; |
| 70 } | 26 } |
| 71 | 27 |
| 72 scoped_refptr<AutoThreadTaskRunner> | 28 scoped_refptr<AutoThreadTaskRunner> |
| 73 ChromotingHostContext::file_task_runner() { | 29 ChromotingHostContext::file_task_runner() { |
| 74 return file_task_runner_; | 30 return file_task_runner_; |
| 75 } | 31 } |
| 76 | 32 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 98 ChromotingHostContext::video_encode_task_runner() { | 54 ChromotingHostContext::video_encode_task_runner() { |
| 99 return video_encode_task_runner_; | 55 return video_encode_task_runner_; |
| 100 } | 56 } |
| 101 | 57 |
| 102 scoped_refptr<net::URLRequestContextGetter> | 58 scoped_refptr<net::URLRequestContextGetter> |
| 103 ChromotingHostContext::url_request_context_getter() { | 59 ChromotingHostContext::url_request_context_getter() { |
| 104 return url_request_context_getter_; | 60 return url_request_context_getter_; |
| 105 } | 61 } |
| 106 | 62 |
| 107 } // namespace remoting | 63 } // namespace remoting |
| OLD | NEW |