OLD | NEW |
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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 void HostMessageDispatcher::Initialize( | 28 void HostMessageDispatcher::Initialize( |
29 protocol::Session* session, | 29 protocol::Session* session, |
30 HostStub* host_stub, InputStub* input_stub) { | 30 HostStub* host_stub, InputStub* input_stub) { |
31 if (!session || !host_stub || !input_stub || | 31 if (!session || !host_stub || !input_stub || |
32 !session->event_channel() || !session->control_channel()) { | 32 !session->event_channel() || !session->control_channel()) { |
33 return; | 33 return; |
34 } | 34 } |
35 | 35 |
36 control_message_reader_.reset(new MessageReader()); | 36 control_message_reader_.reset(new ProtobufMessageReader<ControlMessage>()); |
37 event_message_reader_.reset(new MessageReader()); | 37 event_message_reader_.reset(new ProtobufMessageReader<EventMessage>()); |
38 host_stub_ = host_stub; | 38 host_stub_ = host_stub; |
39 input_stub_ = input_stub; | 39 input_stub_ = input_stub; |
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<EventMessage>( | 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<ControlMessage>( | 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(ControlMessage* message) { |
51 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = | 51 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = |
52 new RefCountedMessage<ControlMessage>(message); | 52 new RefCountedMessage<ControlMessage>(message); |
53 if (message->has_suggest_resolution()) { | 53 if (message->has_suggest_resolution()) { |
54 host_stub_->SuggestResolution( | 54 host_stub_->SuggestResolution( |
55 &message->suggest_resolution(), NewDeleteTask(ref_msg)); | 55 &message->suggest_resolution(), NewDeleteTask(ref_msg)); |
(...skipping 17 matching lines...) Expand all Loading... |
73 } | 73 } |
74 if (message->event(i).has_mouse()) { | 74 if (message->event(i).has_mouse()) { |
75 input_stub_->InjectMouseEvent( | 75 input_stub_->InjectMouseEvent( |
76 &message->event(i).mouse(), NewDeleteTask(ref_msg)); | 76 &message->event(i).mouse(), NewDeleteTask(ref_msg)); |
77 } | 77 } |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 } // namespace protocol | 81 } // namespace protocol |
82 } // namespace remoting | 82 } // namespace remoting |
OLD | NEW |