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 NET_SOCKET_SOCKET_H_ | 5 #ifndef NET_SOCKET_SOCKET_H_ |
6 #define NET_SOCKET_SOCKET_H_ | 6 #define NET_SOCKET_SOCKET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // connected. Zero is returned once to indicate end-of-file; the return value | 24 // connected. Zero is returned once to indicate end-of-file; the return value |
25 // of subsequent calls is undefined, and may be OS dependent. ERR_IO_PENDING | 25 // of subsequent calls is undefined, and may be OS dependent. ERR_IO_PENDING |
26 // is returned if the operation could not be completed synchronously, in which | 26 // is returned if the operation could not be completed synchronously, in which |
27 // case the result will be passed to the callback when available. If the | 27 // case the result will be passed to the callback when available. If the |
28 // operation is not completed immediately, the socket acquires a reference to | 28 // operation is not completed immediately, the socket acquires a reference to |
29 // the provided buffer until the callback is invoked or the socket is | 29 // the provided buffer until the callback is invoked or the socket is |
30 // closed. If the socket is Disconnected before the read completes, the | 30 // closed. If the socket is Disconnected before the read completes, the |
31 // callback will not be invoked. | 31 // callback will not be invoked. |
32 virtual int Read(IOBuffer* buf, int buf_len, | 32 virtual int Read(IOBuffer* buf, int buf_len, |
33 OldCompletionCallback* callback) = 0; | 33 OldCompletionCallback* callback) = 0; |
| 34 virtual int Read(IOBuffer* buf, int buf_len, |
| 35 const CompletionCallback& callback) = 0; |
34 | 36 |
35 // Writes data, up to |buf_len| bytes, to the socket. Note: data may be | 37 // Writes data, up to |buf_len| bytes, to the socket. Note: data may be |
36 // written partially. The number of bytes written is returned, or an error | 38 // written partially. The number of bytes written is returned, or an error |
37 // is returned upon failure. ERR_SOCKET_NOT_CONNECTED should be returned if | 39 // is returned upon failure. ERR_SOCKET_NOT_CONNECTED should be returned if |
38 // the socket is not currently connected. The return value when the | 40 // the socket is not currently connected. The return value when the |
39 // connection is closed is undefined, and may be OS dependent. ERR_IO_PENDING | 41 // connection is closed is undefined, and may be OS dependent. ERR_IO_PENDING |
40 // is returned if the operation could not be completed synchronously, in which | 42 // is returned if the operation could not be completed synchronously, in which |
41 // case the result will be passed to the callback when available. If the | 43 // case the result will be passed to the callback when available. If the |
42 // operation is not completed immediately, the socket acquires a reference to | 44 // operation is not completed immediately, the socket acquires a reference to |
43 // the provided buffer until the callback is invoked or the socket is | 45 // the provided buffer until the callback is invoked or the socket is |
(...skipping 10 matching lines...) Expand all Loading... |
54 | 56 |
55 // Set the send buffer size (in bytes) for the socket. | 57 // Set the send buffer size (in bytes) for the socket. |
56 // Note: changing this value can affect the TCP window size on some platforms. | 58 // Note: changing this value can affect the TCP window size on some platforms. |
57 // Returns true on success, or false on failure. | 59 // Returns true on success, or false on failure. |
58 virtual bool SetSendBufferSize(int32 size) = 0; | 60 virtual bool SetSendBufferSize(int32 size) = 0; |
59 }; | 61 }; |
60 | 62 |
61 } // namespace net | 63 } // namespace net |
62 | 64 |
63 #endif // NET_SOCKET_SOCKET_H_ | 65 #endif // NET_SOCKET_SOCKET_H_ |
OLD | NEW |