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); | |
398 is_secure_ = is_secure; | 397 is_secure_ = is_secure; |
399 certificate_error_code_ = certificate_error_code; | 398 certificate_error_code_ = certificate_error_code; |
400 | 399 |
401 SSLClientSocket::NextProto protocol = g_default_protocol; | 400 SSLClientSocket::NextProto protocol = g_default_protocol; |
402 if (is_secure_) { | 401 if (is_secure_) { |
403 SSLClientSocket* ssl_socket = GetSSLClientSocket(); | 402 SSLClientSocket* ssl_socket = GetSSLClientSocket(); |
404 | 403 |
405 SSLClientSocket::NextProto protocol_negotiated = | 404 SSLClientSocket::NextProto protocol_negotiated = |
406 ssl_socket->protocol_negotiated(); | 405 ssl_socket->protocol_negotiated(); |
407 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { | 406 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 return connection_->socket()->GetPeerAddress(address); | 1184 return connection_->socket()->GetPeerAddress(address); |
1186 } | 1185 } |
1187 | 1186 |
1188 int SpdySession::GetLocalAddress(IPEndPoint* address) const { | 1187 int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
1189 if (!connection_->socket()) | 1188 if (!connection_->socket()) |
1190 return ERR_SOCKET_NOT_CONNECTED; | 1189 return ERR_SOCKET_NOT_CONNECTED; |
1191 | 1190 |
1192 return connection_->socket()->GetLocalAddress(address); | 1191 return connection_->socket()->GetLocalAddress(address); |
1193 } | 1192 } |
1194 | 1193 |
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 | |
1207 void SpdySession::ActivateStream(SpdyStream* stream) { | 1194 void SpdySession::ActivateStream(SpdyStream* stream) { |
1208 const spdy::SpdyStreamId id = stream->stream_id(); | 1195 const spdy::SpdyStreamId id = stream->stream_id(); |
1209 DCHECK(!IsStreamActive(id)); | 1196 DCHECK(!IsStreamActive(id)); |
1210 | 1197 |
1211 active_streams_[id] = stream; | 1198 active_streams_[id] = stream; |
1212 } | 1199 } |
1213 | 1200 |
1214 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { | 1201 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { |
1215 // For push streams, if they are being deleted normally, we leave | 1202 // For push streams, if they are being deleted normally, we leave |
1216 // the stream in the unclaimed_pushed_streams_ list. However, if | 1203 // the stream in the unclaimed_pushed_streams_ list. However, if |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1963 SSLClientSocket* SpdySession::GetSSLClientSocket() const { | 1950 SSLClientSocket* SpdySession::GetSSLClientSocket() const { |
1964 if (!is_secure_) | 1951 if (!is_secure_) |
1965 return NULL; | 1952 return NULL; |
1966 SSLClientSocket* ssl_socket = | 1953 SSLClientSocket* ssl_socket = |
1967 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 1954 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
1968 DCHECK(ssl_socket); | 1955 DCHECK(ssl_socket); |
1969 return ssl_socket; | 1956 return ssl_socket; |
1970 } | 1957 } |
1971 | 1958 |
1972 } // namespace net | 1959 } // namespace net |
OLD | NEW |