| 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 // This file should only be included by remoting/protocol/jingle_session.cc. | |
| 6 | |
| 7 #ifndef REMOTING_PROTOCOL_SOCKET_WRAPPER_H_ | |
| 8 #define REMOTING_PROTOCOL_SOCKET_WRAPPER_H_ | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "net/socket/socket.h" | |
| 12 | |
| 13 namespace remoting { | |
| 14 namespace protocol { | |
| 15 | |
| 16 // This class is used only to wrap over SSL sockets in JingleSession. | |
| 17 // There is a strong assumption in Chromium's code that sockets are used and | |
| 18 // destroyed on the same thread. However in remoting code we may destroy | |
| 19 // sockets on other thread. A wrapper is added between JingleSession and | |
| 20 // SSL sockets so we can destroy SSL sockets and still maintain valid | |
| 21 // references. | |
| 22 class SocketWrapper : public net::Socket { | |
| 23 public: | |
| 24 SocketWrapper(net::Socket* socket); | |
| 25 virtual ~SocketWrapper(); | |
| 26 | |
| 27 // net::Socket implementation. | |
| 28 virtual int Read(net::IOBuffer* buf, int buf_len, | |
| 29 net::CompletionCallback* callback); | |
| 30 virtual int Write(net::IOBuffer* buf, int buf_len, | |
| 31 net::CompletionCallback* callback); | |
| 32 virtual bool SetReceiveBufferSize(int32 size); | |
| 33 virtual bool SetSendBufferSize(int32 size); | |
| 34 | |
| 35 // Method to allow us to destroy the internal socket. This method must be | |
| 36 // called before SocketWrapper is destroyed. | |
| 37 // | |
| 38 // This method must be called on the same thread where this object is | |
| 39 // created. | |
| 40 void Disconnect(); | |
| 41 | |
| 42 private: | |
| 43 // The internal socket. | |
| 44 scoped_ptr<net::Socket> socket_; | |
| 45 | |
| 46 DISALLOW_COPY_AND_ASSIGN(SocketWrapper); | |
| 47 }; | |
| 48 | |
| 49 } // namespace protocol | |
| 50 } // namespace remoting | |
| 51 | |
| 52 #endif // REMOTING_PROTOCOL_SOCKET_WRAPPER_H_ | |
| OLD | NEW |