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

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

Issue 11018004: Fix ChromotingHost and DesktopEnvironmentFactory references to TaskRunners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows build. Created 8 years, 2 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/base/auto_thread_task_runner.h" 11 #include "remoting/base/auto_thread_task_runner.h"
12 #include "remoting/host/url_request_context.h" 12 #include "remoting/host/url_request_context.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 ChromotingHostContext::ChromotingHostContext( 16 ChromotingHostContext::ChromotingHostContext(
17 scoped_refptr<AutoThreadTaskRunner> ui_task_runner) 17 scoped_refptr<AutoThreadTaskRunner> ui_task_runner)
18 : audio_thread_("ChromotingAudioThread"), 18 : audio_thread_("ChromotingAudioThread"),
19 capture_thread_("ChromotingCaptureThread"), 19 capture_thread_("ChromotingCaptureThread"),
20 desktop_thread_("ChromotingDesktopThread"),
21 encode_thread_("ChromotingEncodeThread"), 20 encode_thread_("ChromotingEncodeThread"),
22 file_thread_("ChromotingFileIOThread"), 21 file_thread_("ChromotingFileIOThread"),
22 input_thread_("ChromotingInputThread"),
23 network_thread_("ChromotingNetworkThread"), 23 network_thread_("ChromotingNetworkThread"),
24 ui_task_runner_(ui_task_runner) { 24 ui_task_runner_(ui_task_runner) {
25 } 25 }
26 26
27 ChromotingHostContext::~ChromotingHostContext() { 27 ChromotingHostContext::~ChromotingHostContext() {
28 } 28 }
29 29
30 void ChromotingHostContext::ReleaseTaskRunners() { 30 void ChromotingHostContext::ReleaseTaskRunners() {
31 url_request_context_getter_ = NULL; 31 url_request_context_getter_ = NULL;
32 audio_task_runner_ = NULL; 32 audio_task_runner_ = NULL;
33 capture_task_runner_ = NULL; 33 capture_task_runner_ = NULL;
34 desktop_task_runner_ = NULL;
35 encode_task_runner_ = NULL; 34 encode_task_runner_ = NULL;
36 file_task_runner_ = NULL; 35 file_task_runner_ = NULL;
36 input_task_runner_ = NULL;
37 network_task_runner_ = NULL; 37 network_task_runner_ = NULL;
38 ui_task_runner_ = NULL; 38 ui_task_runner_ = NULL;
39 } 39 }
40 40
41 bool ChromotingHostContext::Start() { 41 bool ChromotingHostContext::Start() {
42 // Start all the threads. 42 // Start all the threads.
43 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0); 43 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0);
44 bool started = capture_thread_.Start() && encode_thread_.Start() && 44 bool started = capture_thread_.Start() && encode_thread_.Start() &&
45 audio_thread_.StartWithOptions(io_thread_options) && 45 audio_thread_.StartWithOptions(io_thread_options) &&
46 network_thread_.StartWithOptions(io_thread_options) && 46 file_thread_.StartWithOptions(io_thread_options) &&
47 desktop_thread_.StartWithOptions(io_thread_options) && 47 input_thread_.StartWithOptions(io_thread_options) &&
48 file_thread_.StartWithOptions(io_thread_options); 48 network_thread_.StartWithOptions(io_thread_options);
49 if (!started) 49 if (!started)
50 return false; 50 return false;
51 51
52 // Wrap worker threads with |AutoThreadTaskRunner| and have them reference 52 // Wrap worker threads with |AutoThreadTaskRunner| and have them reference
53 // the main thread via |ui_task_runner_|, to ensure that it remain active to 53 // the main thread via |ui_task_runner_|, to ensure that it remain active to
54 // Stop() them when no references remain. 54 // Stop() them when no references remain.
55 audio_task_runner_ = 55 audio_task_runner_ =
56 new AutoThreadTaskRunner(audio_thread_.message_loop_proxy(), 56 new AutoThreadTaskRunner(audio_thread_.message_loop_proxy(),
57 ui_task_runner_); 57 ui_task_runner_);
58 capture_task_runner_ = 58 capture_task_runner_ =
59 new AutoThreadTaskRunner(capture_thread_.message_loop_proxy(), 59 new AutoThreadTaskRunner(capture_thread_.message_loop_proxy(),
60 ui_task_runner_); 60 ui_task_runner_);
61 desktop_task_runner_ =
62 new AutoThreadTaskRunner(desktop_thread_.message_loop_proxy(),
63 ui_task_runner_);
64 encode_task_runner_ = 61 encode_task_runner_ =
65 new AutoThreadTaskRunner(encode_thread_.message_loop_proxy(), 62 new AutoThreadTaskRunner(encode_thread_.message_loop_proxy(),
66 ui_task_runner_); 63 ui_task_runner_);
67 file_task_runner_ = 64 file_task_runner_ =
68 new AutoThreadTaskRunner(file_thread_.message_loop_proxy(), 65 new AutoThreadTaskRunner(file_thread_.message_loop_proxy(),
69 ui_task_runner_); 66 ui_task_runner_);
67 input_task_runner_ =
68 new AutoThreadTaskRunner(input_thread_.message_loop_proxy(),
69 ui_task_runner_);
70 network_task_runner_ = 70 network_task_runner_ =
71 new AutoThreadTaskRunner(network_thread_.message_loop_proxy(), 71 new AutoThreadTaskRunner(network_thread_.message_loop_proxy(),
72 ui_task_runner_); 72 ui_task_runner_);
73 73
74 url_request_context_getter_ = new URLRequestContextGetter( 74 url_request_context_getter_ = new URLRequestContextGetter(
75 ui_task_runner(), network_task_runner(), 75 ui_task_runner(), network_task_runner(),
76 static_cast<MessageLoopForIO*>(file_thread_.message_loop())); 76 static_cast<MessageLoopForIO*>(file_thread_.message_loop()));
77 return true; 77 return true;
78 } 78 }
79 79
80 base::SingleThreadTaskRunner* ChromotingHostContext::audio_task_runner() { 80 base::SingleThreadTaskRunner* ChromotingHostContext::audio_task_runner() {
81 return audio_task_runner_; 81 return audio_task_runner_;
82 } 82 }
83 83
84 base::SingleThreadTaskRunner* ChromotingHostContext::capture_task_runner() { 84 base::SingleThreadTaskRunner* ChromotingHostContext::capture_task_runner() {
85 return capture_task_runner_; 85 return capture_task_runner_;
86 } 86 }
87 87
88 base::SingleThreadTaskRunner* ChromotingHostContext::desktop_task_runner() {
89 return desktop_task_runner_;
90 }
91
92 base::SingleThreadTaskRunner* ChromotingHostContext::encode_task_runner() { 88 base::SingleThreadTaskRunner* ChromotingHostContext::encode_task_runner() {
93 return encode_task_runner_; 89 return encode_task_runner_;
94 } 90 }
95 91
96 base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() { 92 base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() {
97 return file_task_runner_; 93 return file_task_runner_;
98 } 94 }
99 95
96 base::SingleThreadTaskRunner* ChromotingHostContext::input_task_runner() {
97 return input_task_runner_;
98 }
99
100 base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() { 100 base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() {
101 return network_task_runner_; 101 return network_task_runner_;
102 } 102 }
103 103
104 base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() { 104 base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() {
105 return ui_task_runner_; 105 return ui_task_runner_;
106 } 106 }
107 107
108 const scoped_refptr<net::URLRequestContextGetter>& 108 const scoped_refptr<net::URLRequestContextGetter>&
109 ChromotingHostContext::url_request_context_getter() { 109 ChromotingHostContext::url_request_context_getter() {
110 DCHECK(url_request_context_getter_.get()); 110 DCHECK(url_request_context_getter_.get());
111 return url_request_context_getter_; 111 return url_request_context_getter_;
112 } 112 }
113 113
114 } // namespace remoting 114 } // 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