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.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 372 |
373 net::Error SpdySession::InitializeWithSocket( | 373 net::Error SpdySession::InitializeWithSocket( |
374 ClientSocketHandle* connection, | 374 ClientSocketHandle* connection, |
375 bool is_secure, | 375 bool is_secure, |
376 int certificate_error_code) { | 376 int certificate_error_code) { |
377 base::StatsCounter spdy_sessions("spdy.sessions"); | 377 base::StatsCounter spdy_sessions("spdy.sessions"); |
378 spdy_sessions.Increment(); | 378 spdy_sessions.Increment(); |
379 | 379 |
380 state_ = CONNECTED; | 380 state_ = CONNECTED; |
381 connection_.reset(connection); | 381 connection_.reset(connection); |
| 382 connection_->AddLayeredPool(this); |
382 is_secure_ = is_secure; | 383 is_secure_ = is_secure; |
383 certificate_error_code_ = certificate_error_code; | 384 certificate_error_code_ = certificate_error_code; |
384 | 385 |
385 SSLClientSocket::NextProto protocol = default_protocol_; | 386 SSLClientSocket::NextProto protocol = default_protocol_; |
386 if (is_secure_) { | 387 if (is_secure_) { |
387 SSLClientSocket* ssl_socket = GetSSLClientSocket(); | 388 SSLClientSocket* ssl_socket = GetSSLClientSocket(); |
388 | 389 |
389 SSLClientSocket::NextProto protocol_negotiated = | 390 SSLClientSocket::NextProto protocol_negotiated = |
390 ssl_socket->protocol_negotiated(); | 391 ssl_socket->protocol_negotiated(); |
391 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { | 392 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 return connection_->socket()->GetPeerAddress(address); | 1170 return connection_->socket()->GetPeerAddress(address); |
1170 } | 1171 } |
1171 | 1172 |
1172 int SpdySession::GetLocalAddress(IPEndPoint* address) const { | 1173 int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
1173 if (!connection_->socket()) | 1174 if (!connection_->socket()) |
1174 return ERR_SOCKET_NOT_CONNECTED; | 1175 return ERR_SOCKET_NOT_CONNECTED; |
1175 | 1176 |
1176 return connection_->socket()->GetLocalAddress(address); | 1177 return connection_->socket()->GetLocalAddress(address); |
1177 } | 1178 } |
1178 | 1179 |
| 1180 bool SpdySession::CloseOneIdleConnection() { |
| 1181 if (spdy_session_pool_ && num_active_streams() == 0) { |
| 1182 CHECK(HasOneRef()); |
| 1183 // Should delete this, because only the pool should have a reference. |
| 1184 RemoveFromPool(); |
| 1185 return true; |
| 1186 } |
| 1187 return false; |
| 1188 } |
| 1189 |
1179 void SpdySession::ActivateStream(SpdyStream* stream) { | 1190 void SpdySession::ActivateStream(SpdyStream* stream) { |
1180 const spdy::SpdyStreamId id = stream->stream_id(); | 1191 const spdy::SpdyStreamId id = stream->stream_id(); |
1181 DCHECK(!IsStreamActive(id)); | 1192 DCHECK(!IsStreamActive(id)); |
1182 | 1193 |
1183 active_streams_[id] = stream; | 1194 active_streams_[id] = stream; |
1184 } | 1195 } |
1185 | 1196 |
1186 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { | 1197 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { |
1187 // For push streams, if they are being deleted normally, we leave | 1198 // For push streams, if they are being deleted normally, we leave |
1188 // the stream in the unclaimed_pushed_streams_ list. However, if | 1199 // the stream in the unclaimed_pushed_streams_ list. However, if |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 SSLClientSocket* SpdySession::GetSSLClientSocket() const { | 1952 SSLClientSocket* SpdySession::GetSSLClientSocket() const { |
1942 if (!is_secure_) | 1953 if (!is_secure_) |
1943 return NULL; | 1954 return NULL; |
1944 SSLClientSocket* ssl_socket = | 1955 SSLClientSocket* ssl_socket = |
1945 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 1956 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
1946 DCHECK(ssl_socket); | 1957 DCHECK(ssl_socket); |
1947 return ssl_socket; | 1958 return ssl_socket; |
1948 } | 1959 } |
1949 | 1960 |
1950 } // namespace net | 1961 } // namespace net |
OLD | NEW |