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

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

Issue 2593063003: Add Socket::ReadIfReady() (Closed)
Patch Set: Rebased Created 3 years, 9 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
« no previous file with comments | « net/socket/ssl_client_socket_unittest.cc ('k') | net/socket/tcp_client_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_TCP_CLIENT_SOCKET_H_ 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_H_
6 #define NET_SOCKET_TCP_CLIENT_SOCKET_H_ 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 bool WasAlpnNegotiated() const override; 61 bool WasAlpnNegotiated() const override;
62 NextProto GetNegotiatedProtocol() const override; 62 NextProto GetNegotiatedProtocol() const override;
63 bool GetSSLInfo(SSLInfo* ssl_info) override; 63 bool GetSSLInfo(SSLInfo* ssl_info) override;
64 64
65 // Socket implementation. 65 // Socket implementation.
66 // Multiple outstanding requests are not supported. 66 // Multiple outstanding requests are not supported.
67 // Full duplex mode (reading and writing at the same time) is supported. 67 // Full duplex mode (reading and writing at the same time) is supported.
68 int Read(IOBuffer* buf, 68 int Read(IOBuffer* buf,
69 int buf_len, 69 int buf_len,
70 const CompletionCallback& callback) override; 70 const CompletionCallback& callback) override;
71 int ReadIfReady(IOBuffer* buf,
72 int buf_len,
73 const CompletionCallback& callback) override;
71 int Write(IOBuffer* buf, 74 int Write(IOBuffer* buf,
72 int buf_len, 75 int buf_len,
73 const CompletionCallback& callback) override; 76 const CompletionCallback& callback) override;
74 int SetReceiveBufferSize(int32_t size) override; 77 int SetReceiveBufferSize(int32_t size) override;
75 int SetSendBufferSize(int32_t size) override; 78 int SetSendBufferSize(int32_t size) override;
76 79
77 virtual bool SetKeepAlive(bool enable, int delay); 80 virtual bool SetKeepAlive(bool enable, int delay);
78 virtual bool SetNoDelay(bool no_delay); 81 virtual bool SetNoDelay(bool no_delay);
79 82
80 void GetConnectionAttempts(ConnectionAttempts* out) const override; 83 void GetConnectionAttempts(ConnectionAttempts* out) const override;
81 void ClearConnectionAttempts() override; 84 void ClearConnectionAttempts() override;
82 void AddConnectionAttempts(const ConnectionAttempts& attempts) override; 85 void AddConnectionAttempts(const ConnectionAttempts& attempts) override;
83 int64_t GetTotalReceivedBytes() const override; 86 int64_t GetTotalReceivedBytes() const override;
84 87
85 private: 88 private:
86 // State machine for connecting the socket. 89 // State machine for connecting the socket.
87 enum ConnectState { 90 enum ConnectState {
88 CONNECT_STATE_CONNECT, 91 CONNECT_STATE_CONNECT,
89 CONNECT_STATE_CONNECT_COMPLETE, 92 CONNECT_STATE_CONNECT_COMPLETE,
90 CONNECT_STATE_NONE, 93 CONNECT_STATE_NONE,
91 }; 94 };
92 95
96 // A helper method shared by Read() and ReadIfReady(). If |read_if_ready| is
97 // set to true, ReadIfReady() will be used instead of Read().
98 int ReadCommon(IOBuffer* buf,
99 int buf_len,
100 const CompletionCallback& callback,
101 bool read_if_ready);
102
93 // State machine used by Connect(). 103 // State machine used by Connect().
94 int DoConnectLoop(int result); 104 int DoConnectLoop(int result);
95 int DoConnect(); 105 int DoConnect();
96 int DoConnectComplete(int result); 106 int DoConnectComplete(int result);
97 107
98 // Helper used by Disconnect(), which disconnects minus resetting 108 // Helper used by Disconnect(), which disconnects minus resetting
99 // current_address_index_ and bind_address_. 109 // current_address_index_ and bind_address_.
100 void DoDisconnect(); 110 void DoDisconnect();
101 111
102 void DidCompleteConnect(int result); 112 void DidCompleteConnect(int result);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 157
148 // Total number of bytes received by the socket. 158 // Total number of bytes received by the socket.
149 int64_t total_received_bytes_; 159 int64_t total_received_bytes_;
150 160
151 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); 161 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket);
152 }; 162 };
153 163
154 } // namespace net 164 } // namespace net
155 165
156 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ 166 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_unittest.cc ('k') | net/socket/tcp_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698