| Index: net/socket/socket.h
|
| diff --git a/net/socket/socket.h b/net/socket/socket.h
|
| index cda54063f3059e76726c896b5e6ae87508a5f483..8f5fed6dea08a65799468a23e1328a73d7af7a12 100644
|
| --- a/net/socket/socket.h
|
| +++ b/net/socket/socket.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include <stdint.h>
|
|
|
| +#include "base/feature_list.h"
|
| #include "net/base/completion_callback.h"
|
| #include "net/base/net_export.h"
|
|
|
| @@ -17,6 +18,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 base::Feature kReadIfReadyExperiment;
|
| +
|
| virtual ~Socket() {}
|
|
|
| // Reads data, up to |buf_len| bytes, from the socket. The number of bytes
|
| @@ -33,6 +37,19 @@ class NET_EXPORT Socket {
|
| virtual int Read(IOBuffer* buf, int buf_len,
|
| const CompletionCallback& callback) = 0;
|
|
|
| + // Reads data, up to |buf_len| bytes, 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 0 on EOF,
|
| + // 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
|
|
|