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