Use the appropriate variant of IntToString in //remoting
[chromium-blink-merge.git] / remoting / protocol / client_event_dispatcher.cc
blob4f1e51e42bd3826aae57a886e37c14ec130250fe
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/time/time.h"
8 #include "net/socket/stream_socket.h"
9 #include "remoting/base/constants.h"
10 #include "remoting/proto/event.pb.h"
11 #include "remoting/proto/internal.pb.h"
12 #include "remoting/protocol/message_serialization.h"
14 namespace remoting {
15 namespace protocol {
17 ClientEventDispatcher::ClientEventDispatcher()
18 : ChannelDispatcherBase(kEventChannelName) {
21 ClientEventDispatcher::~ClientEventDispatcher() {
24 void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
25 DCHECK(event.has_usb_keycode());
26 DCHECK(event.has_pressed());
27 EventMessage message;
28 message.set_timestamp(base::Time::Now().ToInternalValue());
29 message.mutable_key_event()->CopyFrom(event);
30 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
33 void ClientEventDispatcher::InjectTextEvent(const TextEvent& event) {
34 DCHECK(event.has_text());
35 EventMessage message;
36 message.set_timestamp(base::Time::Now().ToInternalValue());
37 message.mutable_text_event()->CopyFrom(event);
38 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
41 void ClientEventDispatcher::InjectMouseEvent(const MouseEvent& event) {
42 EventMessage message;
43 message.set_timestamp(base::Time::Now().ToInternalValue());
44 message.mutable_mouse_event()->CopyFrom(event);
45 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
48 void ClientEventDispatcher::InjectTouchEvent(const TouchEvent& event) {
49 EventMessage message;
50 message.set_timestamp(base::Time::Now().ToInternalValue());
51 message.mutable_touch_event()->CopyFrom(event);
52 writer()->Write(SerializeAndFrameMessage(message), base::Closure());
55 } // namespace protocol
56 } // namespace remoting