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

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

Issue 8587053: Remove event_channel() and control_channel() from Session interface. (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
OLDNEW
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 "net/socket/stream_socket.h"
8 #include "remoting/base/constants.h"
7 #include "remoting/proto/event.pb.h" 9 #include "remoting/proto/event.pb.h"
8 #include "remoting/proto/internal.pb.h" 10 #include "remoting/proto/internal.pb.h"
9 #include "remoting/protocol/input_stub.h" 11 #include "remoting/protocol/input_stub.h"
10 #include "remoting/protocol/session.h"
11 12
12 namespace remoting { 13 namespace remoting {
13 namespace protocol { 14 namespace protocol {
14 15
15 HostEventDispatcher::HostEventDispatcher() 16 HostEventDispatcher::HostEventDispatcher()
16 : input_stub_(NULL) { 17 : ChannelDispatcherBase(kEventChannelName),
18 input_stub_(NULL) {
17 } 19 }
18 20
19 HostEventDispatcher::~HostEventDispatcher() { 21 HostEventDispatcher::~HostEventDispatcher() {
20 } 22 }
21 23
22 void HostEventDispatcher::Init(Session* session) { 24 void HostEventDispatcher::OnInitialized() {
23 DCHECK(session); 25 reader_.Init(channel(), base::Bind(
24 reader_.Init(session->event_channel(), base::Bind(
25 &HostEventDispatcher::OnMessageReceived, base::Unretained(this))); 26 &HostEventDispatcher::OnMessageReceived, base::Unretained(this)));
26 } 27 }
27 28
28 void HostEventDispatcher::OnMessageReceived( 29 void HostEventDispatcher::OnMessageReceived(
29 EventMessage* message, const base::Closure& done_task) { 30 EventMessage* message, const base::Closure& done_task) {
30 DCHECK(input_stub_); 31 DCHECK(input_stub_);
31 32
32 base::ScopedClosureRunner done_runner(done_task); 33 base::ScopedClosureRunner done_runner(done_task);
33 34
34 sequence_number_callback_.Run(message->sequence_number()); 35 sequence_number_callback_.Run(message->sequence_number());
35 36
36 if (message->has_key_event()) { 37 if (message->has_key_event()) {
37 const KeyEvent& event = message->key_event(); 38 const KeyEvent& event = message->key_event();
38 if (event.has_keycode() && event.has_pressed()) { 39 if (event.has_keycode() && event.has_pressed()) {
39 input_stub_->InjectKeyEvent(event); 40 input_stub_->InjectKeyEvent(event);
40 } else { 41 } else {
41 LOG(WARNING) << "Received invalid key event."; 42 LOG(WARNING) << "Received invalid key event.";
42 } 43 }
43 } else if (message->has_mouse_event()) { 44 } else if (message->has_mouse_event()) {
44 input_stub_->InjectMouseEvent(message->mouse_event()); 45 input_stub_->InjectMouseEvent(message->mouse_event());
45 } else { 46 } else {
46 LOG(WARNING) << "Unknown event message received."; 47 LOG(WARNING) << "Unknown event message received.";
47 } 48 }
48 } 49 }
49 50
50 } // namespace protocol 51 } // namespace protocol
51 } // namespace remoting 52 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698