| 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" |
| 11 #include "remoting/host/url_request_context.h" | 11 #include "remoting/host/url_request_context.h" |
| 12 #include "remoting/jingle_glue/jingle_thread.h" | |
| 13 | 12 |
| 14 namespace remoting { | 13 namespace remoting { |
| 15 | 14 |
| 16 ChromotingHostContext::ChromotingHostContext( | 15 ChromotingHostContext::ChromotingHostContext( |
| 17 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 16 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
| 18 : capture_thread_("ChromotingCaptureThread"), | 17 : network_thread_("ChromotingNetworkThread"), |
| 18 capture_thread_("ChromotingCaptureThread"), |
| 19 encode_thread_("ChromotingEncodeThread"), | 19 encode_thread_("ChromotingEncodeThread"), |
| 20 desktop_thread_("ChromotingDesktopThread"), | 20 desktop_thread_("ChromotingDesktopThread"), |
| 21 io_thread_("ChromotingIOThread"), | |
| 22 file_thread_("ChromotingFileIOThread"), | 21 file_thread_("ChromotingFileIOThread"), |
| 23 ui_task_runner_(ui_task_runner) { | 22 ui_task_runner_(ui_task_runner) { |
| 24 } | 23 } |
| 25 | 24 |
| 26 ChromotingHostContext::~ChromotingHostContext() { | 25 ChromotingHostContext::~ChromotingHostContext() { |
| 27 } | 26 } |
| 28 | 27 |
| 29 bool ChromotingHostContext::Start() { | 28 bool ChromotingHostContext::Start() { |
| 30 // Start all the threads. | 29 // Start all the threads. |
| 31 bool started = capture_thread_.Start() && encode_thread_.Start() && | 30 bool started = capture_thread_.Start() && encode_thread_.Start() && |
| 32 jingle_thread_.Start() && desktop_thread_.Start() && | 31 network_thread_.StartWithOptions(base::Thread::Options( |
| 33 io_thread_.StartWithOptions( | 32 MessageLoop::TYPE_IO, 0)) && |
| 34 base::Thread::Options(MessageLoop::TYPE_IO, 0)) && | 33 desktop_thread_.Start() && |
| 35 file_thread_.StartWithOptions( | 34 file_thread_.StartWithOptions( |
| 36 base::Thread::Options(MessageLoop::TYPE_IO, 0)); | 35 base::Thread::Options(MessageLoop::TYPE_IO, 0)); |
| 37 if (!started) | 36 if (!started) |
| 38 return false; | 37 return false; |
| 39 | 38 |
| 40 url_request_context_getter_ = new URLRequestContextGetter( | 39 url_request_context_getter_ = new URLRequestContextGetter( |
| 41 ui_task_runner(), io_task_runner(), | 40 ui_task_runner(), network_task_runner(), |
| 42 static_cast<MessageLoopForIO*>(file_thread_.message_loop())); | 41 static_cast<MessageLoopForIO*>(file_thread_.message_loop())); |
| 43 return true; | 42 return true; |
| 44 } | 43 } |
| 45 | 44 |
| 46 JingleThread* ChromotingHostContext::jingle_thread() { | |
| 47 return &jingle_thread_; | |
| 48 } | |
| 49 | |
| 50 base::SingleThreadTaskRunner* ChromotingHostContext::capture_task_runner() { | 45 base::SingleThreadTaskRunner* ChromotingHostContext::capture_task_runner() { |
| 51 return capture_thread_.message_loop_proxy(); | 46 return capture_thread_.message_loop_proxy(); |
| 52 } | 47 } |
| 53 | 48 |
| 54 base::SingleThreadTaskRunner* ChromotingHostContext::encode_task_runner() { | 49 base::SingleThreadTaskRunner* ChromotingHostContext::encode_task_runner() { |
| 55 return encode_thread_.message_loop_proxy(); | 50 return encode_thread_.message_loop_proxy(); |
| 56 } | 51 } |
| 57 | 52 |
| 58 base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() { | 53 base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() { |
| 59 return jingle_thread_.message_loop_proxy(); | 54 return network_thread_.message_loop_proxy(); |
| 60 } | 55 } |
| 61 | 56 |
| 62 base::SingleThreadTaskRunner* ChromotingHostContext::desktop_task_runner() { | 57 base::SingleThreadTaskRunner* ChromotingHostContext::desktop_task_runner() { |
| 63 return desktop_thread_.message_loop_proxy(); | 58 return desktop_thread_.message_loop_proxy(); |
| 64 } | 59 } |
| 65 | 60 |
| 66 base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() { | 61 base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() { |
| 67 return ui_task_runner_; | 62 return ui_task_runner_; |
| 68 } | 63 } |
| 69 | 64 |
| 70 base::SingleThreadTaskRunner* ChromotingHostContext::io_task_runner() { | |
| 71 return io_thread_.message_loop_proxy(); | |
| 72 } | |
| 73 | |
| 74 base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() { | 65 base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() { |
| 75 return file_thread_.message_loop_proxy(); | 66 return file_thread_.message_loop_proxy(); |
| 76 } | 67 } |
| 77 | 68 |
| 78 const scoped_refptr<net::URLRequestContextGetter>& | 69 const scoped_refptr<net::URLRequestContextGetter>& |
| 79 ChromotingHostContext::url_request_context_getter() { | 70 ChromotingHostContext::url_request_context_getter() { |
| 80 DCHECK(url_request_context_getter_.get()); | 71 DCHECK(url_request_context_getter_.get()); |
| 81 return url_request_context_getter_; | 72 return url_request_context_getter_; |
| 82 } | 73 } |
| 83 | 74 |
| 84 } // namespace remoting | 75 } // namespace remoting |
| OLD | NEW |