Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: remoting/host/chromoting_host_context.cc

Issue 923773003: Revert of Remove dependency on content from remoting_host. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/chromoting_host_context.h ('k') | remoting/host/input_injector_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
8 #include "base/threading/thread_restrictions.h" 7 #include "base/threading/thread_restrictions.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "remoting/base/auto_thread.h" 9 #include "remoting/base/auto_thread.h"
10 #include "remoting/base/url_request_context_getter.h" 10 #include "remoting/base/url_request_context_getter.h"
11 11
12 namespace remoting { 12 namespace remoting {
13 13
14 namespace { 14 namespace {
15 15
16 void DisallowBlockingOperations() { 16 void DisallowBlockingOperations() {
17 base::ThreadRestrictions::SetIOAllowed(false); 17 base::ThreadRestrictions::SetIOAllowed(false);
18 base::ThreadRestrictions::DisallowWaiting(); 18 base::ThreadRestrictions::DisallowWaiting();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner, 120 AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner,
121 base::MessageLoop::TYPE_IO), 121 base::MessageLoop::TYPE_IO),
122 network_task_runner, 122 network_task_runner,
123 AutoThread::Create("ChromotingCaptureThread", ui_task_runner), 123 AutoThread::Create("ChromotingCaptureThread", ui_task_runner),
124 AutoThread::Create("ChromotingEncodeThread", ui_task_runner), 124 AutoThread::Create("ChromotingEncodeThread", ui_task_runner),
125 make_scoped_refptr( 125 make_scoped_refptr(
126 new URLRequestContextGetter(network_task_runner, file_task_runner)))); 126 new URLRequestContextGetter(network_task_runner, file_task_runner))));
127 } 127 }
128 128
129 #if defined(OS_CHROMEOS) 129 #if defined(OS_CHROMEOS)
130 namespace {
131 // Retrieves the task_runner from the browser thread with |id|.
132 scoped_refptr<AutoThreadTaskRunner> WrapBrowserThread(
133 content::BrowserThread::ID id) {
134 // AutoThreadTaskRunner is a TaskRunner with the special property that it will
135 // continue to process tasks until no references remain, at least. The
136 // QuitClosure we usually pass does the simple thing of stopping the
137 // underlying TaskRunner. Since we are re-using the ui_task_runner of the
138 // browser thread, we cannot stop it explicitly. Therefore, base::DoNothing
139 // is passed in as the quit closure.
140 // TODO(kelvinp): Fix this (See crbug.com/428187).
141 return new AutoThreadTaskRunner(
142 content::BrowserThread::GetMessageLoopProxyForThread(id).get(),
143 base::Bind(&base::DoNothing));
144 }
145
146 } // namespace
130 147
131 // static 148 // static
132 scoped_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS( 149 scoped_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS(
133 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, 150 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) {
134 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
135 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
136 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) {
137 DCHECK(url_request_context_getter.get()); 151 DCHECK(url_request_context_getter.get());
138 152
153 // Use BrowserThread::FILE as the joiner as it is the only browser-thread
154 // that allows blocking I/O, which is required by thread joining.
155 // TODO(kelvinp): Fix AutoThread so that it can be joinable on task runners
156 // that disallow I/O (crbug.com/428466).
157 scoped_refptr<AutoThreadTaskRunner> file_task_runner =
158 WrapBrowserThread(content::BrowserThread::FILE);
139 159
140 // AutoThreadTaskRunner is a TaskRunner with the special property that it will 160 scoped_refptr<AutoThreadTaskRunner> ui_task_runner =
141 // continue to process tasks until no references remain, at least. The 161 WrapBrowserThread(content::BrowserThread::UI);
142 // QuitClosure we usually pass does the simple thing of stopping the
143 // underlying TaskRunner. Since we are re-using browser's threads, we cannot
144 // stop them explicitly. Therefore, base::DoNothing is passed in as the quit
145 // closure.
146 scoped_refptr<AutoThreadTaskRunner> io_auto_task_runner =
147 new AutoThreadTaskRunner(io_task_runner, base::Bind(&base::DoNothing));
148 scoped_refptr<AutoThreadTaskRunner> file_auto_task_runner =
149 new AutoThreadTaskRunner(file_task_runner, base::Bind(&base::DoNothing));
150 scoped_refptr<AutoThreadTaskRunner> ui_auto_task_runner =
151 new AutoThreadTaskRunner(ui_task_runner, base::Bind(&base::DoNothing));
152 162
153 // Use browser's file thread as the joiner as it is the only browser-thread
154 // that allows blocking I/O, which is required by thread joining.
155 return make_scoped_ptr(new ChromotingHostContext( 163 return make_scoped_ptr(new ChromotingHostContext(
156 ui_auto_task_runner, 164 ui_task_runner,
157 AutoThread::Create("ChromotingAudioThread", file_auto_task_runner), 165 AutoThread::CreateWithType("ChromotingAudioThread", file_task_runner,
158 file_auto_task_runner, 166 base::MessageLoop::TYPE_IO),
159 ui_auto_task_runner, // input_task_runner 167 file_task_runner,
160 io_auto_task_runner, // network_task_runner 168 AutoThread::CreateWithType("ChromotingInputThread", file_task_runner,
161 ui_auto_task_runner, // video_capture_task_runner 169 base::MessageLoop::TYPE_IO),
162 AutoThread::Create("ChromotingEncodeThread", file_auto_task_runner), 170 WrapBrowserThread(content::BrowserThread::IO), // network_task_runner
171 ui_task_runner, // video_capture_task_runner
172 AutoThread::CreateWithType("ChromotingEncodeThread", file_task_runner,
173 base::MessageLoop::TYPE_IO),
163 url_request_context_getter)); 174 url_request_context_getter));
164 } 175 }
165 #endif // defined(OS_CHROMEOS) 176 #endif // defined(OS_CHROMEOS)
166 177
167 } // namespace remoting 178 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host_context.h ('k') | remoting/host/input_injector_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698