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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromoting_host_context.cc
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
index e2943ff329d98f5917aaadb05d892d2521aaaf6a..319cc77f1784f17a2b392d90eda5a372d646df76 100644
--- a/remoting/host/chromoting_host_context.cc
+++ b/remoting/host/chromoting_host_context.cc
@@ -4,8 +4,8 @@
#include "remoting/host/chromoting_host_context.h"
-#include "base/bind.h"
#include "base/threading/thread_restrictions.h"
+#include "content/public/browser/browser_thread.h"
#include "remoting/base/auto_thread.h"
#include "remoting/base/url_request_context_getter.h"
@@ -127,39 +127,50 @@
}
#if defined(OS_CHROMEOS)
+namespace {
+// Retrieves the task_runner from the browser thread with |id|.
+scoped_refptr<AutoThreadTaskRunner> WrapBrowserThread(
+ content::BrowserThread::ID id) {
+ // AutoThreadTaskRunner is a TaskRunner with the special property that it will
+ // continue to process tasks until no references remain, at least. The
+ // QuitClosure we usually pass does the simple thing of stopping the
+ // underlying TaskRunner. Since we are re-using the ui_task_runner of the
+ // browser thread, we cannot stop it explicitly. Therefore, base::DoNothing
+ // is passed in as the quit closure.
+ // TODO(kelvinp): Fix this (See crbug.com/428187).
+ return new AutoThreadTaskRunner(
+ content::BrowserThread::GetMessageLoopProxyForThread(id).get(),
+ base::Bind(&base::DoNothing));
+}
+
+} // namespace
// static
scoped_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS(
- scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) {
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) {
DCHECK(url_request_context_getter.get());
+ // Use BrowserThread::FILE as the joiner as it is the only browser-thread
+ // that allows blocking I/O, which is required by thread joining.
+ // TODO(kelvinp): Fix AutoThread so that it can be joinable on task runners
+ // that disallow I/O (crbug.com/428466).
+ scoped_refptr<AutoThreadTaskRunner> file_task_runner =
+ WrapBrowserThread(content::BrowserThread::FILE);
- // AutoThreadTaskRunner is a TaskRunner with the special property that it will
- // continue to process tasks until no references remain, at least. The
- // QuitClosure we usually pass does the simple thing of stopping the
- // underlying TaskRunner. Since we are re-using browser's threads, we cannot
- // stop them explicitly. Therefore, base::DoNothing is passed in as the quit
- // closure.
- scoped_refptr<AutoThreadTaskRunner> io_auto_task_runner =
- new AutoThreadTaskRunner(io_task_runner, base::Bind(&base::DoNothing));
- scoped_refptr<AutoThreadTaskRunner> file_auto_task_runner =
- new AutoThreadTaskRunner(file_task_runner, base::Bind(&base::DoNothing));
- scoped_refptr<AutoThreadTaskRunner> ui_auto_task_runner =
- new AutoThreadTaskRunner(ui_task_runner, base::Bind(&base::DoNothing));
+ scoped_refptr<AutoThreadTaskRunner> ui_task_runner =
+ WrapBrowserThread(content::BrowserThread::UI);
- // Use browser's file thread as the joiner as it is the only browser-thread
- // that allows blocking I/O, which is required by thread joining.
return make_scoped_ptr(new ChromotingHostContext(
- ui_auto_task_runner,
- AutoThread::Create("ChromotingAudioThread", file_auto_task_runner),
- file_auto_task_runner,
- ui_auto_task_runner, // input_task_runner
- io_auto_task_runner, // network_task_runner
- ui_auto_task_runner, // video_capture_task_runner
- AutoThread::Create("ChromotingEncodeThread", file_auto_task_runner),
+ ui_task_runner,
+ AutoThread::CreateWithType("ChromotingAudioThread", file_task_runner,
+ base::MessageLoop::TYPE_IO),
+ file_task_runner,
+ AutoThread::CreateWithType("ChromotingInputThread", file_task_runner,
+ base::MessageLoop::TYPE_IO),
+ WrapBrowserThread(content::BrowserThread::IO), // network_task_runner
+ ui_task_runner, // video_capture_task_runner
+ AutoThread::CreateWithType("ChromotingEncodeThread", file_task_runner,
+ base::MessageLoop::TYPE_IO),
url_request_context_getter));
}
#endif // defined(OS_CHROMEOS)
« 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