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_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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/timer.h" | 15 #include "base/timer.h" |
16 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
17 #include "net/base/host_resolver.h" | 17 #include "net/base/host_resolver.h" |
18 #include "net/base/single_request_host_resolver.h" | 18 #include "net/base/single_request_host_resolver.h" |
19 #include "net/socket/client_socket_pool_base.h" | 19 #include "net/socket/client_socket_pool_base.h" |
20 #include "net/socket/client_socket_pool_histograms.h" | 20 #include "net/socket/client_socket_pool_histograms.h" |
21 #include "net/socket/client_socket_pool.h" | 21 #include "net/socket/client_socket_pool.h" |
22 | 22 |
23 namespace net { | 23 namespace net { |
24 | 24 |
25 class ClientSocketFactory; | 25 class ClientSocketFactory; |
26 | 26 |
27 class NET_TEST TransportSocketParams | 27 class NET_EXPORT_PRIVATE TransportSocketParams |
28 : public base::RefCounted<TransportSocketParams> { | 28 : public base::RefCounted<TransportSocketParams> { |
29 public: | 29 public: |
30 TransportSocketParams(const HostPortPair& host_port_pair, | 30 TransportSocketParams(const HostPortPair& host_port_pair, |
31 RequestPriority priority, | 31 RequestPriority priority, |
32 const GURL& referrer, | 32 const GURL& referrer, |
33 bool disable_resolver_cache, | 33 bool disable_resolver_cache, |
34 bool ignore_limits); | 34 bool ignore_limits); |
35 | 35 |
36 const HostResolver::RequestInfo& destination() const { return destination_; } | 36 const HostResolver::RequestInfo& destination() const { return destination_; } |
37 bool ignore_limits() const { return ignore_limits_; } | 37 bool ignore_limits() const { return ignore_limits_; } |
(...skipping 12 matching lines...) Expand all Loading... |
50 }; | 50 }; |
51 | 51 |
52 // TransportConnectJob handles the host resolution necessary for socket creation | 52 // TransportConnectJob handles the host resolution necessary for socket creation |
53 // and the transport (likely TCP) connect. TransportConnectJob also has fallback | 53 // and the transport (likely TCP) connect. TransportConnectJob also has fallback |
54 // logic for IPv6 connect() timeouts (which may happen due to networks / routers | 54 // logic for IPv6 connect() timeouts (which may happen due to networks / routers |
55 // with broken IPv6 support). Those timeouts take 20s, so rather than make the | 55 // with broken IPv6 support). Those timeouts take 20s, so rather than make the |
56 // user wait 20s for the timeout to fire, we use a fallback timer | 56 // user wait 20s for the timeout to fire, we use a fallback timer |
57 // (kIPv6FallbackTimerInMs) and start a connect() to a IPv4 address if the timer | 57 // (kIPv6FallbackTimerInMs) and start a connect() to a IPv4 address if the timer |
58 // fires. Then we race the IPv4 connect() against the IPv6 connect() (which has | 58 // fires. Then we race the IPv4 connect() against the IPv6 connect() (which has |
59 // a headstart) and return the one that completes first to the socket pool. | 59 // a headstart) and return the one that completes first to the socket pool. |
60 class NET_TEST TransportConnectJob : public ConnectJob { | 60 class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { |
61 public: | 61 public: |
62 TransportConnectJob(const std::string& group_name, | 62 TransportConnectJob(const std::string& group_name, |
63 const scoped_refptr<TransportSocketParams>& params, | 63 const scoped_refptr<TransportSocketParams>& params, |
64 base::TimeDelta timeout_duration, | 64 base::TimeDelta timeout_duration, |
65 ClientSocketFactory* client_socket_factory, | 65 ClientSocketFactory* client_socket_factory, |
66 HostResolver* host_resolver, | 66 HostResolver* host_resolver, |
67 Delegate* delegate, | 67 Delegate* delegate, |
68 NetLog* net_log); | 68 NetLog* net_log); |
69 virtual ~TransportConnectJob(); | 69 virtual ~TransportConnectJob(); |
70 | 70 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 scoped_ptr<StreamSocket> fallback_transport_socket_; | 126 scoped_ptr<StreamSocket> fallback_transport_socket_; |
127 scoped_ptr<AddressList> fallback_addresses_; | 127 scoped_ptr<AddressList> fallback_addresses_; |
128 CompletionCallbackImpl<TransportConnectJob> fallback_callback_; | 128 CompletionCallbackImpl<TransportConnectJob> fallback_callback_; |
129 base::TimeTicks fallback_connect_start_time_; | 129 base::TimeTicks fallback_connect_start_time_; |
130 base::OneShotTimer<TransportConnectJob> fallback_timer_; | 130 base::OneShotTimer<TransportConnectJob> fallback_timer_; |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(TransportConnectJob); | 132 DISALLOW_COPY_AND_ASSIGN(TransportConnectJob); |
133 }; | 133 }; |
134 | 134 |
135 class NET_TEST TransportClientSocketPool : public ClientSocketPool { | 135 class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool { |
136 public: | 136 public: |
137 TransportClientSocketPool( | 137 TransportClientSocketPool( |
138 int max_sockets, | 138 int max_sockets, |
139 int max_sockets_per_group, | 139 int max_sockets_per_group, |
140 ClientSocketPoolHistograms* histograms, | 140 ClientSocketPoolHistograms* histograms, |
141 HostResolver* host_resolver, | 141 HostResolver* host_resolver, |
142 ClientSocketFactory* client_socket_factory, | 142 ClientSocketFactory* client_socket_factory, |
143 NetLog* net_log); | 143 NetLog* net_log); |
144 | 144 |
145 virtual ~TransportClientSocketPool(); | 145 virtual ~TransportClientSocketPool(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); | 222 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); |
223 }; | 223 }; |
224 | 224 |
225 REGISTER_SOCKET_PARAMS_FOR_POOL(TransportClientSocketPool, | 225 REGISTER_SOCKET_PARAMS_FOR_POOL(TransportClientSocketPool, |
226 TransportSocketParams); | 226 TransportSocketParams); |
227 | 227 |
228 } // namespace net | 228 } // namespace net |
229 | 229 |
230 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 230 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |