Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: remoting/protocol/host_event_dispatcher.cc

Issue 8468022: Refactor channel dispatchers on the host side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/host_event_dispatcher.h ('k') | remoting/protocol/host_message_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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);
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 } else {
46 LOG(WARNING) << "Unknown event message received.";
47 }
48 }
49
50 } // namespace protocol
51 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/host_event_dispatcher.h ('k') | remoting/protocol/host_message_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698