Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/protocol/host_input_dispatcher.h" | |
| 6 | |
| 7 #include "remoting/proto/event.pb.h" | |
| 8 #include "remoting/proto/internal.pb.h" | |
| 9 #include "remoting/protocol/input_stub.h" | |
| 10 #include "remoting/protocol/session.h" | |
| 11 | |
| 12 namespace remoting { | |
| 13 namespace protocol { | |
| 14 | |
| 15 HostInputDispatcher::HostInputDispatcher() | |
| 16 : input_stub_(NULL) { | |
| 17 } | |
| 18 | |
| 19 HostInputDispatcher::~HostInputDispatcher() { | |
| 20 } | |
| 21 | |
| 22 void HostInputDispatcher::Init( | |
| 23 Session* session, | |
| 24 InputStub* input_stub, | |
| 25 const SequenceNumberCallback& seq_num_callback) { | |
| 26 DCHECK(session); | |
| 27 DCHECK(input_stub); | |
| 28 | |
| 29 input_stub_ = input_stub; | |
| 30 seq_num_callback_ = seq_num_callback; | |
| 31 | |
| 32 reader_.Init(session->event_channel(), base::Bind( | |
| 33 &HostInputDispatcher::OnMessageReceived, base::Unretained(this))); | |
| 34 } | |
| 35 | |
| 36 void HostInputDispatcher::OnMessageReceived( | |
| 37 EventMessage* message, const base::Closure& done_task) { | |
| 38 base::ScopedClosureRunner done_runner(done_task); | |
| 39 | |
| 40 seq_num_callback_.Run(message->sequence_number()); | |
| 41 | |
| 42 if (message->has_key_event()) { | |
| 43 const KeyEvent& event = message->key_event(); | |
| 44 if (event.has_keycode() && event.has_pressed()) { | |
| 45 input_stub_->InjectKeyEvent(event); | |
| 46 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.
| |
| 47 } | |
| 48 } else if (message->has_mouse_event()) { | |
| 49 input_stub_->InjectMouseEvent(message->mouse_event()); | |
| 50 return; | |
| 51 } | |
| 52 | |
| 53 LOG(WARNING) << "Unknown event message received."; | |
| 54 } | |
| 55 | |
| 56 void HostInputDispatcher::Close() { | |
| 57 } | |
| 58 | |
| 59 } // namespace protocol | |
| 60 } // namespace remoting | |
| OLD | NEW |