| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/base/address_list.h" | 11 #include "net/base/address_list.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 #include "net/log/net_log.h" | 14 #include "net/log/net_log.h" |
| 15 #include "net/socket/connection_attempts.h" |
| 15 #include "net/socket/stream_socket.h" | 16 #include "net/socket/stream_socket.h" |
| 16 #include "net/socket/tcp_socket.h" | 17 #include "net/socket/tcp_socket.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 // A client socket that uses TCP as the transport layer. | 21 // A client socket that uses TCP as the transport layer. |
| 21 class NET_EXPORT TCPClientSocket : public StreamSocket { | 22 class NET_EXPORT TCPClientSocket : public StreamSocket { |
| 22 public: | 23 public: |
| 23 // The IP address(es) and port number to connect to. The TCP socket will try | 24 // The IP address(es) and port number to connect to. The TCP socket will try |
| 24 // each IP address in the list until it succeeds in establishing a | 25 // each IP address in the list until it succeeds in establishing a |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 const CompletionCallback& callback) override; | 63 const CompletionCallback& callback) override; |
| 63 int Write(IOBuffer* buf, | 64 int Write(IOBuffer* buf, |
| 64 int buf_len, | 65 int buf_len, |
| 65 const CompletionCallback& callback) override; | 66 const CompletionCallback& callback) override; |
| 66 int SetReceiveBufferSize(int32 size) override; | 67 int SetReceiveBufferSize(int32 size) override; |
| 67 int SetSendBufferSize(int32 size) override; | 68 int SetSendBufferSize(int32 size) override; |
| 68 | 69 |
| 69 virtual bool SetKeepAlive(bool enable, int delay); | 70 virtual bool SetKeepAlive(bool enable, int delay); |
| 70 virtual bool SetNoDelay(bool no_delay); | 71 virtual bool SetNoDelay(bool no_delay); |
| 71 | 72 |
| 73 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
| 74 void ClearConnectionAttempts() override; |
| 75 void AddConnectionAttempts(const ConnectionAttempts& attempts) override; |
| 76 |
| 72 private: | 77 private: |
| 73 // State machine for connecting the socket. | 78 // State machine for connecting the socket. |
| 74 enum ConnectState { | 79 enum ConnectState { |
| 75 CONNECT_STATE_CONNECT, | 80 CONNECT_STATE_CONNECT, |
| 76 CONNECT_STATE_CONNECT_COMPLETE, | 81 CONNECT_STATE_CONNECT_COMPLETE, |
| 77 CONNECT_STATE_NONE, | 82 CONNECT_STATE_NONE, |
| 78 }; | 83 }; |
| 79 | 84 |
| 80 // State machine used by Connect(). | 85 // State machine used by Connect(). |
| 81 int DoConnectLoop(int result); | 86 int DoConnectLoop(int result); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 109 // The next state for the Connect() state machine. | 114 // The next state for the Connect() state machine. |
| 110 ConnectState next_connect_state_; | 115 ConnectState next_connect_state_; |
| 111 | 116 |
| 112 // This socket was previously disconnected and has not been re-connected. | 117 // This socket was previously disconnected and has not been re-connected. |
| 113 bool previously_disconnected_; | 118 bool previously_disconnected_; |
| 114 | 119 |
| 115 // Record of connectivity and transmissions, for use in speculative connection | 120 // Record of connectivity and transmissions, for use in speculative connection |
| 116 // histograms. | 121 // histograms. |
| 117 UseHistory use_history_; | 122 UseHistory use_history_; |
| 118 | 123 |
| 124 // Failed connection attempts made while trying to connect this socket. |
| 125 ConnectionAttempts connection_attempts_; |
| 126 |
| 119 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); | 127 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); |
| 120 }; | 128 }; |
| 121 | 129 |
| 122 } // namespace net | 130 } // namespace net |
| 123 | 131 |
| 124 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ | 132 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ |
| OLD | NEW |