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> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "net/base/address_list.h" | 14 #include "net/base/address_list.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
17 #include "net/log/net_log.h" | |
18 #include "net/socket/connection_attempts.h" | 17 #include "net/socket/connection_attempts.h" |
19 #include "net/socket/stream_socket.h" | 18 #include "net/socket/stream_socket.h" |
20 #include "net/socket/tcp_socket.h" | 19 #include "net/socket/tcp_socket.h" |
21 | 20 |
22 namespace net { | 21 namespace net { |
23 | 22 |
| 23 class NetLog; |
| 24 struct NetLogSource; |
24 class SocketPerformanceWatcher; | 25 class SocketPerformanceWatcher; |
25 | 26 |
26 // A client socket that uses TCP as the transport layer. | 27 // A client socket that uses TCP as the transport layer. |
27 class NET_EXPORT TCPClientSocket : public StreamSocket { | 28 class NET_EXPORT TCPClientSocket : public StreamSocket { |
28 public: | 29 public: |
29 // The IP address(es) and port number to connect to. The TCP socket will try | 30 // The IP address(es) and port number to connect to. The TCP socket will try |
30 // each IP address in the list until it succeeds in establishing a | 31 // each IP address in the list until it succeeds in establishing a |
31 // connection. | 32 // connection. |
32 TCPClientSocket( | 33 TCPClientSocket( |
33 const AddressList& addresses, | 34 const AddressList& addresses, |
34 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, | 35 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
35 net::NetLog* net_log, | 36 net::NetLog* net_log, |
36 const net::NetLog::Source& source); | 37 const net::NetLogSource& source); |
37 | 38 |
38 // Adopts the given, connected socket and then acts as if Connect() had been | 39 // Adopts the given, connected socket and then acts as if Connect() had been |
39 // called. This function is used by TCPServerSocket and for testing. | 40 // called. This function is used by TCPServerSocket and for testing. |
40 TCPClientSocket(std::unique_ptr<TCPSocket> connected_socket, | 41 TCPClientSocket(std::unique_ptr<TCPSocket> connected_socket, |
41 const IPEndPoint& peer_address); | 42 const IPEndPoint& peer_address); |
42 | 43 |
43 ~TCPClientSocket() override; | 44 ~TCPClientSocket() override; |
44 | 45 |
45 // Binds the socket to a local IP address and port. | 46 // Binds the socket to a local IP address and port. |
46 int Bind(const IPEndPoint& address); | 47 int Bind(const IPEndPoint& address); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 147 |
147 // Total number of bytes received by the socket. | 148 // Total number of bytes received by the socket. |
148 int64_t total_received_bytes_; | 149 int64_t total_received_bytes_; |
149 | 150 |
150 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); | 151 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); |
151 }; | 152 }; |
152 | 153 |
153 } // namespace net | 154 } // namespace net |
154 | 155 |
155 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ | 156 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ |
OLD | NEW |