| 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 "base/callback_helpers.h" | |
| 12 #include "net/socket/stream_socket.h" | 11 #include "net/socket/stream_socket.h" |
| 13 #include "remoting/base/constants.h" | 12 #include "remoting/base/constants.h" |
| 14 #include "remoting/proto/control.pb.h" | 13 #include "remoting/proto/control.pb.h" |
| 15 #include "remoting/proto/internal.pb.h" | 14 #include "remoting/proto/internal.pb.h" |
| 16 #include "remoting/protocol/client_stub.h" | 15 #include "remoting/protocol/client_stub.h" |
| 17 #include "remoting/protocol/message_serialization.h" | 16 #include "remoting/protocol/message_serialization.h" |
| 18 | 17 |
| 19 namespace remoting { | 18 namespace remoting { |
| 20 namespace protocol { | 19 namespace protocol { |
| 21 | 20 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 57 } |
| 59 | 58 |
| 60 } // namespace | 59 } // namespace |
| 61 | 60 |
| 62 ClientControlDispatcher::ClientControlDispatcher() | 61 ClientControlDispatcher::ClientControlDispatcher() |
| 63 : ChannelDispatcherBase(kControlChannelName), | 62 : ChannelDispatcherBase(kControlChannelName), |
| 64 client_stub_(nullptr), | 63 client_stub_(nullptr), |
| 65 clipboard_stub_(nullptr), | 64 clipboard_stub_(nullptr), |
| 66 parser_(base::Bind(&ClientControlDispatcher::OnMessageReceived, | 65 parser_(base::Bind(&ClientControlDispatcher::OnMessageReceived, |
| 67 base::Unretained(this)), | 66 base::Unretained(this)), |
| 68 reader()) { | 67 reader()) {} |
| 69 } | |
| 70 | 68 |
| 71 ClientControlDispatcher::~ClientControlDispatcher() { | 69 ClientControlDispatcher::~ClientControlDispatcher() {} |
| 72 } | |
| 73 | 70 |
| 74 void ClientControlDispatcher::InjectClipboardEvent( | 71 void ClientControlDispatcher::InjectClipboardEvent( |
| 75 const ClipboardEvent& event) { | 72 const ClipboardEvent& event) { |
| 76 ControlMessage message; | 73 ControlMessage message; |
| 77 message.mutable_clipboard_event()->CopyFrom(event); | 74 message.mutable_clipboard_event()->CopyFrom(event); |
| 78 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); | 75 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); |
| 79 } | 76 } |
| 80 | 77 |
| 81 void ClientControlDispatcher::NotifyClientResolution( | 78 void ClientControlDispatcher::NotifyClientResolution( |
| 82 const ClientResolution& resolution) { | 79 const ClientResolution& resolution) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 112 } | 109 } |
| 113 | 110 |
| 114 void ClientControlDispatcher::DeliverClientMessage( | 111 void ClientControlDispatcher::DeliverClientMessage( |
| 115 const ExtensionMessage& message) { | 112 const ExtensionMessage& message) { |
| 116 ControlMessage control_message; | 113 ControlMessage control_message; |
| 117 control_message.mutable_extension_message()->CopyFrom(message); | 114 control_message.mutable_extension_message()->CopyFrom(message); |
| 118 writer()->Write(SerializeAndFrameMessage(control_message), base::Closure()); | 115 writer()->Write(SerializeAndFrameMessage(control_message), base::Closure()); |
| 119 } | 116 } |
| 120 | 117 |
| 121 void ClientControlDispatcher::OnMessageReceived( | 118 void ClientControlDispatcher::OnMessageReceived( |
| 122 scoped_ptr<ControlMessage> message, | 119 scoped_ptr<ControlMessage> message) { |
| 123 const base::Closure& done_task) { | |
| 124 DCHECK(client_stub_); | 120 DCHECK(client_stub_); |
| 125 DCHECK(clipboard_stub_); | 121 DCHECK(clipboard_stub_); |
| 126 base::ScopedClosureRunner done_runner(done_task); | |
| 127 | 122 |
| 128 if (message->has_clipboard_event()) { | 123 if (message->has_clipboard_event()) { |
| 129 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); | 124 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); |
| 130 } else if (message->has_capabilities()) { | 125 } else if (message->has_capabilities()) { |
| 131 client_stub_->SetCapabilities(message->capabilities()); | 126 client_stub_->SetCapabilities(message->capabilities()); |
| 132 } else if (message->has_cursor_shape()) { | 127 } else if (message->has_cursor_shape()) { |
| 133 if (CursorShapeIsValid(message->cursor_shape())) | 128 if (CursorShapeIsValid(message->cursor_shape())) |
| 134 client_stub_->SetCursorShape(message->cursor_shape()); | 129 client_stub_->SetCursorShape(message->cursor_shape()); |
| 135 } else if (message->has_pairing_response()) { | 130 } else if (message->has_pairing_response()) { |
| 136 client_stub_->SetPairingResponse(message->pairing_response()); | 131 client_stub_->SetPairingResponse(message->pairing_response()); |
| 137 } else if (message->has_extension_message()) { | 132 } else if (message->has_extension_message()) { |
| 138 client_stub_->DeliverHostMessage(message->extension_message()); | 133 client_stub_->DeliverHostMessage(message->extension_message()); |
| 139 } else { | 134 } else { |
| 140 LOG(WARNING) << "Unknown control message received."; | 135 LOG(WARNING) << "Unknown control message received."; |
| 141 } | 136 } |
| 142 } | 137 } |
| 143 | 138 |
| 144 } // namespace protocol | 139 } // namespace protocol |
| 145 } // namespace remoting | 140 } // namespace remoting |
| OLD | NEW |