| 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 #ifndef JINGLE_GLUE_PSEUDOTCP_ADAPTER_H_ | 5 #ifndef JINGLE_GLUE_PSEUDOTCP_ADAPTER_H_ |
| 6 #define JINGLE_GLUE_PSEUDOTCP_ADAPTER_H_ | 6 #define JINGLE_GLUE_PSEUDOTCP_ADAPTER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // can be deleted during callbacks, while PseudoTcp cannot, the core of the | 22 // can be deleted during callbacks, while PseudoTcp cannot, the core of the |
| 23 // PseudoTcpAdapter is reference counted, with a reference held by the | 23 // PseudoTcpAdapter is reference counted, with a reference held by the |
| 24 // adapter, and an additional reference held on the stack during callbacks. | 24 // adapter, and an additional reference held on the stack during callbacks. |
| 25 class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe { | 25 class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe { |
| 26 public: | 26 public: |
| 27 // Creates an adapter for the supplied Socket. |socket| should already | 27 // Creates an adapter for the supplied Socket. |socket| should already |
| 28 // be ready for use, and ownership of it will be assumed by the adapter. | 28 // be ready for use, and ownership of it will be assumed by the adapter. |
| 29 PseudoTcpAdapter(net::Socket* socket); | 29 PseudoTcpAdapter(net::Socket* socket); |
| 30 virtual ~PseudoTcpAdapter(); | 30 virtual ~PseudoTcpAdapter(); |
| 31 | 31 |
| 32 // Sets callback that should be called when the adapter is being |
| 33 // destroyed. The callback is not allowed to touch the adapter, but |
| 34 // can do anything else. |
| 35 void SetOnDestroyedCallback(const base::Closure& callback); |
| 36 |
| 32 // net::Socket implementation. | 37 // net::Socket implementation. |
| 33 virtual int Read(net::IOBuffer* buffer, int buffer_size, | 38 virtual int Read(net::IOBuffer* buffer, int buffer_size, |
| 34 const net::CompletionCallback& callback) OVERRIDE; | 39 const net::CompletionCallback& callback) OVERRIDE; |
| 35 virtual int Write(net::IOBuffer* buffer, int buffer_size, | 40 virtual int Write(net::IOBuffer* buffer, int buffer_size, |
| 36 const net::CompletionCallback& callback) OVERRIDE; | 41 const net::CompletionCallback& callback) OVERRIDE; |
| 37 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; | 42 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; |
| 38 virtual bool SetSendBufferSize(int32 size) OVERRIDE; | 43 virtual bool SetSendBufferSize(int32 size) OVERRIDE; |
| 39 | 44 |
| 40 // net::StreamSocket implementation. | 45 // net::StreamSocket implementation. |
| 41 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; | 46 virtual int Connect(const net::CompletionCallback& callback) OVERRIDE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 | 59 |
| 55 // Set the delay for sending ACK. | 60 // Set the delay for sending ACK. |
| 56 void SetAckDelay(int delay_ms); | 61 void SetAckDelay(int delay_ms); |
| 57 | 62 |
| 58 // Set whether Nagle's algorithm is enabled. | 63 // Set whether Nagle's algorithm is enabled. |
| 59 void SetNoDelay(bool no_delay); | 64 void SetNoDelay(bool no_delay); |
| 60 | 65 |
| 61 private: | 66 private: |
| 62 class Core; | 67 class Core; |
| 63 | 68 |
| 69 base::Closure destruction_callback_; |
| 70 |
| 64 scoped_refptr<Core> core_; | 71 scoped_refptr<Core> core_; |
| 65 | 72 |
| 66 net::BoundNetLog net_log_; | 73 net::BoundNetLog net_log_; |
| 67 | 74 |
| 68 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); | 75 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); |
| 69 }; | 76 }; |
| 70 | 77 |
| 71 } // namespace jingle_glue | 78 } // namespace jingle_glue |
| 72 | 79 |
| 73 #endif // JINGLE_GLUE_STREAM_SOCKET_ADAPTER_H_ | 80 #endif // JINGLE_GLUE_STREAM_SOCKET_ADAPTER_H_ |
| OLD | NEW |