| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_event_dispatcher.h" | 5 #include "remoting/protocol/host_event_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "net/socket/stream_socket.h" | 8 #include "net/socket/stream_socket.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/proto/event.pb.h" | 10 #include "remoting/proto/event.pb.h" |
| 11 #include "remoting/proto/internal.pb.h" | 11 #include "remoting/proto/internal.pb.h" |
| 12 #include "remoting/protocol/clipboard_stub.h" |
| 12 #include "remoting/protocol/input_stub.h" | 13 #include "remoting/protocol/input_stub.h" |
| 13 | 14 |
| 14 namespace remoting { | 15 namespace remoting { |
| 15 namespace protocol { | 16 namespace protocol { |
| 16 | 17 |
| 17 HostEventDispatcher::HostEventDispatcher() | 18 HostEventDispatcher::HostEventDispatcher() |
| 18 : ChannelDispatcherBase(kEventChannelName), | 19 : ChannelDispatcherBase(kEventChannelName), |
| 20 clipboard_stub_(NULL), |
| 19 input_stub_(NULL) { | 21 input_stub_(NULL) { |
| 20 } | 22 } |
| 21 | 23 |
| 22 HostEventDispatcher::~HostEventDispatcher() { | 24 HostEventDispatcher::~HostEventDispatcher() { |
| 23 } | 25 } |
| 24 | 26 |
| 25 void HostEventDispatcher::OnInitialized() { | 27 void HostEventDispatcher::OnInitialized() { |
| 26 reader_.Init(channel(), base::Bind( | 28 reader_.Init(channel(), base::Bind( |
| 27 &HostEventDispatcher::OnMessageReceived, base::Unretained(this))); | 29 &HostEventDispatcher::OnMessageReceived, base::Unretained(this))); |
| 28 } | 30 } |
| 29 | 31 |
| 30 void HostEventDispatcher::OnMessageReceived( | 32 void HostEventDispatcher::OnMessageReceived( |
| 31 EventMessage* message, const base::Closure& done_task) { | 33 EventMessage* message, const base::Closure& done_task) { |
| 34 DCHECK(clipboard_stub_); |
| 32 DCHECK(input_stub_); | 35 DCHECK(input_stub_); |
| 33 | 36 |
| 34 base::ScopedClosureRunner done_runner(done_task); | 37 base::ScopedClosureRunner done_runner(done_task); |
| 35 | 38 |
| 36 sequence_number_callback_.Run(message->sequence_number()); | 39 sequence_number_callback_.Run(message->sequence_number()); |
| 37 | 40 |
| 38 if (message->has_key_event()) { | 41 if (message->has_key_event()) { |
| 39 const KeyEvent& event = message->key_event(); | 42 const KeyEvent& event = message->key_event(); |
| 40 if (event.has_keycode() && event.has_pressed()) { | 43 if (event.has_keycode() && event.has_pressed()) { |
| 41 input_stub_->InjectKeyEvent(event); | 44 input_stub_->InjectKeyEvent(event); |
| 42 } else { | 45 } else { |
| 43 LOG(WARNING) << "Received invalid key event."; | 46 LOG(WARNING) << "Received invalid key event."; |
| 44 } | 47 } |
| 45 } else if (message->has_mouse_event()) { | 48 } else if (message->has_mouse_event()) { |
| 46 input_stub_->InjectMouseEvent(message->mouse_event()); | 49 input_stub_->InjectMouseEvent(message->mouse_event()); |
| 50 } else if (message->has_clipboard_event()) { |
| 51 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); |
| 47 } else { | 52 } else { |
| 48 LOG(WARNING) << "Unknown event message received."; | 53 LOG(WARNING) << "Unknown event message received."; |
| 49 } | 54 } |
| 50 } | 55 } |
| 51 | 56 |
| 52 } // namespace protocol | 57 } // namespace protocol |
| 53 } // namespace remoting | 58 } // namespace remoting |
| OLD | NEW |