| OLD | NEW |
| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 class Socket; | 23 class Socket; |
| 24 } // namespace net | 24 } // namespace net |
| 25 | 25 |
| 26 namespace remoting { | 26 namespace remoting { |
| 27 namespace protocol { | 27 namespace protocol { |
| 28 | 28 |
| 29 class BufferedSocketWriter; | 29 class BufferedSocketWriter; |
| 30 | 30 |
| 31 // 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 |
| 33 // other thread. |
| 31 class InputSender : public InputStub { | 34 class InputSender : public InputStub { |
| 32 public: | 35 public: |
| 33 // Create a stub using a socket. | 36 // Create a stub using a socket. |
| 34 explicit InputSender(net::Socket* socket); | 37 explicit InputSender(net::Socket* socket); |
| 35 virtual ~InputSender(); | 38 virtual ~InputSender(); |
| 36 | 39 |
| 37 // InputStub implementation. | 40 // InputStub implementation. |
| 38 virtual void InjectKeyEvent(const KeyEvent* event, Task* done); | 41 virtual void InjectKeyEvent(const KeyEvent* event, Task* done); |
| 39 virtual void InjectMouseEvent(const MouseEvent* event, Task* done); | 42 virtual void InjectMouseEvent(const MouseEvent* event, Task* done); |
| 40 | 43 |
| 44 // Stop writing. Must be called on the network thread when the |
| 45 // underlying socket is being destroyed. |
| 46 void Close(); |
| 47 |
| 41 private: | 48 private: |
| 42 // Helper method to run the task and delete it afterwards. | 49 // Helper method to run the task and delete it afterwards. |
| 43 void RunTask(Task* done); | 50 void RunTask(Task* done); |
| 44 | 51 |
| 45 // Buffered socket writer holds the serialized message and sends it on the | 52 // Buffered socket writer holds the serialized message and sends it on the |
| 46 // right thread. | 53 // right thread. |
| 47 scoped_refptr<BufferedSocketWriter> buffered_writer_; | 54 scoped_refptr<BufferedSocketWriter> buffered_writer_; |
| 48 | 55 |
| 49 DISALLOW_COPY_AND_ASSIGN(InputSender); | 56 DISALLOW_COPY_AND_ASSIGN(InputSender); |
| 50 }; | 57 }; |
| 51 | 58 |
| 52 } // namespace protocol | 59 } // namespace protocol |
| 53 } // namespace remoting | 60 } // namespace remoting |
| 54 | 61 |
| 55 #endif // REMOTING_PROTOCOL_INPUT_SENDER_H_ | 62 #endif // REMOTING_PROTOCOL_INPUT_SENDER_H_ |
| OLD | NEW |