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

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

Issue 7799014: Fix stuck keys problem with Chromoting when host disconnects while keys are (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update copyright Created 9 years, 3 months 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/host/client_session.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This stub is thread safe because of the use of BufferedSocketWriter. 5 // This stub is thread safe because of the use of BufferedSocketWriter.
6 // BufferedSocketWriter buffers messages and send them on them right thread. 6 // BufferedSocketWriter buffers messages and send them on them right thread.
7 7
8 #include "remoting/protocol/input_sender.h" 8 #include "remoting/protocol/input_sender.h"
9 9
10 #include "base/task.h" 10 #include "base/task.h"
11 #include "remoting/proto/event.pb.h" 11 #include "remoting/proto/event.pb.h"
12 #include "remoting/proto/internal.pb.h" 12 #include "remoting/proto/internal.pb.h"
13 #include "remoting/protocol/buffered_socket_writer.h" 13 #include "remoting/protocol/buffered_socket_writer.h"
14 #include "remoting/protocol/util.h" 14 #include "remoting/protocol/util.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 namespace protocol { 17 namespace protocol {
18 18
19 InputSender::InputSender(base::MessageLoopProxy* message_loop, 19 InputSender::InputSender(base::MessageLoopProxy* message_loop,
20 net::Socket* socket) 20 net::Socket* socket)
21 : buffered_writer_(new BufferedSocketWriter(message_loop)) { 21 : buffered_writer_(new BufferedSocketWriter(message_loop)) {
22 // TODO(garykac) Set write failed callback. 22 // TODO(garykac) Set write failed callback.
23 DCHECK(socket); 23 DCHECK(socket);
24 buffered_writer_->Init(socket, NULL); 24 buffered_writer_->Init(socket, NULL);
25 } 25 }
26 26
27 InputSender::~InputSender() { 27 InputSender::~InputSender() {
28 } 28 }
29 29
30 void InputSender::InjectKeyEvent(const KeyEvent* event, Task* done) { 30 void InputSender::InjectKeyEvent(const KeyEvent* event, Task* done) {
31 DCHECK(done);
32
31 EventMessage message; 33 EventMessage message;
32 message.set_sequence_number(base::Time::Now().ToInternalValue()); 34 message.set_sequence_number(base::Time::Now().ToInternalValue());
33 message.mutable_key_event()->CopyFrom(*event); 35 message.mutable_key_event()->CopyFrom(*event);
34 buffered_writer_->Write(SerializeAndFrameMessage(message), done); 36 buffered_writer_->Write(SerializeAndFrameMessage(message), done);
35 } 37 }
36 38
37 void InputSender::InjectMouseEvent(const MouseEvent* event, Task* done) { 39 void InputSender::InjectMouseEvent(const MouseEvent* event, Task* done) {
40 DCHECK(done);
41
38 EventMessage message; 42 EventMessage message;
39 message.set_sequence_number(base::Time::Now().ToInternalValue()); 43 message.set_sequence_number(base::Time::Now().ToInternalValue());
40 message.mutable_mouse_event()->CopyFrom(*event); 44 message.mutable_mouse_event()->CopyFrom(*event);
41 buffered_writer_->Write(SerializeAndFrameMessage(message), done); 45 buffered_writer_->Write(SerializeAndFrameMessage(message), done);
42 } 46 }
43 47
44 void InputSender::Close() { 48 void InputSender::Close() {
45 buffered_writer_->Close(); 49 buffered_writer_->Close();
46 } 50 }
47 51
48 } // namespace protocol 52 } // namespace protocol
49 } // namespace remoting 53 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698