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

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

Issue 10572005: Use SingleThreadTaskRunner instead of MessageLoopProxy in remoting/host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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 <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" 12 #include "remoting/jingle_glue/jingle_thread.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 ChromotingHostContext::ChromotingHostContext( 16 ChromotingHostContext::ChromotingHostContext(
17 base::MessageLoopProxy* ui_message_loop) 17 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
18 : main_thread_("ChromotingMainThread"), 18 : capture_thread_("ChromotingCaptureThread"),
19 encode_thread_("ChromotingEncodeThread"), 19 encode_thread_("ChromotingEncodeThread"),
20 desktop_thread_("ChromotingDesktopThread"), 20 desktop_thread_("ChromotingDesktopThread"),
21 io_thread_("ChromotingIOThread"), 21 io_thread_("ChromotingIOThread"),
22 file_thread_("ChromotingFileIOThread"), 22 file_thread_("ChromotingFileIOThread"),
23 ui_message_loop_(ui_message_loop) { 23 ui_task_runner_(ui_task_runner) {
24 } 24 }
25 25
26 ChromotingHostContext::~ChromotingHostContext() { 26 ChromotingHostContext::~ChromotingHostContext() {
27 } 27 }
28 28
29 bool ChromotingHostContext::Start() { 29 bool ChromotingHostContext::Start() {
30 // Start all the threads. 30 // Start all the threads.
31 bool started = main_thread_.Start() && encode_thread_.Start() && 31 bool started = capture_thread_.Start() && encode_thread_.Start() &&
32 jingle_thread_.Start() && desktop_thread_.Start() && 32 jingle_thread_.Start() && desktop_thread_.Start() &&
33 io_thread_.StartWithOptions( 33 io_thread_.StartWithOptions(
34 base::Thread::Options(MessageLoop::TYPE_IO, 0)) && 34 base::Thread::Options(MessageLoop::TYPE_IO, 0)) &&
35 file_thread_.StartWithOptions( 35 file_thread_.StartWithOptions(
36 base::Thread::Options(MessageLoop::TYPE_IO, 0)); 36 base::Thread::Options(MessageLoop::TYPE_IO, 0));
37 if (!started) 37 if (!started)
38 return false; 38 return false;
39 39
40 url_request_context_getter_ = new URLRequestContextGetter( 40 url_request_context_getter_ = new URLRequestContextGetter(
41 ui_message_loop_, io_thread_.message_loop(), 41 ui_task_runner(), io_task_runner(),
42 static_cast<MessageLoopForIO*>(file_thread_.message_loop())); 42 static_cast<MessageLoopForIO*>(file_thread_.message_loop()));
43 return true; 43 return true;
44 } 44 }
45 45
46 JingleThread* ChromotingHostContext::jingle_thread() { 46 JingleThread* ChromotingHostContext::jingle_thread() {
47 return &jingle_thread_; 47 return &jingle_thread_;
48 } 48 }
49 49
50 MessageLoop* ChromotingHostContext::main_message_loop() { 50 base::SingleThreadTaskRunner* ChromotingHostContext::capture_task_runner() {
51 return main_thread_.message_loop(); 51 return capture_thread_.message_loop_proxy();
52 } 52 }
53 53
54 MessageLoop* ChromotingHostContext::encode_message_loop() { 54 base::SingleThreadTaskRunner* ChromotingHostContext::encode_task_runner() {
55 return encode_thread_.message_loop(); 55 return encode_thread_.message_loop_proxy();
56 } 56 }
57 57
58 base::MessageLoopProxy* ChromotingHostContext::network_message_loop() { 58 base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() {
59 return jingle_thread_.message_loop_proxy(); 59 return jingle_thread_.message_loop_proxy();
60 } 60 }
61 61
62 MessageLoop* ChromotingHostContext::desktop_message_loop() { 62 base::SingleThreadTaskRunner* ChromotingHostContext::desktop_task_runner() {
63 return desktop_thread_.message_loop(); 63 return desktop_thread_.message_loop_proxy();
64 } 64 }
65 65
66 base::MessageLoopProxy* ChromotingHostContext::ui_message_loop() { 66 base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() {
67 return ui_message_loop_; 67 return ui_task_runner_;
68 } 68 }
69 69
70 base::MessageLoopProxy* ChromotingHostContext::io_message_loop() { 70 base::SingleThreadTaskRunner* ChromotingHostContext::io_task_runner() {
71 return io_thread_.message_loop_proxy(); 71 return io_thread_.message_loop_proxy();
72 } 72 }
73 73
74 base::MessageLoopProxy* ChromotingHostContext::file_message_loop() { 74 base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() {
75 return file_thread_.message_loop_proxy(); 75 return file_thread_.message_loop_proxy();
76 } 76 }
77 77
78 const scoped_refptr<net::URLRequestContextGetter>& 78 const scoped_refptr<net::URLRequestContextGetter>&
79 ChromotingHostContext::url_request_context_getter() { 79 ChromotingHostContext::url_request_context_getter() {
80 DCHECK(url_request_context_getter_.get()); 80 DCHECK(url_request_context_getter_.get());
81 return url_request_context_getter_; 81 return url_request_context_getter_;
82 } 82 }
83 83
84 } // namespace remoting 84 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host_context.h ('k') | remoting/host/chromoting_host_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698