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 ClientStub using sockets created from jingle connection. | 5 // Implementation of ClientStub 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 ConnectionToClient. | 8 // Object of this class can only be created by ConnectionToClient. |
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_CLIENT_STUB_IMPL_H_ | 12 #ifndef REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_ |
13 #define REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_ | 13 #define REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_ |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "remoting/protocol/client_stub.h" | 18 #include "remoting/protocol/client_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 ClientStub that sends commands on a socket. Must | 35 // Implementation of ClientStub that sends commands 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 ClientControlSender : public ClientStub { | 38 class ClientControlSender : public ClientStub { |
35 public: | 39 public: |
36 explicit ClientControlSender(net::Socket* socket); | 40 explicit ClientControlSender(base::MessageLoopProxy* message_loop, |
| 41 net::Socket* socket); |
37 virtual ~ClientControlSender(); | 42 virtual ~ClientControlSender(); |
38 | 43 |
39 virtual void BeginSessionResponse(const LocalLoginStatus* msg, | 44 virtual void BeginSessionResponse(const LocalLoginStatus* msg, |
40 Task* done) OVERRIDE; | 45 Task* done) OVERRIDE; |
41 | 46 |
42 // Stop writing. Must be called on the network thread when the | 47 // Stop writing. Must be called on the network thread when the |
43 // underlying socket is being destroyed. | 48 // underlying socket is being destroyed. |
44 void Close(); | 49 void Close(); |
45 | 50 |
46 private: | 51 private: |
47 // Buffered socket writer holds the serialized message and send it on the | 52 // Buffered socket writer holds the serialized message and send it on the |
48 // right thread. | 53 // right thread. |
49 scoped_refptr<BufferedSocketWriter> buffered_writer_; | 54 scoped_refptr<BufferedSocketWriter> buffered_writer_; |
50 | 55 |
51 DISALLOW_COPY_AND_ASSIGN(ClientControlSender); | 56 DISALLOW_COPY_AND_ASSIGN(ClientControlSender); |
52 }; | 57 }; |
53 | 58 |
54 } // namespace protocol | 59 } // namespace protocol |
55 } // namespace remoting | 60 } // namespace remoting |
56 | 61 |
57 #endif // REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_ | 62 #endif // REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_ |
OLD | NEW |