| 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 HostStub using sockets created from jingle connection. | 5 // Implementation of HostStub 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. | 10 // This class can be used on any thread. |
| 11 | 11 |
| 12 #ifndef REMOTING_PROTOCOL_HOST_STUB_IMPL_H_ | 12 #ifndef REMOTING_PROTOCOL_HOST_STUB_IMPL_H_ |
| 13 #define REMOTING_PROTOCOL_HOST_STUB_IMPL_H_ | 13 #define REMOTING_PROTOCOL_HOST_STUB_IMPL_H_ |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/callback.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "remoting/protocol/host_stub.h" | 18 #include "remoting/protocol/host_stub.h" |
| 18 | 19 |
| 19 class Task; | |
| 20 | |
| 21 namespace base { | 20 namespace base { |
| 22 class MessageLoopProxy; | 21 class MessageLoopProxy; |
| 23 } // namespace base | 22 } // namespace base |
| 24 | 23 |
| 25 namespace net { | 24 namespace net { |
| 26 class Socket; | 25 class Socket; |
| 27 } // namespace net | 26 } // namespace net |
| 28 | 27 |
| 29 namespace remoting { | 28 namespace remoting { |
| 30 namespace protocol { | 29 namespace protocol { |
| 31 | 30 |
| 32 class BufferedSocketWriter; | 31 class BufferedSocketWriter; |
| 33 | 32 |
| 34 // Implementation of HostStub that sends commands on a socket. Must be | 33 // Implementation of HostStub that sends commands on a socket. Must be |
| 35 // created and closed on the network thread, but can be used on any | 34 // created and closed on the network thread, but can be used on any |
| 36 // other thread. | 35 // other thread. |
| 37 class HostControlSender : public HostStub { | 36 class HostControlSender : public HostStub { |
| 38 public: | 37 public: |
| 39 explicit HostControlSender(base::MessageLoopProxy* message_loop, | 38 explicit HostControlSender(base::MessageLoopProxy* message_loop, |
| 40 net::Socket* socket); | 39 net::Socket* socket); |
| 41 virtual ~HostControlSender(); | 40 virtual ~HostControlSender(); |
| 42 | 41 |
| 43 virtual void BeginSessionRequest( | 42 virtual void BeginSessionRequest( |
| 44 const LocalLoginCredentials* credentials, Task* done); | 43 const LocalLoginCredentials* credentials, const base::Closure& done); |
| 45 | 44 |
| 46 // Stop writing. Must be called on the network thread when the | 45 // Stop writing. Must be called on the network thread when the |
| 47 // underlying socket is being destroyed. | 46 // underlying socket is being destroyed. |
| 48 void Close(); | 47 void Close(); |
| 49 | 48 |
| 50 private: | 49 private: |
| 51 // Buffered socket writer holds the serialized message and send it on the | 50 // Buffered socket writer holds the serialized message and send it on the |
| 52 // right thread. | 51 // right thread. |
| 53 scoped_refptr<BufferedSocketWriter> buffered_writer_; | 52 scoped_refptr<BufferedSocketWriter> buffered_writer_; |
| 54 | 53 |
| 55 DISALLOW_COPY_AND_ASSIGN(HostControlSender); | 54 DISALLOW_COPY_AND_ASSIGN(HostControlSender); |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 } // namespace protocol | 57 } // namespace protocol |
| 59 } // namespace remoting | 58 } // namespace remoting |
| 60 | 59 |
| 61 #endif // REMOTING_PROTOCOL_HOST_STUB_IMPL_H_ | 60 #endif // REMOTING_PROTOCOL_HOST_STUB_IMPL_H_ |
| OLD | NEW |