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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 387 |
388 net::Error SpdySession::InitializeWithSocket( | 388 net::Error SpdySession::InitializeWithSocket( |
389 ClientSocketHandle* connection, | 389 ClientSocketHandle* connection, |
390 bool is_secure, | 390 bool is_secure, |
391 int certificate_error_code) { | 391 int certificate_error_code) { |
392 base::StatsCounter spdy_sessions("spdy.sessions"); | 392 base::StatsCounter spdy_sessions("spdy.sessions"); |
393 spdy_sessions.Increment(); | 393 spdy_sessions.Increment(); |
394 | 394 |
395 state_ = CONNECTED; | 395 state_ = CONNECTED; |
396 connection_.reset(connection); | 396 connection_.reset(connection); |
| 397 connection_->AddLayeredPool(this); |
397 is_secure_ = is_secure; | 398 is_secure_ = is_secure; |
398 certificate_error_code_ = certificate_error_code; | 399 certificate_error_code_ = certificate_error_code; |
399 | 400 |
400 SSLClientSocket::NextProto protocol = g_default_protocol; | 401 SSLClientSocket::NextProto protocol = g_default_protocol; |
401 if (is_secure_) { | 402 if (is_secure_) { |
402 SSLClientSocket* ssl_socket = GetSSLClientSocket(); | 403 SSLClientSocket* ssl_socket = GetSSLClientSocket(); |
403 | 404 |
404 SSLClientSocket::NextProto protocol_negotiated = | 405 SSLClientSocket::NextProto protocol_negotiated = |
405 ssl_socket->protocol_negotiated(); | 406 ssl_socket->protocol_negotiated(); |
406 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { | 407 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 return connection_->socket()->GetPeerAddress(address); | 1185 return connection_->socket()->GetPeerAddress(address); |
1185 } | 1186 } |
1186 | 1187 |
1187 int SpdySession::GetLocalAddress(IPEndPoint* address) const { | 1188 int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
1188 if (!connection_->socket()) | 1189 if (!connection_->socket()) |
1189 return ERR_SOCKET_NOT_CONNECTED; | 1190 return ERR_SOCKET_NOT_CONNECTED; |
1190 | 1191 |
1191 return connection_->socket()->GetLocalAddress(address); | 1192 return connection_->socket()->GetLocalAddress(address); |
1192 } | 1193 } |
1193 | 1194 |
| 1195 bool SpdySession::CloseOneIdleConnection() { |
| 1196 if (spdy_session_pool_ && num_active_streams() == 0) { |
| 1197 bool ret = HasOneRef(); |
| 1198 // Will remove a reference to this. |
| 1199 RemoveFromPool(); |
| 1200 // Since the underlying socket is only returned when |this| is destroyed |
| 1201 // we should only return true if RemoveFromPool() removed the last ref. |
| 1202 return ret; |
| 1203 } |
| 1204 return false; |
| 1205 } |
| 1206 |
1194 void SpdySession::ActivateStream(SpdyStream* stream) { | 1207 void SpdySession::ActivateStream(SpdyStream* stream) { |
1195 const spdy::SpdyStreamId id = stream->stream_id(); | 1208 const spdy::SpdyStreamId id = stream->stream_id(); |
1196 DCHECK(!IsStreamActive(id)); | 1209 DCHECK(!IsStreamActive(id)); |
1197 | 1210 |
1198 active_streams_[id] = stream; | 1211 active_streams_[id] = stream; |
1199 } | 1212 } |
1200 | 1213 |
1201 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { | 1214 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { |
1202 // For push streams, if they are being deleted normally, we leave | 1215 // For push streams, if they are being deleted normally, we leave |
1203 // the stream in the unclaimed_pushed_streams_ list. However, if | 1216 // the stream in the unclaimed_pushed_streams_ list. However, if |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 SSLClientSocket* SpdySession::GetSSLClientSocket() const { | 1963 SSLClientSocket* SpdySession::GetSSLClientSocket() const { |
1951 if (!is_secure_) | 1964 if (!is_secure_) |
1952 return NULL; | 1965 return NULL; |
1953 SSLClientSocket* ssl_socket = | 1966 SSLClientSocket* ssl_socket = |
1954 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 1967 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
1955 DCHECK(ssl_socket); | 1968 DCHECK(ssl_socket); |
1956 return ssl_socket; | 1969 return ssl_socket; |
1957 } | 1970 } |
1958 | 1971 |
1959 } // namespace net | 1972 } // namespace net |
OLD | NEW |