| 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/client_control_dispatcher.h" | 5 #include "remoting/protocol/client_control_dispatcher.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "net/socket/stream_socket.h" | 11 #include "net/socket/stream_socket.h" |
| 12 #include "remoting/base/compound_buffer.h" |
| 12 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 13 #include "remoting/proto/control.pb.h" | 14 #include "remoting/proto/control.pb.h" |
| 14 #include "remoting/proto/internal.pb.h" | 15 #include "remoting/proto/internal.pb.h" |
| 15 #include "remoting/protocol/client_stub.h" | 16 #include "remoting/protocol/client_stub.h" |
| 17 #include "remoting/protocol/message_pipe.h" |
| 16 #include "remoting/protocol/message_serialization.h" | 18 #include "remoting/protocol/message_serialization.h" |
| 17 | 19 |
| 18 namespace remoting { | 20 namespace remoting { |
| 19 namespace protocol { | 21 namespace protocol { |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| 23 // 32-bit BGRA is 4 bytes per pixel. | 25 // 32-bit BGRA is 4 bytes per pixel. |
| 24 const int kBytesPerPixel = 4; | 26 const int kBytesPerPixel = 4; |
| 25 | 27 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } // namespace | 61 } // namespace |
| 60 | 62 |
| 61 ClientControlDispatcher::ClientControlDispatcher() | 63 ClientControlDispatcher::ClientControlDispatcher() |
| 62 : ChannelDispatcherBase(kControlChannelName) {} | 64 : ChannelDispatcherBase(kControlChannelName) {} |
| 63 ClientControlDispatcher::~ClientControlDispatcher() {} | 65 ClientControlDispatcher::~ClientControlDispatcher() {} |
| 64 | 66 |
| 65 void ClientControlDispatcher::InjectClipboardEvent( | 67 void ClientControlDispatcher::InjectClipboardEvent( |
| 66 const ClipboardEvent& event) { | 68 const ClipboardEvent& event) { |
| 67 ControlMessage message; | 69 ControlMessage message; |
| 68 message.mutable_clipboard_event()->CopyFrom(event); | 70 message.mutable_clipboard_event()->CopyFrom(event); |
| 69 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 71 message_pipe()->Send(&message, base::Closure()); |
| 70 } | 72 } |
| 71 | 73 |
| 72 void ClientControlDispatcher::NotifyClientResolution( | 74 void ClientControlDispatcher::NotifyClientResolution( |
| 73 const ClientResolution& resolution) { | 75 const ClientResolution& resolution) { |
| 74 ControlMessage message; | 76 ControlMessage message; |
| 75 message.mutable_client_resolution()->CopyFrom(resolution); | 77 message.mutable_client_resolution()->CopyFrom(resolution); |
| 76 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 78 message_pipe()->Send(&message, base::Closure()); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void ClientControlDispatcher::ControlVideo(const VideoControl& video_control) { | 81 void ClientControlDispatcher::ControlVideo(const VideoControl& video_control) { |
| 80 ControlMessage message; | 82 ControlMessage message; |
| 81 message.mutable_video_control()->CopyFrom(video_control); | 83 message.mutable_video_control()->CopyFrom(video_control); |
| 82 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 84 message_pipe()->Send(&message, base::Closure()); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void ClientControlDispatcher::ControlAudio(const AudioControl& audio_control) { | 87 void ClientControlDispatcher::ControlAudio(const AudioControl& audio_control) { |
| 86 ControlMessage message; | 88 ControlMessage message; |
| 87 message.mutable_audio_control()->CopyFrom(audio_control); | 89 message.mutable_audio_control()->CopyFrom(audio_control); |
| 88 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 90 message_pipe()->Send(&message, base::Closure()); |
| 89 } | 91 } |
| 90 | 92 |
| 91 void ClientControlDispatcher::SetCapabilities( | 93 void ClientControlDispatcher::SetCapabilities( |
| 92 const Capabilities& capabilities) { | 94 const Capabilities& capabilities) { |
| 93 ControlMessage message; | 95 ControlMessage message; |
| 94 message.mutable_capabilities()->CopyFrom(capabilities); | 96 message.mutable_capabilities()->CopyFrom(capabilities); |
| 95 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 97 message_pipe()->Send(&message, base::Closure()); |
| 96 } | 98 } |
| 97 | 99 |
| 98 void ClientControlDispatcher::RequestPairing( | 100 void ClientControlDispatcher::RequestPairing( |
| 99 const PairingRequest& pairing_request) { | 101 const PairingRequest& pairing_request) { |
| 100 ControlMessage message; | 102 ControlMessage message; |
| 101 message.mutable_pairing_request()->CopyFrom(pairing_request); | 103 message.mutable_pairing_request()->CopyFrom(pairing_request); |
| 102 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 104 message_pipe()->Send(&message, base::Closure()); |
| 103 } | 105 } |
| 104 | 106 |
| 105 void ClientControlDispatcher::DeliverClientMessage( | 107 void ClientControlDispatcher::DeliverClientMessage( |
| 106 const ExtensionMessage& message) { | 108 const ExtensionMessage& message) { |
| 107 ControlMessage control_message; | 109 ControlMessage control_message; |
| 108 control_message.mutable_extension_message()->CopyFrom(message); | 110 control_message.mutable_extension_message()->CopyFrom(message); |
| 109 writer()->Write(SerializeAndFrameMessage(control_message), base::Closure()); | 111 message_pipe()->Send(&control_message, base::Closure()); |
| 110 } | 112 } |
| 111 | 113 |
| 112 void ClientControlDispatcher::OnIncomingMessage( | 114 void ClientControlDispatcher::OnIncomingMessage( |
| 113 scoped_ptr<CompoundBuffer> buffer) { | 115 scoped_ptr<CompoundBuffer> buffer) { |
| 114 DCHECK(client_stub_); | 116 DCHECK(client_stub_); |
| 115 DCHECK(clipboard_stub_); | 117 DCHECK(clipboard_stub_); |
| 116 | 118 |
| 117 scoped_ptr<ControlMessage> message = | 119 scoped_ptr<ControlMessage> message = |
| 118 ParseMessage<ControlMessage>(buffer.get()); | 120 ParseMessage<ControlMessage>(buffer.get()); |
| 119 if (!message) | 121 if (!message) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 130 client_stub_->SetPairingResponse(message->pairing_response()); | 132 client_stub_->SetPairingResponse(message->pairing_response()); |
| 131 } else if (message->has_extension_message()) { | 133 } else if (message->has_extension_message()) { |
| 132 client_stub_->DeliverHostMessage(message->extension_message()); | 134 client_stub_->DeliverHostMessage(message->extension_message()); |
| 133 } else { | 135 } else { |
| 134 LOG(WARNING) << "Unknown control message received."; | 136 LOG(WARNING) << "Unknown control message received."; |
| 135 } | 137 } |
| 136 } | 138 } |
| 137 | 139 |
| 138 } // namespace protocol | 140 } // namespace protocol |
| 139 } // namespace remoting | 141 } // namespace remoting |
| OLD | NEW |