OLD | NEW |
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/protocol/host_control_dispatcher.h" | 5 #include "remoting/protocol/host_control_dispatcher.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "net/socket/stream_socket.h" | 8 #include "net/socket/stream_socket.h" |
| 9 #include "remoting/base/compound_buffer.h" |
9 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
10 #include "remoting/proto/control.pb.h" | 11 #include "remoting/proto/control.pb.h" |
11 #include "remoting/proto/internal.pb.h" | 12 #include "remoting/proto/internal.pb.h" |
12 #include "remoting/protocol/clipboard_stub.h" | 13 #include "remoting/protocol/clipboard_stub.h" |
13 #include "remoting/protocol/host_stub.h" | 14 #include "remoting/protocol/host_stub.h" |
| 15 #include "remoting/protocol/message_pipe.h" |
14 #include "remoting/protocol/message_serialization.h" | 16 #include "remoting/protocol/message_serialization.h" |
15 | 17 |
16 namespace remoting { | 18 namespace remoting { |
17 namespace protocol { | 19 namespace protocol { |
18 | 20 |
19 HostControlDispatcher::HostControlDispatcher() | 21 HostControlDispatcher::HostControlDispatcher() |
20 : ChannelDispatcherBase(kControlChannelName) {} | 22 : ChannelDispatcherBase(kControlChannelName) {} |
21 HostControlDispatcher::~HostControlDispatcher() {} | 23 HostControlDispatcher::~HostControlDispatcher() {} |
22 | 24 |
23 void HostControlDispatcher::SetCapabilities( | 25 void HostControlDispatcher::SetCapabilities( |
24 const Capabilities& capabilities) { | 26 const Capabilities& capabilities) { |
25 ControlMessage message; | 27 ControlMessage message; |
26 message.mutable_capabilities()->CopyFrom(capabilities); | 28 message.mutable_capabilities()->CopyFrom(capabilities); |
27 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 29 message_pipe()->Send(&message, base::Closure()); |
28 } | 30 } |
29 | 31 |
30 void HostControlDispatcher::SetPairingResponse( | 32 void HostControlDispatcher::SetPairingResponse( |
31 const PairingResponse& pairing_response) { | 33 const PairingResponse& pairing_response) { |
32 ControlMessage message; | 34 ControlMessage message; |
33 message.mutable_pairing_response()->CopyFrom(pairing_response); | 35 message.mutable_pairing_response()->CopyFrom(pairing_response); |
34 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 36 message_pipe()->Send(&message, base::Closure()); |
35 } | 37 } |
36 | 38 |
37 void HostControlDispatcher::DeliverHostMessage( | 39 void HostControlDispatcher::DeliverHostMessage( |
38 const ExtensionMessage& message) { | 40 const ExtensionMessage& message) { |
39 ControlMessage control_message; | 41 ControlMessage control_message; |
40 control_message.mutable_extension_message()->CopyFrom(message); | 42 control_message.mutable_extension_message()->CopyFrom(message); |
41 writer()->Write(SerializeAndFrameMessage(control_message), base::Closure()); | 43 message_pipe()->Send(&control_message, base::Closure()); |
42 } | 44 } |
43 | 45 |
44 void HostControlDispatcher::InjectClipboardEvent(const ClipboardEvent& event) { | 46 void HostControlDispatcher::InjectClipboardEvent(const ClipboardEvent& event) { |
45 ControlMessage message; | 47 ControlMessage message; |
46 message.mutable_clipboard_event()->CopyFrom(event); | 48 message.mutable_clipboard_event()->CopyFrom(event); |
47 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 49 message_pipe()->Send(&message, base::Closure()); |
48 } | 50 } |
49 | 51 |
50 void HostControlDispatcher::SetCursorShape( | 52 void HostControlDispatcher::SetCursorShape( |
51 const CursorShapeInfo& cursor_shape) { | 53 const CursorShapeInfo& cursor_shape) { |
52 ControlMessage message; | 54 ControlMessage message; |
53 message.mutable_cursor_shape()->CopyFrom(cursor_shape); | 55 message.mutable_cursor_shape()->CopyFrom(cursor_shape); |
54 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 56 message_pipe()->Send(&message, base::Closure()); |
55 } | 57 } |
56 | 58 |
57 void HostControlDispatcher::OnIncomingMessage( | 59 void HostControlDispatcher::OnIncomingMessage( |
58 scoped_ptr<CompoundBuffer> buffer) { | 60 scoped_ptr<CompoundBuffer> buffer) { |
59 DCHECK(clipboard_stub_); | 61 DCHECK(clipboard_stub_); |
60 DCHECK(host_stub_); | 62 DCHECK(host_stub_); |
61 | 63 |
62 scoped_ptr<ControlMessage> message = | 64 scoped_ptr<ControlMessage> message = |
63 ParseMessage<ControlMessage>(buffer.get()); | 65 ParseMessage<ControlMessage>(buffer.get()); |
64 if (!message) | 66 if (!message) |
(...skipping 13 matching lines...) Expand all Loading... |
78 host_stub_->RequestPairing(message->pairing_request()); | 80 host_stub_->RequestPairing(message->pairing_request()); |
79 } else if (message->has_extension_message()) { | 81 } else if (message->has_extension_message()) { |
80 host_stub_->DeliverClientMessage(message->extension_message()); | 82 host_stub_->DeliverClientMessage(message->extension_message()); |
81 } else { | 83 } else { |
82 LOG(WARNING) << "Unknown control message received."; | 84 LOG(WARNING) << "Unknown control message received."; |
83 } | 85 } |
84 } | 86 } |
85 | 87 |
86 } // namespace protocol | 88 } // namespace protocol |
87 } // namespace remoting | 89 } // namespace remoting |
OLD | NEW |