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

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

Issue 11366226: Rename capture and encode threads to make it clear that they are for video. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 video_capture_thread_("ChromotingCaptureThread"),
20 encode_thread_("ChromotingEncodeThread"), 20 video_encode_thread_("ChromotingEncodeThread"),
21 file_thread_("ChromotingFileIOThread"), 21 file_thread_("ChromotingFileIOThread"),
22 input_thread_("ChromotingInputThread"), 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 video_capture_task_runner_ = NULL;
34 encode_task_runner_ = NULL; 34 video_encode_task_runner_ = NULL;
35 file_task_runner_ = NULL; 35 file_task_runner_ = NULL;
36 input_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 44
45 bool started = capture_thread_.Start() && encode_thread_.Start(); 45 bool started = video_capture_thread_.Start() && video_encode_thread_.Start();
46 46
47 #if defined(OS_WIN) 47 #if defined(OS_WIN)
48 // On Windows audio capturer needs to run on a UI thread that has COM 48 // On Windows audio capturer needs to run on a UI thread that has COM
49 // initialized. 49 // initialized.
50 audio_thread_.init_com_with_mta(false); 50 audio_thread_.init_com_with_mta(false);
51 started = started && audio_thread_.Start(); 51 started = started && audio_thread_.Start();
52 #else // defined(OS_WIN) 52 #else // defined(OS_WIN)
53 started = started && audio_thread_.StartWithOptions(io_thread_options); 53 started = started && audio_thread_.StartWithOptions(io_thread_options);
54 #endif // !defined(OS_WIN) 54 #endif // !defined(OS_WIN)
55 55
56 started = started && 56 started = started &&
57 file_thread_.StartWithOptions(io_thread_options) && 57 file_thread_.StartWithOptions(io_thread_options) &&
58 input_thread_.StartWithOptions(io_thread_options) && 58 input_thread_.StartWithOptions(io_thread_options) &&
59 network_thread_.StartWithOptions(io_thread_options); 59 network_thread_.StartWithOptions(io_thread_options);
60 if (!started) 60 if (!started)
61 return false; 61 return false;
62 62
63 // Wrap worker threads with |AutoThreadTaskRunner| and have them reference 63 // Wrap worker threads with |AutoThreadTaskRunner| and have them reference
64 // the main thread via |ui_task_runner_|, to ensure that it remain active to 64 // the main thread via |ui_task_runner_|, to ensure that it remain active to
65 // Stop() them when no references remain. 65 // Stop() them when no references remain.
66 audio_task_runner_ = 66 audio_task_runner_ =
67 new AutoThreadTaskRunner(audio_thread_.message_loop_proxy(), 67 new AutoThreadTaskRunner(audio_thread_.message_loop_proxy(),
68 ui_task_runner_); 68 ui_task_runner_);
69 capture_task_runner_ = 69 video_capture_task_runner_ =
70 new AutoThreadTaskRunner(capture_thread_.message_loop_proxy(), 70 new AutoThreadTaskRunner(video_capture_thread_.message_loop_proxy(),
71 ui_task_runner_); 71 ui_task_runner_);
72 encode_task_runner_ = 72 video_encode_task_runner_ =
73 new AutoThreadTaskRunner(encode_thread_.message_loop_proxy(), 73 new AutoThreadTaskRunner(video_encode_thread_.message_loop_proxy(),
74 ui_task_runner_); 74 ui_task_runner_);
75 file_task_runner_ = 75 file_task_runner_ =
76 new AutoThreadTaskRunner(file_thread_.message_loop_proxy(), 76 new AutoThreadTaskRunner(file_thread_.message_loop_proxy(),
77 ui_task_runner_); 77 ui_task_runner_);
78 input_task_runner_ = 78 input_task_runner_ =
79 new AutoThreadTaskRunner(input_thread_.message_loop_proxy(), 79 new AutoThreadTaskRunner(input_thread_.message_loop_proxy(),
80 ui_task_runner_); 80 ui_task_runner_);
81 network_task_runner_ = 81 network_task_runner_ =
82 new AutoThreadTaskRunner(network_thread_.message_loop_proxy(), 82 new AutoThreadTaskRunner(network_thread_.message_loop_proxy(),
83 ui_task_runner_); 83 ui_task_runner_);
84 84
85 url_request_context_getter_ = new URLRequestContextGetter( 85 url_request_context_getter_ = new URLRequestContextGetter(
86 ui_task_runner(), network_task_runner()); 86 ui_task_runner(), network_task_runner());
87 return true; 87 return true;
88 } 88 }
89 89
90 base::SingleThreadTaskRunner* ChromotingHostContext::audio_task_runner() { 90 base::SingleThreadTaskRunner* ChromotingHostContext::audio_task_runner() {
91 return audio_task_runner_; 91 return audio_task_runner_;
92 } 92 }
93 93
94 base::SingleThreadTaskRunner* ChromotingHostContext::capture_task_runner() { 94 base::SingleThreadTaskRunner*
95 return capture_task_runner_; 95 ChromotingHostContext::video_capture_task_runner() {
96 return video_capture_task_runner_;
96 } 97 }
97 98
98 base::SingleThreadTaskRunner* ChromotingHostContext::encode_task_runner() { 99 base::SingleThreadTaskRunner*
99 return encode_task_runner_; 100 ChromotingHostContext::video_encode_task_runner() {
101 return video_encode_task_runner_;
100 } 102 }
101 103
102 base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() { 104 base::SingleThreadTaskRunner* ChromotingHostContext::file_task_runner() {
103 return file_task_runner_; 105 return file_task_runner_;
104 } 106 }
105 107
106 base::SingleThreadTaskRunner* ChromotingHostContext::input_task_runner() { 108 base::SingleThreadTaskRunner* ChromotingHostContext::input_task_runner() {
107 return input_task_runner_; 109 return input_task_runner_;
108 } 110 }
109 111
110 base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() { 112 base::SingleThreadTaskRunner* ChromotingHostContext::network_task_runner() {
111 return network_task_runner_; 113 return network_task_runner_;
112 } 114 }
113 115
114 base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() { 116 base::SingleThreadTaskRunner* ChromotingHostContext::ui_task_runner() {
115 return ui_task_runner_; 117 return ui_task_runner_;
116 } 118 }
117 119
118 const scoped_refptr<net::URLRequestContextGetter>& 120 const scoped_refptr<net::URLRequestContextGetter>&
119 ChromotingHostContext::url_request_context_getter() { 121 ChromotingHostContext::url_request_context_getter() {
120 DCHECK(url_request_context_getter_.get()); 122 DCHECK(url_request_context_getter_.get());
121 return url_request_context_getter_; 123 return url_request_context_getter_;
122 } 124 }
123 125
124 } // namespace remoting 126 } // 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