| Index: net/socket/socket.h
|
| diff --git a/net/socket/socket.h b/net/socket/socket.h
|
| index cda54063f3059e76726c896b5e6ae87508a5f483..544e8267b274aadb2a32be2cc389b442e782c280 100644
|
| --- a/net/socket/socket.h
|
| +++ b/net/socket/socket.h
|
| @@ -17,6 +17,9 @@ class IOBuffer;
|
| // Represents a read/write socket.
|
| class NET_EXPORT Socket {
|
| public:
|
| + // Name of the field trial for using ReadyIfReady() instead of Read().
|
| + static const char kReadIfReadyTrialName[];
|
| +
|
| virtual ~Socket() {}
|
|
|
| // Reads data, up to |buf_len| bytes, from the socket. The number of bytes
|
| @@ -33,6 +36,19 @@ class NET_EXPORT Socket {
|
| virtual int Read(IOBuffer* buf, int buf_len,
|
| const CompletionCallback& callback) = 0;
|
|
|
| + // Reads as much data as possible into |buf| without blocking. Default
|
| + // implementation returns ERR_READ_IF_READY_NOT_IMPLEMENTED. Caller should
|
| + // fall back to Read() if receives ERR_READ_IF_READY_NOT_IMPLEMENTED.
|
| + // Upon synchronous completion, returns the number of bytes read or an error
|
| + // code if an error happens; If read cannot be completed synchronously,
|
| + // returns ERR_IO_PENDING and does not hold on to |buf|. |callback| will be
|
| + // invoked with OK when data can be read, at which point, caller can call
|
| + // ReadIfReady() again; if an error occurs asynchronously, |callback| will be
|
| + // invoked with the error code.
|
| + virtual int ReadIfReady(IOBuffer* buf,
|
| + int buf_len,
|
| + const CompletionCallback& callback);
|
| +
|
| // Writes data, up to |buf_len| bytes, to the socket. Note: data may be
|
| // written partially. The number of bytes written is returned, or an error
|
| // is returned upon failure. ERR_SOCKET_NOT_CONNECTED should be returned if
|
|
|