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 #include "net/spdy/spdy_session_pool.h" | 5 #include "net/spdy/spdy_session_pool.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 SpdySessionPool::SpdySessionPool( | 31 SpdySessionPool::SpdySessionPool( |
32 HostResolver* resolver, | 32 HostResolver* resolver, |
33 SSLConfigService* ssl_config_service, | 33 SSLConfigService* ssl_config_service, |
34 const base::WeakPtr<HttpServerProperties>& http_server_properties, | 34 const base::WeakPtr<HttpServerProperties>& http_server_properties, |
35 TransportSecurityState* transport_security_state, | 35 TransportSecurityState* transport_security_state, |
36 bool force_single_domain, | 36 bool force_single_domain, |
37 bool enable_compression, | 37 bool enable_compression, |
38 bool enable_ping_based_connection_checking, | 38 bool enable_ping_based_connection_checking, |
39 NextProto default_protocol, | 39 NextProto default_protocol, |
40 size_t stream_initial_recv_window_size, | 40 size_t session_max_recv_window_size, |
| 41 size_t stream_max_recv_window_size, |
41 size_t initial_max_concurrent_streams, | 42 size_t initial_max_concurrent_streams, |
42 size_t max_concurrent_streams_limit, | 43 size_t max_concurrent_streams_limit, |
43 SpdySessionPool::TimeFunc time_func, | 44 SpdySessionPool::TimeFunc time_func, |
44 const std::string& trusted_spdy_proxy) | 45 const std::string& trusted_spdy_proxy) |
45 : http_server_properties_(http_server_properties), | 46 : http_server_properties_(http_server_properties), |
46 transport_security_state_(transport_security_state), | 47 transport_security_state_(transport_security_state), |
47 ssl_config_service_(ssl_config_service), | 48 ssl_config_service_(ssl_config_service), |
48 resolver_(resolver), | 49 resolver_(resolver), |
49 verify_domain_authentication_(true), | 50 verify_domain_authentication_(true), |
50 enable_sending_initial_data_(true), | 51 enable_sending_initial_data_(true), |
51 force_single_domain_(force_single_domain), | 52 force_single_domain_(force_single_domain), |
52 enable_compression_(enable_compression), | 53 enable_compression_(enable_compression), |
53 enable_ping_based_connection_checking_( | 54 enable_ping_based_connection_checking_( |
54 enable_ping_based_connection_checking), | 55 enable_ping_based_connection_checking), |
55 // TODO(akalin): Force callers to have a valid value of | 56 // TODO(akalin): Force callers to have a valid value of |
56 // |default_protocol_|. | 57 // |default_protocol_|. |
57 default_protocol_( | 58 default_protocol_((default_protocol == kProtoUnknown) ? kProtoSPDY31 |
58 (default_protocol == kProtoUnknown) ? | 59 : default_protocol), |
59 kProtoSPDY31 : default_protocol), | 60 session_max_recv_window_size_(session_max_recv_window_size), |
60 stream_initial_recv_window_size_(stream_initial_recv_window_size), | 61 stream_max_recv_window_size_(stream_max_recv_window_size), |
61 initial_max_concurrent_streams_(initial_max_concurrent_streams), | 62 initial_max_concurrent_streams_(initial_max_concurrent_streams), |
62 max_concurrent_streams_limit_(max_concurrent_streams_limit), | 63 max_concurrent_streams_limit_(max_concurrent_streams_limit), |
63 time_func_(time_func), | 64 time_func_(time_func), |
64 trusted_spdy_proxy_( | 65 trusted_spdy_proxy_(HostPortPair::FromString(trusted_spdy_proxy)) { |
65 HostPortPair::FromString(trusted_spdy_proxy)) { | |
66 DCHECK(default_protocol_ >= kProtoSPDYMinimumVersion && | 66 DCHECK(default_protocol_ >= kProtoSPDYMinimumVersion && |
67 default_protocol_ <= kProtoSPDYMaximumVersion); | 67 default_protocol_ <= kProtoSPDYMaximumVersion); |
68 NetworkChangeNotifier::AddIPAddressObserver(this); | 68 NetworkChangeNotifier::AddIPAddressObserver(this); |
69 if (ssl_config_service_.get()) | 69 if (ssl_config_service_.get()) |
70 ssl_config_service_->AddObserver(this); | 70 ssl_config_service_->AddObserver(this); |
71 CertDatabase::GetInstance()->AddObserver(this); | 71 CertDatabase::GetInstance()->AddObserver(this); |
72 } | 72 } |
73 | 73 |
74 SpdySessionPool::~SpdySessionPool() { | 74 SpdySessionPool::~SpdySessionPool() { |
75 CloseAllSessions(); | 75 CloseAllSessions(); |
(...skipping 15 matching lines...) Expand all Loading... |
91 scoped_ptr<ClientSocketHandle> connection, | 91 scoped_ptr<ClientSocketHandle> connection, |
92 const BoundNetLog& net_log, | 92 const BoundNetLog& net_log, |
93 int certificate_error_code, | 93 int certificate_error_code, |
94 bool is_secure) { | 94 bool is_secure) { |
95 DCHECK_GE(default_protocol_, kProtoSPDYMinimumVersion); | 95 DCHECK_GE(default_protocol_, kProtoSPDYMinimumVersion); |
96 DCHECK_LE(default_protocol_, kProtoSPDYMaximumVersion); | 96 DCHECK_LE(default_protocol_, kProtoSPDYMaximumVersion); |
97 | 97 |
98 UMA_HISTOGRAM_ENUMERATION( | 98 UMA_HISTOGRAM_ENUMERATION( |
99 "Net.SpdySessionGet", IMPORTED_FROM_SOCKET, SPDY_SESSION_GET_MAX); | 99 "Net.SpdySessionGet", IMPORTED_FROM_SOCKET, SPDY_SESSION_GET_MAX); |
100 | 100 |
101 scoped_ptr<SpdySession> new_session( | 101 scoped_ptr<SpdySession> new_session(new SpdySession( |
102 new SpdySession(key, | 102 key, http_server_properties_, transport_security_state_, |
103 http_server_properties_, | 103 verify_domain_authentication_, enable_sending_initial_data_, |
104 transport_security_state_, | 104 enable_compression_, enable_ping_based_connection_checking_, |
105 verify_domain_authentication_, | 105 default_protocol_, session_max_recv_window_size_, |
106 enable_sending_initial_data_, | 106 stream_max_recv_window_size_, initial_max_concurrent_streams_, |
107 enable_compression_, | 107 max_concurrent_streams_limit_, time_func_, trusted_spdy_proxy_, |
108 enable_ping_based_connection_checking_, | 108 net_log.net_log())); |
109 default_protocol_, | |
110 stream_initial_recv_window_size_, | |
111 initial_max_concurrent_streams_, | |
112 max_concurrent_streams_limit_, | |
113 time_func_, | |
114 trusted_spdy_proxy_, | |
115 net_log.net_log())); | |
116 | 109 |
117 new_session->InitializeWithSocket( | 110 new_session->InitializeWithSocket( |
118 connection.Pass(), this, is_secure, certificate_error_code); | 111 connection.Pass(), this, is_secure, certificate_error_code); |
119 | 112 |
120 base::WeakPtr<SpdySession> available_session = new_session->GetWeakPtr(); | 113 base::WeakPtr<SpdySession> available_session = new_session->GetWeakPtr(); |
121 sessions_.insert(new_session.release()); | 114 sessions_.insert(new_session.release()); |
122 MapKeyToAvailableSession(key, available_session); | 115 MapKeyToAvailableSession(key, available_session); |
123 | 116 |
124 net_log.AddEvent( | 117 net_log.AddEvent( |
125 NetLog::TYPE_HTTP2_SESSION_POOL_IMPORTED_SESSION_FROM_SOCKET, | 118 NetLog::TYPE_HTTP2_SESSION_POOL_IMPORTED_SESSION_FROM_SOCKET, |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 392 |
400 if (idle_only && (*it)->is_active()) | 393 if (idle_only && (*it)->is_active()) |
401 continue; | 394 continue; |
402 | 395 |
403 (*it)->CloseSessionOnError(error, description); | 396 (*it)->CloseSessionOnError(error, description); |
404 DCHECK(!IsSessionAvailable(*it)); | 397 DCHECK(!IsSessionAvailable(*it)); |
405 } | 398 } |
406 } | 399 } |
407 | 400 |
408 } // namespace net | 401 } // namespace net |
OLD | NEW |