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

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

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorder initialization in constructor 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/tcp_socket_win.cc ('k') | net/socket/transport_client_socket_pool.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_TRANSPORT_CLIENT_SOCKET_POOL_H_ 5 #ifndef NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
6 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ 6 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "net/base/host_port_pair.h" 15 #include "net/base/host_port_pair.h"
16 #include "net/dns/host_resolver.h" 16 #include "net/dns/host_resolver.h"
17 #include "net/dns/single_request_host_resolver.h" 17 #include "net/dns/single_request_host_resolver.h"
18 #include "net/socket/client_socket_pool.h" 18 #include "net/socket/client_socket_pool.h"
19 #include "net/socket/client_socket_pool_base.h" 19 #include "net/socket/client_socket_pool_base.h"
20 #include "net/socket/connection_attempts.h" 20 #include "net/socket/connection_attempts.h"
21 21
22 namespace net { 22 namespace net {
23 23
24 class ClientSocketFactory; 24 class ClientSocketFactory;
25 class SocketPerformanceWatcherFactory;
25 26
26 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)> 27 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)>
27 OnHostResolutionCallback; 28 OnHostResolutionCallback;
28 29
29 class NET_EXPORT_PRIVATE TransportSocketParams 30 class NET_EXPORT_PRIVATE TransportSocketParams
30 : public base::RefCounted<TransportSocketParams> { 31 : public base::RefCounted<TransportSocketParams> {
31 public: 32 public:
32 // CombineConnectAndWrite currently translates to using TCP FastOpen. 33 // CombineConnectAndWrite currently translates to using TCP FastOpen.
33 // TCP FastOpen should not be used if the first write to the socket may 34 // TCP FastOpen should not be used if the first write to the socket may
34 // be non-idempotent, as the underlying socket could retransmit the data 35 // be non-idempotent, as the underlying socket could retransmit the data
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // TransportConnectJob handles the host resolution necessary for socket creation 147 // TransportConnectJob handles the host resolution necessary for socket creation
147 // and the transport (likely TCP) connect. TransportConnectJob also has fallback 148 // and the transport (likely TCP) connect. TransportConnectJob also has fallback
148 // logic for IPv6 connect() timeouts (which may happen due to networks / routers 149 // logic for IPv6 connect() timeouts (which may happen due to networks / routers
149 // with broken IPv6 support). Those timeouts take 20s, so rather than make the 150 // with broken IPv6 support). Those timeouts take 20s, so rather than make the
150 // user wait 20s for the timeout to fire, we use a fallback timer 151 // user wait 20s for the timeout to fire, we use a fallback timer
151 // (kIPv6FallbackTimerInMs) and start a connect() to a IPv4 address if the timer 152 // (kIPv6FallbackTimerInMs) and start a connect() to a IPv4 address if the timer
152 // fires. Then we race the IPv4 connect() against the IPv6 connect() (which has 153 // fires. Then we race the IPv4 connect() against the IPv6 connect() (which has
153 // a headstart) and return the one that completes first to the socket pool. 154 // a headstart) and return the one that completes first to the socket pool.
154 class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { 155 class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob {
155 public: 156 public:
156 TransportConnectJob(const std::string& group_name, 157 TransportConnectJob(
157 RequestPriority priority, 158 const std::string& group_name,
158 ClientSocketPool::RespectLimits respect_limits, 159 RequestPriority priority,
159 const scoped_refptr<TransportSocketParams>& params, 160 ClientSocketPool::RespectLimits respect_limits,
160 base::TimeDelta timeout_duration, 161 const scoped_refptr<TransportSocketParams>& params,
161 ClientSocketFactory* client_socket_factory, 162 base::TimeDelta timeout_duration,
162 HostResolver* host_resolver, 163 ClientSocketFactory* client_socket_factory,
163 Delegate* delegate, 164 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
164 NetLog* net_log); 165 HostResolver* host_resolver,
166 Delegate* delegate,
167 NetLog* net_log);
165 ~TransportConnectJob() override; 168 ~TransportConnectJob() override;
166 169
167 // ConnectJob methods. 170 // ConnectJob methods.
168 LoadState GetLoadState() const override; 171 LoadState GetLoadState() const override;
169 void GetAdditionalErrorState(ClientSocketHandle* handle) override; 172 void GetAdditionalErrorState(ClientSocketHandle* handle) override;
170 173
171 // Rolls |addrlist| forward until the first IPv4 address, if any. 174 // Rolls |addrlist| forward until the first IPv4 address, if any.
172 // WARNING: this method should only be used to implement the prefer-IPv4 hack. 175 // WARNING: this method should only be used to implement the prefer-IPv4 hack.
173 static void MakeAddressListStartWithIPv4(AddressList* addrlist); 176 static void MakeAddressListStartWithIPv4(AddressList* addrlist);
174 177
(...skipping 23 matching lines...) Expand all
198 void CopyConnectionAttemptsFromSockets(); 201 void CopyConnectionAttemptsFromSockets();
199 202
200 TransportConnectJobHelper helper_; 203 TransportConnectJobHelper helper_;
201 204
202 scoped_ptr<StreamSocket> transport_socket_; 205 scoped_ptr<StreamSocket> transport_socket_;
203 206
204 scoped_ptr<StreamSocket> fallback_transport_socket_; 207 scoped_ptr<StreamSocket> fallback_transport_socket_;
205 scoped_ptr<AddressList> fallback_addresses_; 208 scoped_ptr<AddressList> fallback_addresses_;
206 base::TimeTicks fallback_connect_start_time_; 209 base::TimeTicks fallback_connect_start_time_;
207 base::OneShotTimer fallback_timer_; 210 base::OneShotTimer fallback_timer_;
211 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
208 212
209 // Track the interval between this connect and previous connect. 213 // Track the interval between this connect and previous connect.
210 ConnectInterval interval_between_connects_; 214 ConnectInterval interval_between_connects_;
211 215
212 int resolve_result_; 216 int resolve_result_;
213 217
214 // Used in the failure case to save connection attempts made on the main and 218 // Used in the failure case to save connection attempts made on the main and
215 // fallback sockets and pass them on in |GetAdditionalErrorState|. (In the 219 // fallback sockets and pass them on in |GetAdditionalErrorState|. (In the
216 // success case, connection attempts are passed through the returned socket; 220 // success case, connection attempts are passed through the returned socket;
217 // attempts are copied from the other socket, if one exists, into it before 221 // attempts are copied from the other socket, if one exists, into it before
218 // it is returned.) 222 // it is returned.)
219 ConnectionAttempts connection_attempts_; 223 ConnectionAttempts connection_attempts_;
220 ConnectionAttempts fallback_connection_attempts_; 224 ConnectionAttempts fallback_connection_attempts_;
221 225
222 DISALLOW_COPY_AND_ASSIGN(TransportConnectJob); 226 DISALLOW_COPY_AND_ASSIGN(TransportConnectJob);
223 }; 227 };
224 228
225 class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool { 229 class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool {
226 public: 230 public:
227 typedef TransportSocketParams SocketParams; 231 typedef TransportSocketParams SocketParams;
228 232
229 TransportClientSocketPool( 233 TransportClientSocketPool(
230 int max_sockets, 234 int max_sockets,
231 int max_sockets_per_group, 235 int max_sockets_per_group,
232 HostResolver* host_resolver, 236 HostResolver* host_resolver,
233 ClientSocketFactory* client_socket_factory, 237 ClientSocketFactory* client_socket_factory,
238 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
234 NetLog* net_log); 239 NetLog* net_log);
235 240
236 ~TransportClientSocketPool() override; 241 ~TransportClientSocketPool() override;
237 242
238 // ClientSocketPool implementation. 243 // ClientSocketPool implementation.
239 int RequestSocket(const std::string& group_name, 244 int RequestSocket(const std::string& group_name,
240 const void* resolve_info, 245 const void* resolve_info,
241 RequestPriority priority, 246 RequestPriority priority,
242 RespectLimits respect_limits, 247 RespectLimits respect_limits,
243 ClientSocketHandle* handle, 248 ClientSocketHandle* handle,
(...skipping 30 matching lines...) Expand all
274 void NetLogTcpClientSocketPoolRequestedSocket( 279 void NetLogTcpClientSocketPoolRequestedSocket(
275 const BoundNetLog& net_log, 280 const BoundNetLog& net_log,
276 const scoped_refptr<TransportSocketParams>* casted_params); 281 const scoped_refptr<TransportSocketParams>* casted_params);
277 282
278 private: 283 private:
279 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; 284 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase;
280 285
281 class TransportConnectJobFactory 286 class TransportConnectJobFactory
282 : public PoolBase::ConnectJobFactory { 287 : public PoolBase::ConnectJobFactory {
283 public: 288 public:
284 TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, 289 TransportConnectJobFactory(
285 HostResolver* host_resolver, 290 ClientSocketFactory* client_socket_factory,
286 NetLog* net_log) 291 HostResolver* host_resolver,
292 SocketPerformanceWatcherFactory* socket_performance_watcher_factory,
293 NetLog* net_log)
287 : client_socket_factory_(client_socket_factory), 294 : client_socket_factory_(client_socket_factory),
295 socket_performance_watcher_factory_(
296 socket_performance_watcher_factory),
288 host_resolver_(host_resolver), 297 host_resolver_(host_resolver),
289 net_log_(net_log) {} 298 net_log_(net_log) {}
290 299
291 ~TransportConnectJobFactory() override {} 300 ~TransportConnectJobFactory() override {}
292 301
293 // ClientSocketPoolBase::ConnectJobFactory methods. 302 // ClientSocketPoolBase::ConnectJobFactory methods.
294 303
295 scoped_ptr<ConnectJob> NewConnectJob( 304 scoped_ptr<ConnectJob> NewConnectJob(
296 const std::string& group_name, 305 const std::string& group_name,
297 const PoolBase::Request& request, 306 const PoolBase::Request& request,
298 ConnectJob::Delegate* delegate) const override; 307 ConnectJob::Delegate* delegate) const override;
299 308
300 base::TimeDelta ConnectionTimeout() const override; 309 base::TimeDelta ConnectionTimeout() const override;
301 310
302 private: 311 private:
303 ClientSocketFactory* const client_socket_factory_; 312 ClientSocketFactory* const client_socket_factory_;
313 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_;
304 HostResolver* const host_resolver_; 314 HostResolver* const host_resolver_;
305 NetLog* net_log_; 315 NetLog* net_log_;
306 316
307 DISALLOW_COPY_AND_ASSIGN(TransportConnectJobFactory); 317 DISALLOW_COPY_AND_ASSIGN(TransportConnectJobFactory);
308 }; 318 };
309 319
310 PoolBase base_; 320 PoolBase base_;
311 321
312 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); 322 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool);
313 }; 323 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 break; 373 break;
364 } 374 }
365 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); 375 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
366 376
367 return rv; 377 return rv;
368 } 378 }
369 379
370 } // namespace net 380 } // namespace net
371 381
372 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ 382 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_
OLDNEW
« no previous file with comments | « net/socket/tcp_socket_win.cc ('k') | net/socket/transport_client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698