Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "remoting/protocol/client_input_dispatcher.h" | |
| 6 | |
| 7 #include "base/time.h" | |
| 8 #include "remoting/proto/event.pb.h" | |
| 9 #include "remoting/proto/internal.pb.h" | |
| 10 #include "remoting/protocol/buffered_socket_writer.h" | |
| 11 #include "remoting/protocol/session.h" | |
| 12 #include "remoting/protocol/util.h" | |
| 13 | |
| 14 namespace remoting { | |
| 15 namespace protocol { | |
| 16 | |
| 17 ClientInputDispatcher::ClientInputDispatcher( | |
| 18 base::MessageLoopProxy* message_loop) | |
| 19 : writer_(new BufferedSocketWriter(message_loop)) { | |
| 20 } | |
| 21 | |
| 22 ClientInputDispatcher::~ClientInputDispatcher() { | |
| 23 Close(); | |
| 24 } | |
| 25 | |
| 26 void ClientInputDispatcher::Init(Session* session) { | |
| 27 DCHECK(session); | |
| 28 | |
| 29 // TODO(garykac) Set write failed callback. | |
|
Wez
2011/11/17 01:51:56
This TODO applies equally to the ClientControlDisp
Sergey Ulanov
2011/11/17 19:29:06
Done.
| |
| 30 writer_->Init(session->event_channel(), | |
| 31 BufferedSocketWriter::WriteFailedCallback()); | |
| 32 } | |
| 33 | |
| 34 void ClientInputDispatcher::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()); | |
| 39 } | |
| 40 | |
| 41 void ClientInputDispatcher::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()); | |
| 46 } | |
| 47 | |
| 48 void ClientInputDispatcher::Close() { | |
| 49 writer_->Close(); | |
|
Wez
2011/11/17 01:51:56
Fold this into dtor?
Sergey Ulanov
2011/11/17 19:29:06
Done.
| |
| 50 } | |
| 51 | |
| 52 } // namespace protocol | |
| 53 } // namespace remoting | |
| OLD | NEW |