| OLD | NEW |
| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 COMBINE_CONNECT_AND_WRITE_PROHIBITED // Do not combine. | 43 COMBINE_CONNECT_AND_WRITE_PROHIBITED // Do not combine. |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // |host_resolution_callback| will be invoked after the the hostname is | 46 // |host_resolution_callback| will be invoked after the the hostname is |
| 47 // resolved. If |host_resolution_callback| does not return OK, then the | 47 // resolved. If |host_resolution_callback| does not return OK, then the |
| 48 // connection will be aborted with that value. |combine_connect_and_write| | 48 // connection will be aborted with that value. |combine_connect_and_write| |
| 49 // defines the policy for use of TCP FastOpen on this socket. | 49 // defines the policy for use of TCP FastOpen on this socket. |
| 50 TransportSocketParams( | 50 TransportSocketParams( |
| 51 const HostPortPair& host_port_pair, | 51 const HostPortPair& host_port_pair, |
| 52 bool disable_resolver_cache, | 52 bool disable_resolver_cache, |
| 53 bool ignore_limits, | |
| 54 const OnHostResolutionCallback& host_resolution_callback, | 53 const OnHostResolutionCallback& host_resolution_callback, |
| 55 CombineConnectAndWritePolicy combine_connect_and_write); | 54 CombineConnectAndWritePolicy combine_connect_and_write); |
| 56 | 55 |
| 57 const HostResolver::RequestInfo& destination() const { return destination_; } | 56 const HostResolver::RequestInfo& destination() const { return destination_; } |
| 58 bool ignore_limits() const { return ignore_limits_; } | |
| 59 const OnHostResolutionCallback& host_resolution_callback() const { | 57 const OnHostResolutionCallback& host_resolution_callback() const { |
| 60 return host_resolution_callback_; | 58 return host_resolution_callback_; |
| 61 } | 59 } |
| 62 | 60 |
| 63 CombineConnectAndWritePolicy combine_connect_and_write() const { | 61 CombineConnectAndWritePolicy combine_connect_and_write() const { |
| 64 return combine_connect_and_write_; | 62 return combine_connect_and_write_; |
| 65 } | 63 } |
| 66 | 64 |
| 67 private: | 65 private: |
| 68 friend class base::RefCounted<TransportSocketParams>; | 66 friend class base::RefCounted<TransportSocketParams>; |
| 69 ~TransportSocketParams(); | 67 ~TransportSocketParams(); |
| 70 | 68 |
| 71 HostResolver::RequestInfo destination_; | 69 HostResolver::RequestInfo destination_; |
| 72 bool ignore_limits_; | |
| 73 const OnHostResolutionCallback host_resolution_callback_; | 70 const OnHostResolutionCallback host_resolution_callback_; |
| 74 CombineConnectAndWritePolicy combine_connect_and_write_; | 71 CombineConnectAndWritePolicy combine_connect_and_write_; |
| 75 | 72 |
| 76 DISALLOW_COPY_AND_ASSIGN(TransportSocketParams); | 73 DISALLOW_COPY_AND_ASSIGN(TransportSocketParams); |
| 77 }; | 74 }; |
| 78 | 75 |
| 79 // Common data and logic shared between TransportConnectJob and | 76 // Common data and logic shared between TransportConnectJob and |
| 80 // WebSocketTransportConnectJob. | 77 // WebSocketTransportConnectJob. |
| 81 class NET_EXPORT_PRIVATE TransportConnectJobHelper { | 78 class NET_EXPORT_PRIVATE TransportConnectJobHelper { |
| 82 public: | 79 public: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // logic for IPv6 connect() timeouts (which may happen due to networks / routers | 148 // logic for IPv6 connect() timeouts (which may happen due to networks / routers |
| 152 // with broken IPv6 support). Those timeouts take 20s, so rather than make the | 149 // with broken IPv6 support). Those timeouts take 20s, so rather than make the |
| 153 // user wait 20s for the timeout to fire, we use a fallback timer | 150 // user wait 20s for the timeout to fire, we use a fallback timer |
| 154 // (kIPv6FallbackTimerInMs) and start a connect() to a IPv4 address if the timer | 151 // (kIPv6FallbackTimerInMs) and start a connect() to a IPv4 address if the timer |
| 155 // fires. Then we race the IPv4 connect() against the IPv6 connect() (which has | 152 // fires. Then we race the IPv4 connect() against the IPv6 connect() (which has |
| 156 // a headstart) and return the one that completes first to the socket pool. | 153 // a headstart) and return the one that completes first to the socket pool. |
| 157 class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { | 154 class NET_EXPORT_PRIVATE TransportConnectJob : public ConnectJob { |
| 158 public: | 155 public: |
| 159 TransportConnectJob(const std::string& group_name, | 156 TransportConnectJob(const std::string& group_name, |
| 160 RequestPriority priority, | 157 RequestPriority priority, |
| 158 ClientSocketPool::IgnoreLimits ignore_limits, |
| 161 const scoped_refptr<TransportSocketParams>& params, | 159 const scoped_refptr<TransportSocketParams>& params, |
| 162 base::TimeDelta timeout_duration, | 160 base::TimeDelta timeout_duration, |
| 163 ClientSocketFactory* client_socket_factory, | 161 ClientSocketFactory* client_socket_factory, |
| 164 HostResolver* host_resolver, | 162 HostResolver* host_resolver, |
| 165 Delegate* delegate, | 163 Delegate* delegate, |
| 166 NetLog* net_log); | 164 NetLog* net_log); |
| 167 ~TransportConnectJob() override; | 165 ~TransportConnectJob() override; |
| 168 | 166 |
| 169 // ConnectJob methods. | 167 // ConnectJob methods. |
| 170 LoadState GetLoadState() const override; | 168 LoadState GetLoadState() const override; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 HostResolver* host_resolver, | 232 HostResolver* host_resolver, |
| 235 ClientSocketFactory* client_socket_factory, | 233 ClientSocketFactory* client_socket_factory, |
| 236 NetLog* net_log); | 234 NetLog* net_log); |
| 237 | 235 |
| 238 ~TransportClientSocketPool() override; | 236 ~TransportClientSocketPool() override; |
| 239 | 237 |
| 240 // ClientSocketPool implementation. | 238 // ClientSocketPool implementation. |
| 241 int RequestSocket(const std::string& group_name, | 239 int RequestSocket(const std::string& group_name, |
| 242 const void* resolve_info, | 240 const void* resolve_info, |
| 243 RequestPriority priority, | 241 RequestPriority priority, |
| 242 IgnoreLimits ignore_limits, |
| 244 ClientSocketHandle* handle, | 243 ClientSocketHandle* handle, |
| 245 const CompletionCallback& callback, | 244 const CompletionCallback& callback, |
| 246 const BoundNetLog& net_log) override; | 245 const BoundNetLog& net_log) override; |
| 247 void RequestSockets(const std::string& group_name, | 246 void RequestSockets(const std::string& group_name, |
| 248 const void* params, | 247 const void* params, |
| 249 int num_sockets, | 248 int num_sockets, |
| 250 const BoundNetLog& net_log) override; | 249 const BoundNetLog& net_log) override; |
| 251 void CancelRequest(const std::string& group_name, | 250 void CancelRequest(const std::string& group_name, |
| 252 ClientSocketHandle* handle) override; | 251 ClientSocketHandle* handle) override; |
| 253 void ReleaseSocket(const std::string& group_name, | 252 void ReleaseSocket(const std::string& group_name, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 break; | 363 break; |
| 365 } | 364 } |
| 366 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 365 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
| 367 | 366 |
| 368 return rv; | 367 return rv; |
| 369 } | 368 } |
| 370 | 369 |
| 371 } // namespace net | 370 } // namespace net |
| 372 | 371 |
| 373 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 372 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |