dbus: Property<>.value() should be const
[chromium-blink-merge.git] / remoting / protocol / client_event_dispatcher.cc
blobc0da8373f2cdcf2e8cf08aa8149e35b3edcbd1cf
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.
5 #include "remoting/protocol/client_event_dispatcher.h"
7 #include "base/message_loop_proxy.h"
8 #include "base/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/buffered_socket_writer.h"
14 #include "remoting/protocol/util.h"
16 namespace remoting {
17 namespace protocol {
19 ClientEventDispatcher::ClientEventDispatcher()
20 : ChannelDispatcherBase(kEventChannelName),
21 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) {
24 ClientEventDispatcher::~ClientEventDispatcher() {
25 writer_->Close();
28 void ClientEventDispatcher::OnInitialized() {
29 // TODO(garykac): Set write failed callback.
30 writer_->Init(channel(),
31 BufferedSocketWriter::WriteFailedCallback());
34 void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
35 EventMessage message;
36 message.set_sequence_number(base::Time::Now().ToInternalValue());
37 message.mutable_key_event()->CopyFrom(event);
38 writer_->Write(SerializeAndFrameMessage(message), base::Closure());
41 void ClientEventDispatcher::InjectMouseEvent(const MouseEvent& event) {
42 EventMessage message;
43 message.set_sequence_number(base::Time::Now().ToInternalValue());
44 message.mutable_mouse_event()->CopyFrom(event);
45 writer_->Write(SerializeAndFrameMessage(message), base::Closure());
48 } // namespace protocol
49 } // namespace remoting