Index: remoting/protocol/host_input_dispatcher.cc |
diff --git a/remoting/protocol/host_input_dispatcher.cc b/remoting/protocol/host_input_dispatcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..935787194d8582203d07ce404c53b0a058b4a88d |
--- /dev/null |
+++ b/remoting/protocol/host_input_dispatcher.cc |
@@ -0,0 +1,60 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "remoting/protocol/host_input_dispatcher.h" |
+ |
+#include "remoting/proto/event.pb.h" |
+#include "remoting/proto/internal.pb.h" |
+#include "remoting/protocol/input_stub.h" |
+#include "remoting/protocol/session.h" |
+ |
+namespace remoting { |
+namespace protocol { |
+ |
+HostInputDispatcher::HostInputDispatcher() |
+ : input_stub_(NULL) { |
+} |
+ |
+HostInputDispatcher::~HostInputDispatcher() { |
+} |
+ |
+void HostInputDispatcher::Init( |
+ Session* session, |
+ InputStub* input_stub, |
+ const SequenceNumberCallback& seq_num_callback) { |
+ DCHECK(session); |
+ DCHECK(input_stub); |
+ |
+ input_stub_ = input_stub; |
+ seq_num_callback_ = seq_num_callback; |
+ |
+ reader_.Init(session->event_channel(), base::Bind( |
+ &HostInputDispatcher::OnMessageReceived, base::Unretained(this))); |
+} |
+ |
+void HostInputDispatcher::OnMessageReceived( |
+ EventMessage* message, const base::Closure& done_task) { |
+ base::ScopedClosureRunner done_runner(done_task); |
+ |
+ seq_num_callback_.Run(message->sequence_number()); |
+ |
+ if (message->has_key_event()) { |
+ const KeyEvent& event = message->key_event(); |
+ if (event.has_keycode() && event.has_pressed()) { |
+ input_stub_->InjectKeyEvent(event); |
+ return; |
Wez
2011/11/17 02:03:40
nit: The return strictly belongs in the scope of i
Sergey Ulanov
2011/11/17 18:38:14
Done.
|
+ } |
+ } else if (message->has_mouse_event()) { |
+ input_stub_->InjectMouseEvent(message->mouse_event()); |
+ return; |
+ } |
+ |
+ LOG(WARNING) << "Unknown event message received."; |
+} |
+ |
+void HostInputDispatcher::Close() { |
+} |
+ |
+} // namespace protocol |
+} // namespace remoting |