Index: net/socket/socket_posix.h |
diff --git a/net/socket/socket_posix.h b/net/socket/socket_posix.h |
index bf4b7e53d9b055793b3b6f6bb4bece7040268d2c..a4e1b80e5719102bd6e04ae99f81566a91715bb0 100644 |
--- a/net/socket/socket_posix.h |
+++ b/net/socket/socket_posix.h |
@@ -10,6 +10,7 @@ |
#include "base/compiler_specific.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
#include "base/message_loop/message_loop.h" |
#include "base/threading/thread_checker.h" |
#include "net/base/completion_callback.h" |
@@ -59,6 +60,14 @@ class NET_EXPORT_PRIVATE SocketPosix : public base::MessageLoopForIO::Watcher { |
// errno, though errno is set if read or write events happen with error. |
// TODO(byungchul): Need more robust way to pass system errno. |
int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
+ |
+ // Reads as much data as possible into |buf| without blocking. If read is to |
+ // be retried later, |callback| will be invoked when data is ready for |
+ // reading. |
+ // See socket.h for more information. |
+ int ReadIfReady(IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback); |
int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
// Waits for next write event. This is called by TCPSocketPosix for TCP |
@@ -95,6 +104,7 @@ class NET_EXPORT_PRIVATE SocketPosix : public base::MessageLoopForIO::Watcher { |
void ConnectCompleted(); |
int DoRead(IOBuffer* buf, int buf_len); |
+ void RetryRead(int rv); |
void ReadCompleted(); |
int DoWrite(IOBuffer* buf, int buf_len); |
@@ -109,11 +119,15 @@ class NET_EXPORT_PRIVATE SocketPosix : public base::MessageLoopForIO::Watcher { |
CompletionCallback accept_callback_; |
base::MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; |
+ |
+ // Non-null when a Read() is in progress. |
scoped_refptr<IOBuffer> read_buf_; |
int read_buf_len_; |
- // External callback; called when read is complete. |
CompletionCallback read_callback_; |
+ // Non-null when a ReadIfReady() is in progress. |
+ CompletionCallback read_if_ready_callback_; |
+ |
base::MessageLoopForIO::FileDescriptorWatcher write_socket_watcher_; |
scoped_refptr<IOBuffer> write_buf_; |
int write_buf_len_; |
@@ -128,6 +142,8 @@ class NET_EXPORT_PRIVATE SocketPosix : public base::MessageLoopForIO::Watcher { |
base::ThreadChecker thread_checker_; |
+ base::WeakPtrFactory<SocketPosix> weak_factory_; |
+ |
DISALLOW_COPY_AND_ASSIGN(SocketPosix); |
}; |