| OLD | NEW |
| 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 Loading... |
| 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(). |
| 97 // If |read_if_ready| is set to true, ReadIfReady() will be used instead of |
| 98 // Read(). |
| 99 int ReadCommon(IOBuffer* buf, |
| 100 int buf_len, |
| 101 const CompletionCallback& callback, |
| 102 bool read_if_ready); |
| 103 |
| 93 // State machine used by Connect(). | 104 // State machine used by Connect(). |
| 94 int DoConnectLoop(int result); | 105 int DoConnectLoop(int result); |
| 95 int DoConnect(); | 106 int DoConnect(); |
| 96 int DoConnectComplete(int result); | 107 int DoConnectComplete(int result); |
| 97 | 108 |
| 98 // Helper used by Disconnect(), which disconnects minus resetting | 109 // Helper used by Disconnect(), which disconnects minus resetting |
| 99 // current_address_index_ and bind_address_. | 110 // current_address_index_ and bind_address_. |
| 100 void DoDisconnect(); | 111 void DoDisconnect(); |
| 101 | 112 |
| 102 void DidCompleteConnect(int result); | 113 void DidCompleteConnect(int result); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 158 |
| 148 // Total number of bytes received by the socket. | 159 // Total number of bytes received by the socket. |
| 149 int64_t total_received_bytes_; | 160 int64_t total_received_bytes_; |
| 150 | 161 |
| 151 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); | 162 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); |
| 152 }; | 163 }; |
| 153 | 164 |
| 154 } // namespace net | 165 } // namespace net |
| 155 | 166 |
| 156 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ | 167 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ |
| OLD | NEW |