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/threading/thread_restrictions.h" |
7 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
8 #include "remoting/base/auto_thread.h" | 9 #include "remoting/base/auto_thread.h" |
9 #include "remoting/base/url_request_context_getter.h" | 10 #include "remoting/base/url_request_context_getter.h" |
10 | 11 |
11 namespace remoting { | 12 namespace remoting { |
12 | 13 |
| 14 namespace { |
| 15 |
| 16 void DisallowBlockingOperations() { |
| 17 base::ThreadRestrictions::SetIOAllowed(false); |
| 18 base::ThreadRestrictions::DisallowWaiting(); |
| 19 } |
| 20 |
| 21 } // namespace |
| 22 |
13 ChromotingHostContext::ChromotingHostContext( | 23 ChromotingHostContext::ChromotingHostContext( |
14 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, | 24 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, |
15 scoped_refptr<AutoThreadTaskRunner> audio_task_runner, | 25 scoped_refptr<AutoThreadTaskRunner> audio_task_runner, |
16 scoped_refptr<AutoThreadTaskRunner> file_task_runner, | 26 scoped_refptr<AutoThreadTaskRunner> file_task_runner, |
17 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 27 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
18 scoped_refptr<AutoThreadTaskRunner> network_task_runner, | 28 scoped_refptr<AutoThreadTaskRunner> network_task_runner, |
19 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner, | 29 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner, |
20 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner, | 30 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner, |
21 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) | 31 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) |
22 : ui_task_runner_(ui_task_runner), | 32 : ui_task_runner_(ui_task_runner), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 "ChromotingAudioThread", ui_task_runner, base::MessageLoop::TYPE_UI, | 99 "ChromotingAudioThread", ui_task_runner, base::MessageLoop::TYPE_UI, |
90 AutoThread::COM_INIT_STA); | 100 AutoThread::COM_INIT_STA); |
91 #else // !defined(OS_WIN) | 101 #else // !defined(OS_WIN) |
92 scoped_refptr<AutoThreadTaskRunner> audio_task_runner = | 102 scoped_refptr<AutoThreadTaskRunner> audio_task_runner = |
93 AutoThread::CreateWithType("ChromotingAudioThread", ui_task_runner, | 103 AutoThread::CreateWithType("ChromotingAudioThread", ui_task_runner, |
94 base::MessageLoop::TYPE_IO); | 104 base::MessageLoop::TYPE_IO); |
95 #endif // !defined(OS_WIN) | 105 #endif // !defined(OS_WIN) |
96 scoped_refptr<AutoThreadTaskRunner> file_task_runner = | 106 scoped_refptr<AutoThreadTaskRunner> file_task_runner = |
97 AutoThread::CreateWithType("ChromotingFileThread", ui_task_runner, | 107 AutoThread::CreateWithType("ChromotingFileThread", ui_task_runner, |
98 base::MessageLoop::TYPE_IO); | 108 base::MessageLoop::TYPE_IO); |
| 109 |
99 scoped_refptr<AutoThreadTaskRunner> network_task_runner = | 110 scoped_refptr<AutoThreadTaskRunner> network_task_runner = |
100 AutoThread::CreateWithType("ChromotingNetworkThread", ui_task_runner, | 111 AutoThread::CreateWithType("ChromotingNetworkThread", ui_task_runner, |
101 base::MessageLoop::TYPE_IO); | 112 base::MessageLoop::TYPE_IO); |
| 113 network_task_runner->PostTask(FROM_HERE, |
| 114 base::Bind(&DisallowBlockingOperations)); |
102 | 115 |
103 return make_scoped_ptr(new ChromotingHostContext( | 116 return make_scoped_ptr(new ChromotingHostContext( |
104 ui_task_runner, | 117 ui_task_runner, |
105 audio_task_runner, | 118 audio_task_runner, |
106 file_task_runner, | 119 file_task_runner, |
107 AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner, | 120 AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner, |
108 base::MessageLoop::TYPE_IO), | 121 base::MessageLoop::TYPE_IO), |
109 network_task_runner, | 122 network_task_runner, |
110 AutoThread::Create("ChromotingCaptureThread", ui_task_runner), | 123 AutoThread::Create("ChromotingCaptureThread", ui_task_runner), |
111 AutoThread::Create("ChromotingEncodeThread", ui_task_runner), | 124 AutoThread::Create("ChromotingEncodeThread", ui_task_runner), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 base::MessageLoop::TYPE_IO), | 169 base::MessageLoop::TYPE_IO), |
157 WrapBrowserThread(content::BrowserThread::IO), // network_task_runner | 170 WrapBrowserThread(content::BrowserThread::IO), // network_task_runner |
158 ui_task_runner, // video_capture_task_runner | 171 ui_task_runner, // video_capture_task_runner |
159 AutoThread::CreateWithType("ChromotingEncodeThread", file_task_runner, | 172 AutoThread::CreateWithType("ChromotingEncodeThread", file_task_runner, |
160 base::MessageLoop::TYPE_IO), | 173 base::MessageLoop::TYPE_IO), |
161 url_request_context_getter)); | 174 url_request_context_getter)); |
162 } | 175 } |
163 #endif // defined(OS_CHROMEOS) | 176 #endif // defined(OS_CHROMEOS) |
164 | 177 |
165 } // namespace remoting | 178 } // namespace remoting |
OLD | NEW |