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