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

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

Issue 1649063003: Add MessagePipe interface. Use it in ChannelDispatcherBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_parser
Patch Set: Created 4 years, 10 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/client_event_dispatcher.h" 5 #include "remoting/protocol/client_event_dispatcher.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "net/socket/stream_socket.h" 8 #include "net/socket/stream_socket.h"
9 #include "remoting/base/compound_buffer.h"
9 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
10 #include "remoting/proto/event.pb.h" 11 #include "remoting/proto/event.pb.h"
11 #include "remoting/proto/internal.pb.h" 12 #include "remoting/proto/internal.pb.h"
12 #include "remoting/protocol/message_serialization.h" 13 #include "remoting/protocol/message_pipe.h"
13 14
14 namespace remoting { 15 namespace remoting {
15 namespace protocol { 16 namespace protocol {
16 17
17 ClientEventDispatcher::ClientEventDispatcher() 18 ClientEventDispatcher::ClientEventDispatcher()
18 : ChannelDispatcherBase(kEventChannelName) { 19 : ChannelDispatcherBase(kEventChannelName) {}
19 } 20 ClientEventDispatcher::~ClientEventDispatcher() {}
20
21 ClientEventDispatcher::~ClientEventDispatcher() {
22 }
23 21
24 void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) { 22 void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
25 DCHECK(event.has_usb_keycode()); 23 DCHECK(event.has_usb_keycode());
26 DCHECK(event.has_pressed()); 24 DCHECK(event.has_pressed());
27 EventMessage message; 25 EventMessage message;
28 message.set_timestamp(base::TimeTicks::Now().ToInternalValue()); 26 message.set_timestamp(base::TimeTicks::Now().ToInternalValue());
29 message.mutable_key_event()->CopyFrom(event); 27 message.mutable_key_event()->CopyFrom(event);
30 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 28 message_pipe()->Send(&message, base::Closure());
31 } 29 }
32 30
33 void ClientEventDispatcher::InjectTextEvent(const TextEvent& event) { 31 void ClientEventDispatcher::InjectTextEvent(const TextEvent& event) {
34 DCHECK(event.has_text()); 32 DCHECK(event.has_text());
35 EventMessage message; 33 EventMessage message;
36 message.set_timestamp(base::TimeTicks::Now().ToInternalValue()); 34 message.set_timestamp(base::TimeTicks::Now().ToInternalValue());
37 message.mutable_text_event()->CopyFrom(event); 35 message.mutable_text_event()->CopyFrom(event);
38 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 36 message_pipe()->Send(&message, base::Closure());
39 } 37 }
40 38
41 void ClientEventDispatcher::InjectMouseEvent(const MouseEvent& event) { 39 void ClientEventDispatcher::InjectMouseEvent(const MouseEvent& event) {
42 EventMessage message; 40 EventMessage message;
43 message.set_timestamp(base::TimeTicks::Now().ToInternalValue()); 41 message.set_timestamp(base::TimeTicks::Now().ToInternalValue());
44 message.mutable_mouse_event()->CopyFrom(event); 42 message.mutable_mouse_event()->CopyFrom(event);
45 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 43 message_pipe()->Send(&message, base::Closure());
46 } 44 }
47 45
48 void ClientEventDispatcher::InjectTouchEvent(const TouchEvent& event) { 46 void ClientEventDispatcher::InjectTouchEvent(const TouchEvent& event) {
49 EventMessage message; 47 EventMessage message;
50 message.set_timestamp(base::TimeTicks::Now().ToInternalValue()); 48 message.set_timestamp(base::TimeTicks::Now().ToInternalValue());
51 message.mutable_touch_event()->CopyFrom(event); 49 message.mutable_touch_event()->CopyFrom(event);
52 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 50 message_pipe()->Send(&message, base::Closure());
53 } 51 }
54 52
55 void ClientEventDispatcher::OnIncomingMessage( 53 void ClientEventDispatcher::OnIncomingMessage(
56 scoped_ptr<CompoundBuffer> message) { 54 scoped_ptr<CompoundBuffer> message) {
57 LOG(ERROR) << "Received unexpected message on the event channel."; 55 LOG(ERROR) << "Received unexpected message on the event channel.";
58 } 56 }
59 57
60 } // namespace protocol 58 } // namespace protocol
61 } // namespace remoting 59 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/client_control_dispatcher.cc ('k') | remoting/protocol/client_video_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698