Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: net/socket/socket_posix.h

Issue 2593063003: Add Socket::ReadIfReady() (Closed)
Patch Set: Fix tests for real Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_POSIX_H_ 5 #ifndef NET_SOCKET_SOCKET_POSIX_H_
6 #define NET_SOCKET_SOCKET_POSIX_H_ 6 #define NET_SOCKET_SOCKET_POSIX_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 bool IsConnected() const; 52 bool IsConnected() const;
53 bool IsConnectedAndIdle() const; 53 bool IsConnectedAndIdle() const;
54 54
55 // Multiple outstanding requests of the same type are not supported. 55 // Multiple outstanding requests of the same type are not supported.
56 // Full duplex mode (reading and writing at the same time) is supported. 56 // Full duplex mode (reading and writing at the same time) is supported.
57 // On error which is not ERR_IO_PENDING, sets errno and returns a net error 57 // On error which is not ERR_IO_PENDING, sets errno and returns a net error
58 // code. On ERR_IO_PENDING, |callback| is called with a net error code, not 58 // code. On ERR_IO_PENDING, |callback| is called with a net error code, not
59 // errno, though errno is set if read or write events happen with error. 59 // errno, though errno is set if read or write events happen with error.
60 // TODO(byungchul): Need more robust way to pass system errno. 60 // TODO(byungchul): Need more robust way to pass system errno.
61 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); 61 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
62
63 // Reads as much data as possible into |buf| without blocking. If read is to
64 // be retried later, |callback| will be invoked when data is ready for
65 // reading.
66 // See socket.h for more information.
67 int ReadIfReady(IOBuffer* buf,
68 int buf_len,
69 const CompletionCallback& callback);
62 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback); 70 int Write(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
63 71
64 // Waits for next write event. This is called by TCPSocketPosix for TCP 72 // Waits for next write event. This is called by TCPSocketPosix for TCP
65 // fastopen after sending first data. Returns ERR_IO_PENDING if it starts 73 // fastopen after sending first data. Returns ERR_IO_PENDING if it starts
66 // waiting for write event successfully. Otherwise, returns a net error code. 74 // waiting for write event successfully. Otherwise, returns a net error code.
67 // It must not be called after Write() because Write() calls it internally. 75 // It must not be called after Write() because Write() calls it internally.
68 int WaitForWrite(IOBuffer* buf, int buf_len, 76 int WaitForWrite(IOBuffer* buf, int buf_len,
69 const CompletionCallback& callback); 77 const CompletionCallback& callback);
70 78
71 int GetLocalAddress(SockaddrStorage* address) const; 79 int GetLocalAddress(SockaddrStorage* address) const;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 std::unique_ptr<SockaddrStorage> peer_address_; 135 std::unique_ptr<SockaddrStorage> peer_address_;
128 136
129 base::ThreadChecker thread_checker_; 137 base::ThreadChecker thread_checker_;
130 138
131 DISALLOW_COPY_AND_ASSIGN(SocketPosix); 139 DISALLOW_COPY_AND_ASSIGN(SocketPosix);
132 }; 140 };
133 141
134 } // namespace net 142 } // namespace net
135 143
136 #endif // NET_SOCKET_SOCKET_POSIX_H_ 144 #endif // NET_SOCKET_SOCKET_POSIX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698