Re-land: C++ readability review
[chromium-blink-merge.git] / remoting / protocol / client_event_dispatcher.cc
blob43507468b8a4641b8c3ba5d96ffbd312201d8b1b
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
3 // found in the LICENSE file.
5 #include "remoting/protocol/client_event_dispatcher.h"
7 #include "base/message_loop/message_loop_proxy.h"
8 #include "base/time/time.h"
9 #include "net/socket/stream_socket.h"
10 #include "remoting/base/constants.h"
11 #include "remoting/proto/event.pb.h"
12 #include "remoting/proto/internal.pb.h"
13 #include "remoting/protocol/message_serialization.h"
15 namespace remoting {
16 namespace protocol {
18 ClientEventDispatcher::ClientEventDispatcher()
19 : ChannelDispatcherBase(kEventChannelName) {
22 ClientEventDispatcher::~ClientEventDispatcher() {
25 void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
26 DCHECK(event.has_usb_keycode());
27 DCHECK(event.has_pressed());
28 EventMessage message;
29 message.set_timestamp(base::Time::Now().ToInternalValue());
30 message.mutable_key_event()->CopyFrom(event);
31 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
34 void ClientEventDispatcher::InjectTextEvent(const TextEvent& event) {
35 DCHECK(event.has_text());
36 EventMessage message;
37 message.set_timestamp(base::Time::Now().ToInternalValue());
38 message.mutable_text_event()->CopyFrom(event);
39 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
42 void ClientEventDispatcher::InjectMouseEvent(const MouseEvent& event) {
43 EventMessage message;
44 message.set_timestamp(base::Time::Now().ToInternalValue());
45 message.mutable_mouse_event()->CopyFrom(event);
46 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
49 void ClientEventDispatcher::InjectTouchEvent(const TouchEvent& event) {
50 EventMessage message;
51 message.set_timestamp(base::Time::Now().ToInternalValue());
52 message.mutable_touch_event()->CopyFrom(event);
53 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
56 } // namespace protocol
57 } // namespace remoting