| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 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 #ifndef NET_BASE_SOCKET_H_ | |
| 6 #define NET_BASE_SOCKET_H_ | |
| 7 | |
| 8 #include "net/base/completion_callback.h" | |
| 9 | |
| 10 namespace net { | |
| 11 | |
| 12 class IOBuffer; | |
| 13 | |
| 14 // Represents a read/write socket. | |
| 15 class Socket { | |
| 16 public: | |
| 17 virtual ~Socket() {} | |
| 18 | |
| 19 // Reads data, up to buf_len bytes, from the socket. The number of bytes | |
| 20 // read is returned, or an error is returned upon failure. Zero is returned | |
| 21 // to indicate end-of-file. ERR_IO_PENDING is returned if the operation | |
| 22 // could not be completed synchronously, in which case the result will be | |
| 23 // passed to the callback when available. If the operation is not completed | |
| 24 // immediately, the socket acquires a reference to the provided buffer until | |
| 25 // the callback is invoked or the socket is destroyed. | |
| 26 virtual int Read(IOBuffer* buf, int buf_len, | |
| 27 CompletionCallback* callback) = 0; | |
| 28 | |
| 29 // Writes data, up to buf_len bytes, to the socket. Note: only part of the | |
| 30 // data may be written! The number of bytes written is returned, or an error | |
| 31 // is returned upon failure. ERR_IO_PENDING is returned if the operation | |
| 32 // could not be completed synchronously, in which case the result will be | |
| 33 // passed to the callback when available. If the operation is not completed | |
| 34 // immediately, the socket acquires a reference to the provided buffer until | |
| 35 // the callback is invoked or the socket is destroyed. | |
| 36 // Implementations of this method should not modify the contents of the actual | |
| 37 // buffer that is written to the socket. | |
| 38 virtual int Write(IOBuffer* buf, int buf_len, | |
| 39 CompletionCallback* callback) = 0; | |
| 40 }; | |
| 41 | |
| 42 } // namespace net | |
| 43 | |
| 44 #endif // NET_BASE_SOCKET_H_ | |
| OLD | NEW |