| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_LIBEVENT_H_ | 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ | 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/non_thread_safe.h" | 10 #include "base/non_thread_safe.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // ClientSocket methods: | 36 // ClientSocket methods: |
| 37 virtual int Connect(CompletionCallback* callback); | 37 virtual int Connect(CompletionCallback* callback); |
| 38 virtual void Disconnect(); | 38 virtual void Disconnect(); |
| 39 virtual bool IsConnected() const; | 39 virtual bool IsConnected() const; |
| 40 virtual bool IsConnectedAndIdle() const; | 40 virtual bool IsConnectedAndIdle() const; |
| 41 virtual int GetPeerAddress(AddressList* address) const; | 41 virtual int GetPeerAddress(AddressList* address) const; |
| 42 virtual const BoundNetLog& NetLog() const { return net_log_; } | 42 virtual const BoundNetLog& NetLog() const { return net_log_; } |
| 43 virtual void SetSubresourceSpeculation(); | 43 virtual void SetSubresourceSpeculation(); |
| 44 virtual void SetOmniboxSpeculation(); | 44 virtual void SetOmniboxSpeculation(); |
| 45 virtual bool WasEverUsed() const; | 45 virtual bool WasEverUsed() const; |
| 46 virtual bool UsingTCPFastOpen() const; |
| 46 | 47 |
| 47 // Socket methods: | 48 // Socket methods: |
| 48 // Multiple outstanding requests are not supported. | 49 // Multiple outstanding requests are not supported. |
| 49 // Full duplex mode (reading and writing at the same time) is supported | 50 // Full duplex mode (reading and writing at the same time) is supported |
| 50 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 51 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 51 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 52 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 52 virtual bool SetReceiveBufferSize(int32 size); | 53 virtual bool SetReceiveBufferSize(int32 size); |
| 53 virtual bool SetSendBufferSize(int32 size); | 54 virtual bool SetSendBufferSize(int32 size); |
| 54 | 55 |
| 55 private: | 56 private: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 bool waiting_connect() const { | 121 bool waiting_connect() const { |
| 121 return next_connect_state_ != CONNECT_STATE_NONE; | 122 return next_connect_state_ != CONNECT_STATE_NONE; |
| 122 } | 123 } |
| 123 | 124 |
| 124 // Returns the OS error code (or 0 on success). | 125 // Returns the OS error code (or 0 on success). |
| 125 int CreateSocket(const struct addrinfo* ai); | 126 int CreateSocket(const struct addrinfo* ai); |
| 126 | 127 |
| 127 // Helper to add a TCP_CONNECT (end) event to the NetLog. | 128 // Helper to add a TCP_CONNECT (end) event to the NetLog. |
| 128 void LogConnectCompletion(int net_error); | 129 void LogConnectCompletion(int net_error); |
| 129 | 130 |
| 131 // Internal function to write to a socket. |
| 132 int InternalWrite(IOBuffer* buf, int buf_len); |
| 133 |
| 130 int socket_; | 134 int socket_; |
| 131 | 135 |
| 132 // The list of addresses we should try in order to establish a connection. | 136 // The list of addresses we should try in order to establish a connection. |
| 133 AddressList addresses_; | 137 AddressList addresses_; |
| 134 | 138 |
| 135 // Where we are in above list, or NULL if all addrinfos have been tried. | 139 // Where we are in above list, or NULL if all addrinfos have been tried. |
| 136 const struct addrinfo* current_ai_; | 140 const struct addrinfo* current_ai_; |
| 137 | 141 |
| 138 // The socket's libevent wrappers | 142 // The socket's libevent wrappers |
| 139 MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; | 143 MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 162 | 166 |
| 163 // The OS error that CONNECT_STATE_CONNECT last completed with. | 167 // The OS error that CONNECT_STATE_CONNECT last completed with. |
| 164 int connect_os_error_; | 168 int connect_os_error_; |
| 165 | 169 |
| 166 BoundNetLog net_log_; | 170 BoundNetLog net_log_; |
| 167 | 171 |
| 168 // Record of connectivity and transmissions, for use in speculative connection | 172 // Record of connectivity and transmissions, for use in speculative connection |
| 169 // histograms. | 173 // histograms. |
| 170 UseHistory use_history_; | 174 UseHistory use_history_; |
| 171 | 175 |
| 176 // Enables experimental TCP FastOpen option. |
| 177 bool use_tcp_fastopen_; |
| 178 |
| 179 // True when TCP FastOpen is in use and we have done the connect. |
| 180 bool tcp_fastopen_connected_; |
| 181 |
| 172 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); | 182 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketLibevent); |
| 173 }; | 183 }; |
| 174 | 184 |
| 175 } // namespace net | 185 } // namespace net |
| 176 | 186 |
| 177 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ | 187 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_LIBEVENT_H_ |
| OLD | NEW |