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

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: - 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
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" 14 #include "remoting/protocol/ref_counted_task.h"
15 #include "remoting/protocol/session.h" 15 #include "remoting/protocol/session.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 namespace protocol { 18 namespace protocol {
19 19
20 HostMessageDispatcher::HostMessageDispatcher() : 20 HostMessageDispatcher::HostMessageDispatcher() :
21 host_stub_(NULL), 21 host_stub_(NULL),
22 input_stub_(NULL) { 22 input_stub_(NULL) {
23 } 23 }
24 24
(...skipping 15 matching lines...) Expand all
40 40
41 // Initialize the readers on the sockets provided by channels. 41 // Initialize the readers on the sockets provided by channels.
42 event_message_reader_->Init( 42 event_message_reader_->Init(
43 session->event_channel(), 43 session->event_channel(),
44 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived)); 44 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived));
45 control_message_reader_->Init( 45 control_message_reader_->Init(
46 session->control_channel(), 46 session->control_channel(),
47 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived)); 47 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived));
48 } 48 }
49 49
50 void HostMessageDispatcher::OnControlMessageReceived(ControlMessage* message) { 50 void HostMessageDispatcher::OnControlMessageReceived(
51 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = 51 ControlMessage* message, Task* done_task) {
52 new RefCountedMessage<ControlMessage>(message); 52 scoped_refptr<RefCountedTask> ref_counted_task =
53 new RefCountedTask(done_task);
53 if (message->has_suggest_resolution()) { 54 if (message->has_suggest_resolution()) {
54 host_stub_->SuggestResolution( 55 host_stub_->SuggestResolution(
55 &message->suggest_resolution(), NewDeleteTask(ref_msg)); 56 &message->suggest_resolution(), NewDeleteTask(ref_counted_task));
56 } else if (message->has_begin_session_request()) { 57 } else if (message->has_begin_session_request()) {
57 host_stub_->BeginSessionRequest( 58 host_stub_->BeginSessionRequest(
58 &message->begin_session_request().credentials(), 59 &message->begin_session_request().credentials(),
59 NewDeleteTask(ref_msg)); 60 NewDeleteTask(ref_counted_task));
60 } else { 61 } else {
61 NOTREACHED() << "Invalid control message received"; 62 NOTREACHED() << "Invalid control message received";
62 } 63 }
63 } 64 }
64 65
65 void HostMessageDispatcher::OnEventMessageReceived( 66 void HostMessageDispatcher::OnEventMessageReceived(
66 EventMessage* message) { 67 EventMessage* message, Task* done_task) {
67 scoped_refptr<RefCountedMessage<EventMessage> > ref_msg = 68 scoped_refptr<RefCountedTask> ref_counted_task =
68 new RefCountedMessage<EventMessage>(message); 69 new RefCountedTask(done_task);
69 for (int i = 0; i < message->event_size(); ++i) { 70 for (int i = 0; i < message->event_size(); ++i) {
70 if (message->event(i).has_key()) { 71 if (message->event(i).has_key()) {
71 input_stub_->InjectKeyEvent( 72 input_stub_->InjectKeyEvent(
72 &message->event(i).key(), NewDeleteTask(ref_msg)); 73 &message->event(i).key(), NewDeleteTask(ref_counted_task));
73 } 74 }
74 if (message->event(i).has_mouse()) { 75 if (message->event(i).has_mouse()) {
75 input_stub_->InjectMouseEvent( 76 input_stub_->InjectMouseEvent(
76 &message->event(i).mouse(), NewDeleteTask(ref_msg)); 77 &message->event(i).mouse(), NewDeleteTask(ref_counted_task));
77 } 78 }
78 } 79 }
79 } 80 }
80 81
81 } // namespace protocol 82 } // namespace protocol
82 } // namespace remoting 83 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698