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/values.h" | 9 #include "base/values.h" |
10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // kProtoSPDY3. | 58 // kProtoSPDY3. |
59 default_protocol_( | 59 default_protocol_( |
60 (default_protocol == kProtoUnknown) ? | 60 (default_protocol == kProtoUnknown) ? |
61 kProtoSPDY2 : default_protocol), | 61 kProtoSPDY2 : default_protocol), |
62 stream_initial_recv_window_size_(stream_initial_recv_window_size), | 62 stream_initial_recv_window_size_(stream_initial_recv_window_size), |
63 initial_max_concurrent_streams_(initial_max_concurrent_streams), | 63 initial_max_concurrent_streams_(initial_max_concurrent_streams), |
64 max_concurrent_streams_limit_(max_concurrent_streams_limit), | 64 max_concurrent_streams_limit_(max_concurrent_streams_limit), |
65 time_func_(time_func), | 65 time_func_(time_func), |
66 trusted_spdy_proxy_( | 66 trusted_spdy_proxy_( |
67 HostPortPair::FromString(trusted_spdy_proxy)) { | 67 HostPortPair::FromString(trusted_spdy_proxy)) { |
68 // TODO(akalin): Change this to kProtoSPDYMinimumVersion once we | 68 DCHECK(default_protocol_ >= kProtoSPDYMinimumVersion && |
69 // stop supporting SPDY/1. | |
70 DCHECK(default_protocol_ >= kProtoSPDY2 && | |
71 default_protocol_ <= kProtoSPDYMaximumVersion); | 69 default_protocol_ <= kProtoSPDYMaximumVersion); |
72 NetworkChangeNotifier::AddIPAddressObserver(this); | 70 NetworkChangeNotifier::AddIPAddressObserver(this); |
73 if (ssl_config_service_.get()) | 71 if (ssl_config_service_.get()) |
74 ssl_config_service_->AddObserver(this); | 72 ssl_config_service_->AddObserver(this); |
75 CertDatabase::GetInstance()->AddObserver(this); | 73 CertDatabase::GetInstance()->AddObserver(this); |
76 } | 74 } |
77 | 75 |
78 SpdySessionPool::~SpdySessionPool() { | 76 SpdySessionPool::~SpdySessionPool() { |
79 CloseAllSessions(); | 77 CloseAllSessions(); |
80 | 78 |
81 if (ssl_config_service_.get()) | 79 if (ssl_config_service_.get()) |
82 ssl_config_service_->RemoveObserver(this); | 80 ssl_config_service_->RemoveObserver(this); |
83 NetworkChangeNotifier::RemoveIPAddressObserver(this); | 81 NetworkChangeNotifier::RemoveIPAddressObserver(this); |
84 CertDatabase::GetInstance()->RemoveObserver(this); | 82 CertDatabase::GetInstance()->RemoveObserver(this); |
85 } | 83 } |
86 | 84 |
87 net::Error SpdySessionPool::CreateAvailableSessionFromSocket( | 85 net::Error SpdySessionPool::CreateAvailableSessionFromSocket( |
88 const SpdySessionKey& key, | 86 const SpdySessionKey& key, |
89 scoped_ptr<ClientSocketHandle> connection, | 87 scoped_ptr<ClientSocketHandle> connection, |
90 const BoundNetLog& net_log, | 88 const BoundNetLog& net_log, |
91 int certificate_error_code, | 89 int certificate_error_code, |
92 base::WeakPtr<SpdySession>* available_session, | 90 base::WeakPtr<SpdySession>* available_session, |
93 bool is_secure) { | 91 bool is_secure) { |
94 // TODO(akalin): Change this to kProtoSPDYMinimumVersion once we | 92 DCHECK_GE(default_protocol_, kProtoSPDYMinimumVersion); |
95 // stop supporting SPDY/1. | |
96 DCHECK_GE(default_protocol_, kProtoSPDY2); | |
97 DCHECK_LE(default_protocol_, kProtoSPDYMaximumVersion); | 93 DCHECK_LE(default_protocol_, kProtoSPDYMaximumVersion); |
98 | 94 |
99 UMA_HISTOGRAM_ENUMERATION( | 95 UMA_HISTOGRAM_ENUMERATION( |
100 "Net.SpdySessionGet", IMPORTED_FROM_SOCKET, SPDY_SESSION_GET_MAX); | 96 "Net.SpdySessionGet", IMPORTED_FROM_SOCKET, SPDY_SESSION_GET_MAX); |
101 | 97 |
102 scoped_ptr<SpdySession> new_session( | 98 scoped_ptr<SpdySession> new_session( |
103 new SpdySession(key, | 99 new SpdySession(key, |
104 http_server_properties_, | 100 http_server_properties_, |
105 verify_domain_authentication_, | 101 verify_domain_authentication_, |
106 enable_sending_initial_data_, | 102 enable_sending_initial_data_, |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (idle_only && (*it)->is_active()) | 386 if (idle_only && (*it)->is_active()) |
391 continue; | 387 continue; |
392 | 388 |
393 (*it)->CloseSessionOnError(error, description); | 389 (*it)->CloseSessionOnError(error, description); |
394 DCHECK(!IsSessionAvailable(*it)); | 390 DCHECK(!IsSessionAvailable(*it)); |
395 DCHECK(!*it); | 391 DCHECK(!*it); |
396 } | 392 } |
397 } | 393 } |
398 | 394 |
399 } // namespace net | 395 } // namespace net |
OLD | NEW |