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_event_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 HostEventDispatcher::HostEventDispatcher() | |
16 : input_stub_(NULL) { | |
17 } | |
18 | |
19 HostEventDispatcher::~HostEventDispatcher() { | |
20 } | |
21 | |
22 void HostEventDispatcher::Init(Session* session) { | |
23 DCHECK(session); | |
24 reader_.Init(session->event_channel(), base::Bind( | |
25 &HostEventDispatcher::OnMessageReceived, base::Unretained(this))); | |
26 } | |
27 | |
28 void HostEventDispatcher::OnMessageReceived( | |
29 EventMessage* message, const base::Closure& done_task) { | |
30 DCHECK(input_stub_); | |
31 | |
32 base::ScopedClosureRunner done_runner(done_task); | |
33 | |
34 sequence_number_callback_.Run(message->sequence_number()); | |
35 | |
36 if (message->has_key_event()) { | |
37 const KeyEvent& event = message->key_event(); | |
38 if (event.has_keycode() && event.has_pressed()) { | |
39 input_stub_->InjectKeyEvent(event); | |
Wez
2011/11/17 22:25:16
Is there a risk that InjectKeyEvent() triggers a t
Sergey Ulanov
2011/11/17 22:41:39
I don't think so.
| |
40 } else { | |
41 LOG(WARNING) << "Received invalid key event."; | |
42 } | |
43 } else if (message->has_mouse_event()) { | |
44 input_stub_->InjectMouseEvent(message->mouse_event()); | |
45 return; | |
Wez
2011/11/17 22:25:16
nit: Lose the return?
Sergey Ulanov
2011/11/17 22:41:39
Done.
| |
46 } else { | |
47 LOG(WARNING) << "Unknown event message received."; | |
48 } | |
49 } | |
50 | |
51 } // namespace protocol | |
52 } // namespace remoting | |
OLD | NEW |