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

Side by Side Diff: net/socket/ssl_client_socket_pool.cc

Issue 14471023: Refactor pooled socket request code to prepare for implementation of pretend-to-preconnect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't overload SSLSocketParams c-tor Created 7 years, 7 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
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 #include "net/socket/ssl_client_socket_pool.h" 5 #include "net/socket/ssl_client_socket_pool.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "net/base/host_port_pair.h" 12 #include "net/base/host_port_pair.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/http/http_proxy_client_socket.h" 14 #include "net/http/http_proxy_client_socket.h"
15 #include "net/http/http_proxy_client_socket_pool.h" 15 #include "net/http/http_proxy_client_socket_pool.h"
16 #include "net/socket/client_socket_factory.h" 16 #include "net/socket/client_socket_factory.h"
17 #include "net/socket/client_socket_handle.h" 17 #include "net/socket/client_socket_handle.h"
18 #include "net/socket/socks_client_socket_pool.h" 18 #include "net/socket/socks_client_socket_pool.h"
19 #include "net/socket/ssl_client_socket.h" 19 #include "net/socket/ssl_client_socket.h"
20 #include "net/socket/transport_client_socket_pool.h" 20 #include "net/socket/transport_client_socket_pool.h"
21 #include "net/ssl/ssl_cert_request_info.h" 21 #include "net/ssl/ssl_cert_request_info.h"
22 22
23 namespace net { 23 namespace net {
24 24
25 scoped_refptr<SSLSocketParams> SSLSocketParams::CreateForDirectConnection(
26 const scoped_refptr<TransportSocketParams>& transport_params,
27 const HostPortPair& host_and_port,
28 const SSLConfig& ssl_config,
29 int load_flags,
30 bool force_spdy_over_ssl,
31 bool want_spdy_over_npn)
32 {
33 return make_scoped_refptr(new SSLSocketParams(
34 transport_params,
35 NULL,
36 NULL,
37 ProxyServer::SCHEME_DIRECT,
38 host_and_port,
39 ssl_config,
40 load_flags,
41 force_spdy_over_ssl,
42 want_spdy_over_npn,
43 transport_params->ignore_limits()
44 ));
45 }
46
47 scoped_refptr<SSLSocketParams> SSLSocketParams::CreateForHttpProxy(
48 const scoped_refptr<HttpProxySocketParams>& http_proxy_params,
49 ProxyServer::Scheme proxy,
50 const HostPortPair& host_and_port,
51 const SSLConfig& ssl_config,
52 int load_flags,
53 bool force_spdy_over_ssl,
54 bool want_spdy_over_npn) {
55 DCHECK(proxy == ProxyServer::SCHEME_HTTP ||
56 proxy == ProxyServer::SCHEME_HTTPS);
57
58 return make_scoped_refptr(new SSLSocketParams(
59 NULL,
60 NULL,
61 http_proxy_params,
62 proxy,
63 host_and_port,
64 ssl_config,
65 load_flags,
66 force_spdy_over_ssl,
67 want_spdy_over_npn,
68 http_proxy_params->ignore_limits()
69 ));
70 }
71
72 scoped_refptr<SSLSocketParams> SSLSocketParams::CreateForSocksProxy(
73 const scoped_refptr<SOCKSSocketParams>& socks_params,
74 ProxyServer::Scheme proxy,
75 const HostPortPair& host_and_port,
76 const SSLConfig& ssl_config,
77 int load_flags,
78 bool force_spdy_over_ssl,
79 bool want_spdy_over_npn) {
80 DCHECK(proxy == ProxyServer::SCHEME_SOCKS4 ||
81 proxy == ProxyServer::SCHEME_SOCKS5);
82
83 return make_scoped_refptr(new SSLSocketParams(
84 NULL,
85 socks_params,
86 NULL,
87 proxy,
88 host_and_port,
89 ssl_config,
90 load_flags,
91 force_spdy_over_ssl,
92 want_spdy_over_npn,
93 socks_params->ignore_limits()
94 ));
95 }
96
25 SSLSocketParams::SSLSocketParams( 97 SSLSocketParams::SSLSocketParams(
26 const scoped_refptr<TransportSocketParams>& transport_params, 98 const scoped_refptr<TransportSocketParams>& transport_params,
27 const scoped_refptr<SOCKSSocketParams>& socks_params, 99 const scoped_refptr<SOCKSSocketParams>& socks_params,
28 const scoped_refptr<HttpProxySocketParams>& http_proxy_params, 100 const scoped_refptr<HttpProxySocketParams>& http_proxy_params,
29 ProxyServer::Scheme proxy, 101 ProxyServer::Scheme proxy,
30 const HostPortPair& host_and_port, 102 const HostPortPair& host_and_port,
31 const SSLConfig& ssl_config, 103 const SSLConfig& ssl_config,
32 int load_flags, 104 int load_flags,
33 bool force_spdy_over_ssl, 105 bool force_spdy_over_ssl,
34 bool want_spdy_over_npn) 106 bool want_spdy_over_npn,
107 bool ignore_limits)
35 : transport_params_(transport_params), 108 : transport_params_(transport_params),
36 http_proxy_params_(http_proxy_params), 109 http_proxy_params_(http_proxy_params),
37 socks_params_(socks_params), 110 socks_params_(socks_params),
38 proxy_(proxy), 111 proxy_(proxy),
39 host_and_port_(host_and_port), 112 host_and_port_(host_and_port),
40 ssl_config_(ssl_config), 113 ssl_config_(ssl_config),
41 load_flags_(load_flags), 114 load_flags_(load_flags),
42 force_spdy_over_ssl_(force_spdy_over_ssl), 115 force_spdy_over_ssl_(force_spdy_over_ssl),
43 want_spdy_over_npn_(want_spdy_over_npn), 116 want_spdy_over_npn_(want_spdy_over_npn),
44 ignore_limits_(false) { 117 ignore_limits_(ignore_limits) {
45 switch (proxy_) { 118 switch (proxy_) {
46 case ProxyServer::SCHEME_DIRECT: 119 case ProxyServer::SCHEME_DIRECT:
47 DCHECK(transport_params_.get() != NULL); 120 DCHECK(transport_params_.get() != NULL);
48 DCHECK(http_proxy_params_.get() == NULL); 121 DCHECK(http_proxy_params_.get() == NULL);
49 DCHECK(socks_params_.get() == NULL); 122 DCHECK(socks_params_.get() == NULL);
50 ignore_limits_ = transport_params_->ignore_limits();
51 break; 123 break;
52 case ProxyServer::SCHEME_HTTP: 124 case ProxyServer::SCHEME_HTTP:
53 case ProxyServer::SCHEME_HTTPS: 125 case ProxyServer::SCHEME_HTTPS:
54 DCHECK(transport_params_.get() == NULL); 126 DCHECK(transport_params_.get() == NULL);
55 DCHECK(http_proxy_params_.get() != NULL); 127 DCHECK(http_proxy_params_.get() != NULL);
56 DCHECK(socks_params_.get() == NULL); 128 DCHECK(socks_params_.get() == NULL);
57 ignore_limits_ = http_proxy_params_->ignore_limits();
58 break; 129 break;
59 case ProxyServer::SCHEME_SOCKS4: 130 case ProxyServer::SCHEME_SOCKS4:
60 case ProxyServer::SCHEME_SOCKS5: 131 case ProxyServer::SCHEME_SOCKS5:
61 DCHECK(transport_params_.get() == NULL); 132 DCHECK(transport_params_.get() == NULL);
62 DCHECK(http_proxy_params_.get() == NULL); 133 DCHECK(http_proxy_params_.get() == NULL);
63 DCHECK(socks_params_.get() != NULL); 134 DCHECK(socks_params_.get() != NULL);
64 ignore_limits_ = socks_params_->ignore_limits();
65 break; 135 break;
66 default: 136 default:
67 LOG(DFATAL) << "unknown proxy type"; 137 LOG(DFATAL) << "unknown proxy type";
68 break; 138 break;
69 } 139 }
70 } 140 }
71 141
72 SSLSocketParams::~SSLSocketParams() {} 142 SSLSocketParams::~SSLSocketParams() {}
73 143
74 // Timeout for the SSL handshake portion of the connect. 144 // Timeout for the SSL handshake portion of the connect.
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 FlushWithError(ERR_NETWORK_CHANGED); 692 FlushWithError(ERR_NETWORK_CHANGED);
623 } 693 }
624 694
625 bool SSLClientSocketPool::CloseOneIdleConnection() { 695 bool SSLClientSocketPool::CloseOneIdleConnection() {
626 if (base_.CloseOneIdleSocket()) 696 if (base_.CloseOneIdleSocket())
627 return true; 697 return true;
628 return base_.CloseOneIdleConnectionInLayeredPool(); 698 return base_.CloseOneIdleConnectionInLayeredPool();
629 } 699 }
630 700
631 } // namespace net 701 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698