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

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

Issue 1892323002: Change scoped_ptr to std::unique_ptr in //net/socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_server_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>
11
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/base/address_list.h" 14 #include "net/base/address_list.h"
14 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
15 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
16 #include "net/log/net_log.h" 17 #include "net/log/net_log.h"
17 #include "net/socket/connection_attempts.h" 18 #include "net/socket/connection_attempts.h"
18 #include "net/socket/stream_socket.h" 19 #include "net/socket/stream_socket.h"
19 #include "net/socket/tcp_socket.h" 20 #include "net/socket/tcp_socket.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 class SocketPerformanceWatcher; 24 class SocketPerformanceWatcher;
24 25
25 // A client socket that uses TCP as the transport layer. 26 // A client socket that uses TCP as the transport layer.
26 class NET_EXPORT TCPClientSocket : public StreamSocket { 27 class NET_EXPORT TCPClientSocket : public StreamSocket {
27 public: 28 public:
28 // The IP address(es) and port number to connect to. The TCP socket will try 29 // The IP address(es) and port number to connect to. The TCP socket will try
29 // each IP address in the list until it succeeds in establishing a 30 // each IP address in the list until it succeeds in establishing a
30 // connection. 31 // connection.
31 TCPClientSocket( 32 TCPClientSocket(
32 const AddressList& addresses, 33 const AddressList& addresses,
33 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher, 34 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
34 net::NetLog* net_log, 35 net::NetLog* net_log,
35 const net::NetLog::Source& source); 36 const net::NetLog::Source& source);
36 37
37 // Adopts the given, connected socket and then acts as if Connect() had been 38 // Adopts the given, connected socket and then acts as if Connect() had been
38 // called. This function is used by TCPServerSocket and for testing. 39 // called. This function is used by TCPServerSocket and for testing.
39 TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, 40 TCPClientSocket(std::unique_ptr<TCPSocket> connected_socket,
40 const IPEndPoint& peer_address); 41 const IPEndPoint& peer_address);
41 42
42 ~TCPClientSocket() override; 43 ~TCPClientSocket() override;
43 44
44 // Binds the socket to a local IP address and port. 45 // Binds the socket to a local IP address and port.
45 int Bind(const IPEndPoint& address); 46 int Bind(const IPEndPoint& address);
46 47
47 // StreamSocket implementation. 48 // StreamSocket implementation.
48 int Connect(const CompletionCallback& callback) override; 49 int Connect(const CompletionCallback& callback) override;
49 void Disconnect() override; 50 void Disconnect() override;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // disconnected. 109 // disconnected.
109 void EmitTCPMetricsHistogramsOnDisconnect(); 110 void EmitTCPMetricsHistogramsOnDisconnect();
110 111
111 // Socket performance statistics (such as RTT) are reported to the 112 // Socket performance statistics (such as RTT) are reported to the
112 // |socket_performance_watcher_|. May be nullptr. 113 // |socket_performance_watcher_|. May be nullptr.
113 // |socket_performance_watcher_| is owned by |socket_|. If non-null, 114 // |socket_performance_watcher_| is owned by |socket_|. If non-null,
114 // |socket_performance_watcher_| is guaranteed to be destroyed when |socket_| 115 // |socket_performance_watcher_| is guaranteed to be destroyed when |socket_|
115 // is destroyed. 116 // is destroyed.
116 SocketPerformanceWatcher* socket_performance_watcher_; 117 SocketPerformanceWatcher* socket_performance_watcher_;
117 118
118 scoped_ptr<TCPSocket> socket_; 119 std::unique_ptr<TCPSocket> socket_;
119 120
120 // Local IP address and port we are bound to. Set to NULL if Bind() 121 // Local IP address and port we are bound to. Set to NULL if Bind()
121 // wasn't called (in that case OS chooses address/port). 122 // wasn't called (in that case OS chooses address/port).
122 scoped_ptr<IPEndPoint> bind_address_; 123 std::unique_ptr<IPEndPoint> bind_address_;
123 124
124 // The list of addresses we should try in order to establish a connection. 125 // The list of addresses we should try in order to establish a connection.
125 AddressList addresses_; 126 AddressList addresses_;
126 127
127 // Where we are in above list. Set to -1 if uninitialized. 128 // Where we are in above list. Set to -1 if uninitialized.
128 int current_address_index_; 129 int current_address_index_;
129 130
130 // External callback; called when connect is complete. 131 // External callback; called when connect is complete.
131 CompletionCallback connect_callback_; 132 CompletionCallback connect_callback_;
132 133
(...skipping 12 matching lines...) Expand all
145 146
146 // Total number of bytes received by the socket. 147 // Total number of bytes received by the socket.
147 int64_t total_received_bytes_; 148 int64_t total_received_bytes_;
148 149
149 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); 150 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket);
150 }; 151 };
151 152
152 } // namespace net 153 } // namespace net
153 154
154 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ 155 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_
OLDNEW
« no previous file with comments | « net/socket/ssl_server_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