| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 424 |
| 425 net::Error SpdySession::InitializeWithSocket( | 425 net::Error SpdySession::InitializeWithSocket( |
| 426 ClientSocketHandle* connection, | 426 ClientSocketHandle* connection, |
| 427 bool is_secure, | 427 bool is_secure, |
| 428 int certificate_error_code) { | 428 int certificate_error_code) { |
| 429 base::StatsCounter spdy_sessions("spdy.sessions"); | 429 base::StatsCounter spdy_sessions("spdy.sessions"); |
| 430 spdy_sessions.Increment(); | 430 spdy_sessions.Increment(); |
| 431 | 431 |
| 432 state_ = CONNECTED; | 432 state_ = CONNECTED; |
| 433 connection_.reset(connection); | 433 connection_.reset(connection); |
| 434 connection_->AddLayeredPool(this); | |
| 435 is_secure_ = is_secure; | 434 is_secure_ = is_secure; |
| 436 certificate_error_code_ = certificate_error_code; | 435 certificate_error_code_ = certificate_error_code; |
| 437 | 436 |
| 438 NextProto protocol = g_default_protocol; | 437 NextProto protocol = g_default_protocol; |
| 439 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol(); | 438 NextProto protocol_negotiated = connection->socket()->GetNegotiatedProtocol(); |
| 440 if (protocol_negotiated != kProtoUnknown) { | 439 if (protocol_negotiated != kProtoUnknown) { |
| 441 protocol = protocol_negotiated; | 440 protocol = protocol_negotiated; |
| 442 } | 441 } |
| 443 | 442 |
| 444 SSLClientSocket* ssl_socket = GetSSLClientSocket(); | 443 SSLClientSocket* ssl_socket = GetSSLClientSocket(); |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 return connection_->socket()->GetPeerAddress(address); | 1215 return connection_->socket()->GetPeerAddress(address); |
| 1217 } | 1216 } |
| 1218 | 1217 |
| 1219 int SpdySession::GetLocalAddress(IPEndPoint* address) const { | 1218 int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
| 1220 if (!connection_->socket()) | 1219 if (!connection_->socket()) |
| 1221 return ERR_SOCKET_NOT_CONNECTED; | 1220 return ERR_SOCKET_NOT_CONNECTED; |
| 1222 | 1221 |
| 1223 return connection_->socket()->GetLocalAddress(address); | 1222 return connection_->socket()->GetLocalAddress(address); |
| 1224 } | 1223 } |
| 1225 | 1224 |
| 1226 bool SpdySession::CloseOneIdleConnection() { | |
| 1227 if (spdy_session_pool_ && num_active_streams() == 0) { | |
| 1228 bool ret = HasOneRef(); | |
| 1229 // Will remove a reference to this. | |
| 1230 RemoveFromPool(); | |
| 1231 // Since the underlying socket is only returned when |this| is destroyed | |
| 1232 // we should only return true if RemoveFromPool() removed the last ref. | |
| 1233 return ret; | |
| 1234 } | |
| 1235 return false; | |
| 1236 } | |
| 1237 | |
| 1238 void SpdySession::ActivateStream(SpdyStream* stream) { | 1225 void SpdySession::ActivateStream(SpdyStream* stream) { |
| 1239 const SpdyStreamId id = stream->stream_id(); | 1226 const SpdyStreamId id = stream->stream_id(); |
| 1240 DCHECK(!IsStreamActive(id)); | 1227 DCHECK(!IsStreamActive(id)); |
| 1241 | 1228 |
| 1242 active_streams_[id] = stream; | 1229 active_streams_[id] = stream; |
| 1243 } | 1230 } |
| 1244 | 1231 |
| 1245 void SpdySession::DeleteStream(SpdyStreamId id, int status) { | 1232 void SpdySession::DeleteStream(SpdyStreamId id, int status) { |
| 1246 // For push streams, if they are being deleted normally, we leave | 1233 // For push streams, if they are being deleted normally, we leave |
| 1247 // the stream in the unclaimed_pushed_streams_ list. However, if | 1234 // the stream in the unclaimed_pushed_streams_ list. However, if |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 SSLClientSocket* SpdySession::GetSSLClientSocket() const { | 1960 SSLClientSocket* SpdySession::GetSSLClientSocket() const { |
| 1974 if (!is_secure_) | 1961 if (!is_secure_) |
| 1975 return NULL; | 1962 return NULL; |
| 1976 SSLClientSocket* ssl_socket = | 1963 SSLClientSocket* ssl_socket = |
| 1977 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 1964 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
| 1978 DCHECK(ssl_socket); | 1965 DCHECK(ssl_socket); |
| 1979 return ssl_socket; | 1966 return ssl_socket; |
| 1980 } | 1967 } |
| 1981 | 1968 |
| 1982 } // namespace net | 1969 } // namespace net |
| OLD | NEW |