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

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

Issue 7633009: Use MessageLoopProxy for network message loop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 4 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/protocol/host_message_dispatcher.h ('k') | remoting/protocol/input_sender.cc » ('j') | 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) 2011 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 // Implementation of InputStub using sockets created from jingle connection. 5 // Implementation of InputStub using sockets created from jingle connection.
6 // It sends messages through the socket after serializing it. 6 // It sends messages through the socket after serializing it.
7 // 7 //
8 // Object of this class can only be created by ConnectionToHost. 8 // Object of this class can only be created by ConnectionToHost.
9 // 9 //
10 // This class can be used on any thread. An object of socket is given to this 10 // This class can be used on any thread. An object of socket is given to this
11 // class, its lifetime is strictly greater than this object. 11 // class, its lifetime is strictly greater than this object.
12 12
13 #ifndef REMOTING_PROTOCOL_INPUT_SENDER_H_ 13 #ifndef REMOTING_PROTOCOL_INPUT_SENDER_H_
14 #define REMOTING_PROTOCOL_INPUT_SENDER_H_ 14 #define REMOTING_PROTOCOL_INPUT_SENDER_H_
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "remoting/protocol/input_stub.h" 18 #include "remoting/protocol/input_stub.h"
19 19
20 class Task; 20 class Task;
21 21
22 namespace base {
23 class MessageLoopProxy;
24 } // namespace base
25
22 namespace net { 26 namespace net {
23 class Socket; 27 class Socket;
24 } // namespace net 28 } // namespace net
25 29
26 namespace remoting { 30 namespace remoting {
27 namespace protocol { 31 namespace protocol {
28 32
29 class BufferedSocketWriter; 33 class BufferedSocketWriter;
30 34
31 // Implementation of InputStub that sends messages on a socket. Must 35 // Implementation of InputStub that sends messages on a socket. Must
32 // be created and closed on the network thread, but can be used on any 36 // be created and closed on the network thread, but can be used on any
33 // other thread. 37 // other thread.
34 class InputSender : public InputStub { 38 class InputSender : public InputStub {
35 public: 39 public:
36 // Create a stub using a socket. 40 // Create a stub using a socket.
37 explicit InputSender(net::Socket* socket); 41 explicit InputSender(base::MessageLoopProxy* message_loop,
42 net::Socket* socket);
38 virtual ~InputSender(); 43 virtual ~InputSender();
39 44
40 // InputStub implementation. 45 // InputStub implementation.
41 virtual void InjectKeyEvent(const KeyEvent* event, Task* done); 46 virtual void InjectKeyEvent(const KeyEvent* event, Task* done);
42 virtual void InjectMouseEvent(const MouseEvent* event, Task* done); 47 virtual void InjectMouseEvent(const MouseEvent* event, Task* done);
43 48
44 // Stop writing. Must be called on the network thread when the 49 // Stop writing. Must be called on the network thread when the
45 // underlying socket is being destroyed. 50 // underlying socket is being destroyed.
46 void Close(); 51 void Close();
47 52
48 private: 53 private:
49 // Helper method to run the task and delete it afterwards. 54 // Helper method to run the task and delete it afterwards.
50 void RunTask(Task* done); 55 void RunTask(Task* done);
51 56
52 // Buffered socket writer holds the serialized message and sends it on the 57 // Buffered socket writer holds the serialized message and sends it on the
53 // right thread. 58 // right thread.
54 scoped_refptr<BufferedSocketWriter> buffered_writer_; 59 scoped_refptr<BufferedSocketWriter> buffered_writer_;
55 60
56 DISALLOW_COPY_AND_ASSIGN(InputSender); 61 DISALLOW_COPY_AND_ASSIGN(InputSender);
57 }; 62 };
58 63
59 } // namespace protocol 64 } // namespace protocol
60 } // namespace remoting 65 } // namespace remoting
61 66
62 #endif // REMOTING_PROTOCOL_INPUT_SENDER_H_ 67 #endif // REMOTING_PROTOCOL_INPUT_SENDER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/host_message_dispatcher.h ('k') | remoting/protocol/input_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698