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

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

Issue 8574025: Refactor client channel dispatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/input_sender.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // This stub is thread safe because of the use of BufferedSocketWriter.
6 // BufferedSocketWriter buffers messages and send them on the right thread.
7
8 #include "remoting/protocol/input_sender.h"
9
10 #include "base/task.h"
11 #include "base/time.h"
12 #include "remoting/proto/event.pb.h"
13 #include "remoting/proto/internal.pb.h"
14 #include "remoting/protocol/buffered_socket_writer.h"
15 #include "remoting/protocol/util.h"
16
17 namespace remoting {
18 namespace protocol {
19
20 InputSender::InputSender(base::MessageLoopProxy* message_loop,
21 net::Socket* socket)
22 : buffered_writer_(new BufferedSocketWriter(message_loop)) {
23 // TODO(garykac) Set write failed callback.
24 DCHECK(socket);
25 buffered_writer_->Init(socket, BufferedSocketWriter::WriteFailedCallback());
26 }
27
28 InputSender::~InputSender() {
29 }
30
31 void InputSender::InjectKeyEvent(const KeyEvent& event) {
32 EventMessage message;
33 message.set_sequence_number(base::Time::Now().ToInternalValue());
34 message.mutable_key_event()->CopyFrom(event);
35 buffered_writer_->Write(SerializeAndFrameMessage(message), base::Closure());
36 }
37
38 void InputSender::InjectMouseEvent(const MouseEvent& event) {
39 EventMessage message;
40 message.set_sequence_number(base::Time::Now().ToInternalValue());
41 message.mutable_mouse_event()->CopyFrom(event);
42 buffered_writer_->Write(SerializeAndFrameMessage(message), base::Closure());
43 }
44
45 void InputSender::Close() {
46 buffered_writer_->Close();
47 }
48
49 } // namespace protocol
50 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/input_sender.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698