Chromium Code Reviews| 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/basictypes.h" | 10 #include "base/basictypes.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/client_socket_pool_histograms.h" | 20 #include "net/socket/client_socket_pool_histograms.h" |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 | 23 |
| 24 // Auto-connect currently translates to using TCP Fast Open. | |
| 25 // NOTE: For TCP Fast Open, enable if the write is known to be idempotent, | |
| 26 // and if a write on the socket is guaranteed to happen before any reads. | |
|
mmenke
2014/09/09 16:03:33
Think the NOTE isn't really clear. How about:
Th
Jana
2014/09/10 16:03:11
I've slightly modified it from your suggestion, PT
| |
| 27 enum AutoConnectWithWritePolicy { | |
| 28 AUTO_CONNECT_USE_DEFAULT, | |
| 29 AUTO_CONNECT_ENABLED, | |
| 30 AUTO_CONNECT_DISABLED | |
|
mmenke
2014/09/09 16:03:33
So I talked to Randy - he remains a bit concerned,
Adam Rice
2014/09/10 05:39:27
At the moment "TransportSocket" always means TCP/I
Jana
2014/09/10 16:03:11
I'm fine with using this... I still think of it as
| |
| 31 }; | |
| 32 | |
| 24 class ClientSocketFactory; | 33 class ClientSocketFactory; |
| 25 | 34 |
| 26 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)> | 35 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)> |
| 27 OnHostResolutionCallback; | 36 OnHostResolutionCallback; |
| 28 | 37 |
| 29 class NET_EXPORT_PRIVATE TransportSocketParams | 38 class NET_EXPORT_PRIVATE TransportSocketParams |
| 30 : public base::RefCounted<TransportSocketParams> { | 39 : public base::RefCounted<TransportSocketParams> { |
| 31 public: | 40 public: |
| 32 // |host_resolution_callback| will be invoked after the the hostname is | 41 // |host_resolution_callback| will be invoked after the the hostname is |
| 33 // resolved. If |host_resolution_callback| does not return OK, then the | 42 // resolved. If |host_resolution_callback| does not return OK, then the |
| 34 // connection will be aborted with that value. | 43 // connection will be aborted with that value. |
| 35 TransportSocketParams( | 44 TransportSocketParams( |
| 36 const HostPortPair& host_port_pair, | 45 const HostPortPair& host_port_pair, |
| 37 bool disable_resolver_cache, | 46 bool disable_resolver_cache, |
| 38 bool ignore_limits, | 47 bool ignore_limits, |
| 39 const OnHostResolutionCallback& host_resolution_callback); | 48 const OnHostResolutionCallback& host_resolution_callback); |
|
mmenke
2014/09/09 16:03:33
Can you get rid of this? Looks like you've update
Jana
2014/09/10 16:03:11
Ah -- oversight. Done. I had already combined the
| |
| 40 | 49 |
| 50 // Same as above with one additional boolean to enable use of TCP FastOpen. | |
| 51 TransportSocketParams( | |
| 52 const HostPortPair& host_port_pair, | |
| 53 bool disable_resolver_cache, | |
| 54 bool ignore_limits, | |
| 55 const OnHostResolutionCallback& host_resolution_callback, | |
| 56 AutoConnectWithWritePolicy auto_connect_with_write_if_supported); | |
| 57 | |
| 41 const HostResolver::RequestInfo& destination() const { return destination_; } | 58 const HostResolver::RequestInfo& destination() const { return destination_; } |
| 42 bool ignore_limits() const { return ignore_limits_; } | 59 bool ignore_limits() const { return ignore_limits_; } |
| 43 const OnHostResolutionCallback& host_resolution_callback() const { | 60 const OnHostResolutionCallback& host_resolution_callback() const { |
| 44 return host_resolution_callback_; | 61 return host_resolution_callback_; |
| 45 } | 62 } |
| 46 | 63 |
| 64 AutoConnectWithWritePolicy auto_connect_with_write() const { | |
| 65 return auto_connect_with_write_; | |
| 66 } | |
| 67 | |
| 47 private: | 68 private: |
| 48 friend class base::RefCounted<TransportSocketParams>; | 69 friend class base::RefCounted<TransportSocketParams>; |
| 49 ~TransportSocketParams(); | 70 ~TransportSocketParams(); |
| 50 | 71 |
| 51 HostResolver::RequestInfo destination_; | 72 HostResolver::RequestInfo destination_; |
| 52 bool ignore_limits_; | 73 bool ignore_limits_; |
| 53 const OnHostResolutionCallback host_resolution_callback_; | 74 const OnHostResolutionCallback host_resolution_callback_; |
| 75 AutoConnectWithWritePolicy auto_connect_with_write_; | |
| 54 | 76 |
| 55 DISALLOW_COPY_AND_ASSIGN(TransportSocketParams); | 77 DISALLOW_COPY_AND_ASSIGN(TransportSocketParams); |
| 56 }; | 78 }; |
| 57 | 79 |
| 58 // Common data and logic shared between TransportConnectJob and | 80 // Common data and logic shared between TransportConnectJob and |
| 59 // WebSocketTransportConnectJob. | 81 // WebSocketTransportConnectJob. |
| 60 class NET_EXPORT_PRIVATE TransportConnectJobHelper { | 82 class NET_EXPORT_PRIVATE TransportConnectJobHelper { |
| 61 public: | 83 public: |
| 62 enum State { | 84 enum State { |
| 63 STATE_RESOLVE_HOST, | 85 STATE_RESOLVE_HOST, |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 83 ~TransportConnectJobHelper(); | 105 ~TransportConnectJobHelper(); |
| 84 | 106 |
| 85 ClientSocketFactory* client_socket_factory() { | 107 ClientSocketFactory* client_socket_factory() { |
| 86 return client_socket_factory_; | 108 return client_socket_factory_; |
| 87 } | 109 } |
| 88 | 110 |
| 89 const AddressList& addresses() const { return addresses_; } | 111 const AddressList& addresses() const { return addresses_; } |
| 90 State next_state() const { return next_state_; } | 112 State next_state() const { return next_state_; } |
| 91 void set_next_state(State next_state) { next_state_ = next_state; } | 113 void set_next_state(State next_state) { next_state_ = next_state; } |
| 92 CompletionCallback on_io_complete() const { return on_io_complete_; } | 114 CompletionCallback on_io_complete() const { return on_io_complete_; } |
| 115 const TransportSocketParams* params() { return params_.get(); } | |
| 93 | 116 |
| 94 int DoResolveHost(RequestPriority priority, const BoundNetLog& net_log); | 117 int DoResolveHost(RequestPriority priority, const BoundNetLog& net_log); |
| 95 int DoResolveHostComplete(int result, const BoundNetLog& net_log); | 118 int DoResolveHostComplete(int result, const BoundNetLog& net_log); |
| 96 | 119 |
| 97 template <class T> | 120 template <class T> |
| 98 int DoConnectInternal(T* job); | 121 int DoConnectInternal(T* job); |
| 99 | 122 |
| 100 template <class T> | 123 template <class T> |
| 101 void SetOnIOComplete(T* job); | 124 void SetOnIOComplete(T* job); |
| 102 | 125 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 break; | 356 break; |
| 334 } | 357 } |
| 335 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 358 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
| 336 | 359 |
| 337 return rv; | 360 return rv; |
| 338 } | 361 } |
| 339 | 362 |
| 340 } // namespace net | 363 } // namespace net |
| 341 | 364 |
| 342 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 365 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |