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

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

Issue 4726003: Implement InputStub in the host side for chromoting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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.h" 5 #include "remoting/host/chromoting_host.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
11 #include "remoting/base/encoder.h" 11 #include "remoting/base/encoder.h"
12 #include "remoting/base/encoder_verbatim.h" 12 #include "remoting/base/encoder_verbatim.h"
13 #include "remoting/base/encoder_vp8.h" 13 #include "remoting/base/encoder_vp8.h"
14 #include "remoting/base/encoder_zlib.h" 14 #include "remoting/base/encoder_zlib.h"
15 #include "remoting/host/chromoting_host_context.h" 15 #include "remoting/host/chromoting_host_context.h"
16 #include "remoting/host/capturer.h" 16 #include "remoting/host/capturer.h"
17 #include "remoting/host/event_executor.h"
18 #include "remoting/host/host_config.h" 17 #include "remoting/host/host_config.h"
19 #include "remoting/host/session_manager.h" 18 #include "remoting/host/session_manager.h"
20 #include "remoting/protocol/session_config.h" 19 #include "remoting/protocol/session_config.h"
21 #include "remoting/protocol/jingle_session_manager.h" 20 #include "remoting/protocol/jingle_session_manager.h"
22 #include "remoting/protocol/connection_to_client.h" 21 #include "remoting/protocol/connection_to_client.h"
23 22
24 using remoting::protocol::ConnectionToClient; 23 using remoting::protocol::ConnectionToClient;
25 24
26 namespace remoting { 25 namespace remoting {
27 26
28 ChromotingHost::ChromotingHost(ChromotingHostContext* context, 27 ChromotingHost::ChromotingHost(ChromotingHostContext* context,
29 MutableHostConfig* config, 28 MutableHostConfig* config,
30 Capturer* capturer, 29 Capturer* capturer,
31 EventExecutor* executor) 30 protocol::InputStub* input_stub)
32 : context_(context), 31 : context_(context),
33 config_(config), 32 config_(config),
34 capturer_(capturer), 33 capturer_(capturer),
35 executor_(executor), 34 input_stub_(input_stub),
36 state_(kInitial) { 35 state_(kInitial) {
37 } 36 }
38 37
39 ChromotingHost::~ChromotingHost() { 38 ChromotingHost::~ChromotingHost() {
40 } 39 }
41 40
42 void ChromotingHost::Start(Task* shutdown_task) { 41 void ChromotingHost::Start(Task* shutdown_task) {
43 if (MessageLoop::current() != context_->main_message_loop()) { 42 if (MessageLoop::current() != context_->main_message_loop()) {
44 context_->main_message_loop()->PostTask( 43 context_->main_message_loop()->PostTask(
45 FROM_HERE, 44 FROM_HERE,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 172
174 // Close the connection to connection just to be safe. 173 // Close the connection to connection just to be safe.
175 connection->Disconnect(); 174 connection->Disconnect();
176 175
177 // Also remove reference to ConnectionToClient from this object. 176 // Also remove reference to ConnectionToClient from this object.
178 connection_ = NULL; 177 connection_ = NULL;
179 } 178 }
180 179
181 //////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////
182 // protocol::ConnectionToClient::EventHandler implementations 181 // protocol::ConnectionToClient::EventHandler implementations
183 void ChromotingHost::HandleMessage(ConnectionToClient* connection,
184 ChromotingClientMessage* message) {
185 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
186
187 // Delegate the messages to EventExecutor and delete the unhandled
188 // messages.
189 DCHECK(executor_.get());
190 executor_->HandleInputEvent(message);
191 }
192
193 void ChromotingHost::OnConnectionOpened(ConnectionToClient* connection) { 182 void ChromotingHost::OnConnectionOpened(ConnectionToClient* connection) {
194 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 183 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
195 184
196 // Completes the connection to the client. 185 // Completes the connection to the client.
197 VLOG(1) << "Connection to client established."; 186 VLOG(1) << "Connection to client established.";
198 OnClientConnected(connection_.get()); 187 OnClientConnected(connection_.get());
199 } 188 }
200 189
201 void ChromotingHost::OnConnectionClosed(ConnectionToClient* connection) { 190 void ChromotingHost::OnConnectionClosed(ConnectionToClient* connection) {
202 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 191 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 265 }
277 266
278 session->set_config(config); 267 session->set_config(config);
279 268
280 *response = protocol::SessionManager::ACCEPT; 269 *response = protocol::SessionManager::ACCEPT;
281 270
282 VLOG(1) << "Client connected: " << session->jid(); 271 VLOG(1) << "Client connected: " << session->jid();
283 272
284 // If we accept the connected then create a client object and set the 273 // If we accept the connected then create a client object and set the
285 // callback. 274 // callback.
286 connection_ = new ConnectionToClient(context_->main_message_loop(), this); 275 connection_ = new ConnectionToClient(context_->main_message_loop(),
276 this, NULL, input_stub_.get());
287 connection_->Init(session); 277 connection_->Init(session);
288 } 278 }
289 279
290 void ChromotingHost::OnServerClosed() { 280 void ChromotingHost::OnServerClosed() {
291 // Don't need to do anything here. 281 // Don't need to do anything here.
292 } 282 }
293 283
294 // TODO(sergeyu): Move this to SessionManager? 284 // TODO(sergeyu): Move this to SessionManager?
295 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) { 285 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) {
296 const protocol::ChannelConfig& video_config = config->video_config(); 286 const protocol::ChannelConfig& video_config = config->video_config();
297 287
298 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { 288 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
299 return new remoting::EncoderVerbatim(); 289 return new remoting::EncoderVerbatim();
300 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { 290 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) {
301 return new remoting::EncoderZlib(); 291 return new remoting::EncoderZlib();
302 } 292 }
303 // TODO(sergeyu): Enable VP8 on ARM builds. 293 // TODO(sergeyu): Enable VP8 on ARM builds.
304 #if !defined(ARCH_CPU_ARM_FAMILY) 294 #if !defined(ARCH_CPU_ARM_FAMILY)
305 else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { 295 else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
306 return new remoting::EncoderVp8(); 296 return new remoting::EncoderVp8();
307 } 297 }
308 #endif 298 #endif
309 299
310 return NULL; 300 return NULL;
311 } 301 }
312 302
313 } // namespace remoting 303 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698