| 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/compound_buffer.h" |
| 10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void HostControlDispatcher::OnIncomingMessage( | 65 void HostControlDispatcher::OnIncomingMessage( |
| 66 std::unique_ptr<CompoundBuffer> buffer) { | 66 std::unique_ptr<CompoundBuffer> buffer) { |
| 67 DCHECK(clipboard_stub_); | 67 DCHECK(clipboard_stub_); |
| 68 DCHECK(host_stub_); | 68 DCHECK(host_stub_); |
| 69 | 69 |
| 70 std::unique_ptr<ControlMessage> message = | 70 std::unique_ptr<ControlMessage> message = |
| 71 ParseMessage<ControlMessage>(buffer.get()); | 71 ParseMessage<ControlMessage>(buffer.get()); |
| 72 if (!message) | 72 if (!message) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 // TODO(sergeyu): Move message valudation from the message handlers here. |
| 75 if (message->has_clipboard_event()) { | 76 if (message->has_clipboard_event()) { |
| 76 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); | 77 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); |
| 77 } else if (message->has_client_resolution()) { | 78 } else if (message->has_client_resolution()) { |
| 78 host_stub_->NotifyClientResolution(message->client_resolution()); | 79 const ClientResolution& resolution = message->client_resolution(); |
| 80 if (!resolution.has_dips_width() || !resolution.has_dips_height() || |
| 81 resolution.dips_width() <= 0 || resolution.dips_height() <= 0) { |
| 82 LOG(ERROR) << "Received invalid ClientResolution message."; |
| 83 return; |
| 84 } |
| 85 host_stub_->NotifyClientResolution(resolution); |
| 79 } else if (message->has_video_control()) { | 86 } else if (message->has_video_control()) { |
| 80 host_stub_->ControlVideo(message->video_control()); | 87 host_stub_->ControlVideo(message->video_control()); |
| 81 } else if (message->has_audio_control()) { | 88 } else if (message->has_audio_control()) { |
| 82 host_stub_->ControlAudio(message->audio_control()); | 89 host_stub_->ControlAudio(message->audio_control()); |
| 83 } else if (message->has_capabilities()) { | 90 } else if (message->has_capabilities()) { |
| 84 host_stub_->SetCapabilities(message->capabilities()); | 91 host_stub_->SetCapabilities(message->capabilities()); |
| 85 } else if (message->has_pairing_request()) { | 92 } else if (message->has_pairing_request()) { |
| 86 host_stub_->RequestPairing(message->pairing_request()); | 93 host_stub_->RequestPairing(message->pairing_request()); |
| 87 } else if (message->has_extension_message()) { | 94 } else if (message->has_extension_message()) { |
| 88 host_stub_->DeliverClientMessage(message->extension_message()); | 95 host_stub_->DeliverClientMessage(message->extension_message()); |
| 89 } else { | 96 } else { |
| 90 LOG(WARNING) << "Unknown control message received."; | 97 LOG(WARNING) << "Unknown control message received."; |
| 91 } | 98 } |
| 92 } | 99 } |
| 93 | 100 |
| 94 } // namespace protocol | 101 } // namespace protocol |
| 95 } // namespace remoting | 102 } // namespace remoting |
| OLD | NEW |