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

Side by Side Diff: remoting/protocol/host_message_dispatcher.cc

Issue 6271004: Changed MessageReader so that it doesn't read from the socket if there are (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ref-counted MessageReader Created 9 years, 11 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
« no previous file with comments | « remoting/protocol/host_message_dispatcher.h ('k') | remoting/protocol/input_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/ref_counted.h" 5 #include "base/ref_counted.h"
6 #include "net/base/io_buffer.h" 6 #include "net/base/io_buffer.h"
7 #include "remoting/proto/control.pb.h" 7 #include "remoting/proto/control.pb.h"
8 #include "remoting/proto/event.pb.h" 8 #include "remoting/proto/event.pb.h"
9 #include "remoting/proto/internal.pb.h" 9 #include "remoting/proto/internal.pb.h"
10 #include "remoting/protocol/host_message_dispatcher.h" 10 #include "remoting/protocol/host_message_dispatcher.h"
11 #include "remoting/protocol/host_stub.h" 11 #include "remoting/protocol/host_stub.h"
12 #include "remoting/protocol/input_stub.h" 12 #include "remoting/protocol/input_stub.h"
13 #include "remoting/protocol/message_reader.h" 13 #include "remoting/protocol/message_reader.h"
14 #include "remoting/protocol/ref_counted_message.h"
15 #include "remoting/protocol/session.h" 14 #include "remoting/protocol/session.h"
16 15
17 namespace remoting { 16 namespace remoting {
18 namespace protocol { 17 namespace protocol {
19 18
20 HostMessageDispatcher::HostMessageDispatcher() : 19 HostMessageDispatcher::HostMessageDispatcher() :
21 host_stub_(NULL), 20 host_stub_(NULL),
22 input_stub_(NULL) { 21 input_stub_(NULL) {
23 } 22 }
24 23
(...skipping 15 matching lines...) Expand all
40 39
41 // Initialize the readers on the sockets provided by channels. 40 // Initialize the readers on the sockets provided by channels.
42 event_message_reader_->Init( 41 event_message_reader_->Init(
43 session->event_channel(), 42 session->event_channel(),
44 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived)); 43 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived));
45 control_message_reader_->Init( 44 control_message_reader_->Init(
46 session->control_channel(), 45 session->control_channel(),
47 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived)); 46 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived));
48 } 47 }
49 48
50 void HostMessageDispatcher::OnControlMessageReceived(ControlMessage* message) { 49 void HostMessageDispatcher::OnControlMessageReceived(
51 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = 50 ControlMessage* message, Task* done_task) {
52 new RefCountedMessage<ControlMessage>(message); 51 // TODO(sergeyu): Add message validation.
53 if (message->has_suggest_resolution()) { 52 if (message->has_suggest_resolution()) {
54 host_stub_->SuggestResolution( 53 host_stub_->SuggestResolution(&message->suggest_resolution(), done_task);
55 &message->suggest_resolution(), NewDeleteTask(ref_msg));
56 } else if (message->has_begin_session_request()) { 54 } else if (message->has_begin_session_request()) {
57 host_stub_->BeginSessionRequest( 55 host_stub_->BeginSessionRequest(
58 &message->begin_session_request().credentials(), 56 &message->begin_session_request().credentials(), done_task);
59 NewDeleteTask(ref_msg));
60 } else { 57 } else {
61 NOTREACHED() << "Invalid control message received"; 58 LOG(WARNING) << "Invalid control message received.";
59 done_task->Run();
60 delete done_task;
62 } 61 }
63 } 62 }
64 63
65 void HostMessageDispatcher::OnEventMessageReceived( 64 void HostMessageDispatcher::OnEventMessageReceived(
66 EventMessage* message) { 65 EventMessage* message, Task* done_task) {
67 scoped_refptr<RefCountedMessage<EventMessage> > ref_msg = 66 // TODO(sergeyu): Add message validation.
68 new RefCountedMessage<EventMessage>(message); 67 if (message->has_key_event()) {
69 for (int i = 0; i < message->event_size(); ++i) { 68 input_stub_->InjectKeyEvent(&message->key_event(), done_task);
70 if (message->event(i).has_key()) { 69 } else if (message->has_mouse_event()) {
71 input_stub_->InjectKeyEvent( 70 input_stub_->InjectMouseEvent(&message->mouse_event(), done_task);
72 &message->event(i).key(), NewDeleteTask(ref_msg)); 71 } else {
73 } 72 LOG(WARNING) << "Invalid event message received.";
74 if (message->event(i).has_mouse()) { 73 done_task->Run();
75 input_stub_->InjectMouseEvent( 74 delete done_task;
76 &message->event(i).mouse(), NewDeleteTask(ref_msg));
77 }
78 } 75 }
79 } 76 }
80 77
81 } // namespace protocol 78 } // namespace protocol
82 } // namespace remoting 79 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/host_message_dispatcher.h ('k') | remoting/protocol/input_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698