| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 net::Error SpdySession::InitializeWithSocket( | 415 net::Error SpdySession::InitializeWithSocket( |
| 416 ClientSocketHandle* connection, | 416 ClientSocketHandle* connection, |
| 417 bool is_secure, | 417 bool is_secure, |
| 418 int certificate_error_code) { | 418 int certificate_error_code) { |
| 419 base::StatsCounter spdy_sessions("spdy.sessions"); | 419 base::StatsCounter spdy_sessions("spdy.sessions"); |
| 420 spdy_sessions.Increment(); | 420 spdy_sessions.Increment(); |
| 421 | 421 |
| 422 state_ = CONNECTED; | 422 state_ = CONNECTED; |
| 423 connection_.reset(connection); | 423 connection_.reset(connection); |
| 424 connection_->AddLayeredPool(this); | |
| 425 is_secure_ = is_secure; | 424 is_secure_ = is_secure; |
| 426 certificate_error_code_ = certificate_error_code; | 425 certificate_error_code_ = certificate_error_code; |
| 427 | 426 |
| 428 SSLClientSocket::NextProto protocol = g_default_protocol; | 427 SSLClientSocket::NextProto protocol = g_default_protocol; |
| 429 if (is_secure_) { | 428 if (is_secure_) { |
| 430 SSLClientSocket* ssl_socket = GetSSLClientSocket(); | 429 SSLClientSocket* ssl_socket = GetSSLClientSocket(); |
| 431 | 430 |
| 432 SSLClientSocket::NextProto protocol_negotiated = | 431 SSLClientSocket::NextProto protocol_negotiated = |
| 433 ssl_socket->protocol_negotiated(); | 432 ssl_socket->protocol_negotiated(); |
| 434 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { | 433 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 return connection_->socket()->GetPeerAddress(address); | 1211 return connection_->socket()->GetPeerAddress(address); |
| 1213 } | 1212 } |
| 1214 | 1213 |
| 1215 int SpdySession::GetLocalAddress(IPEndPoint* address) const { | 1214 int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
| 1216 if (!connection_->socket()) | 1215 if (!connection_->socket()) |
| 1217 return ERR_SOCKET_NOT_CONNECTED; | 1216 return ERR_SOCKET_NOT_CONNECTED; |
| 1218 | 1217 |
| 1219 return connection_->socket()->GetLocalAddress(address); | 1218 return connection_->socket()->GetLocalAddress(address); |
| 1220 } | 1219 } |
| 1221 | 1220 |
| 1222 bool SpdySession::CloseOneIdleConnection() { | |
| 1223 if (spdy_session_pool_ && num_active_streams() == 0) { | |
| 1224 bool ret = HasOneRef(); | |
| 1225 // Will remove a reference to this. | |
| 1226 RemoveFromPool(); | |
| 1227 // Since the underlying socket is only returned when |this| is destroyed | |
| 1228 // we should only return true if RemoveFromPool() removed the last ref. | |
| 1229 return ret; | |
| 1230 } | |
| 1231 return false; | |
| 1232 } | |
| 1233 | |
| 1234 void SpdySession::ActivateStream(SpdyStream* stream) { | 1221 void SpdySession::ActivateStream(SpdyStream* stream) { |
| 1235 const SpdyStreamId id = stream->stream_id(); | 1222 const SpdyStreamId id = stream->stream_id(); |
| 1236 DCHECK(!IsStreamActive(id)); | 1223 DCHECK(!IsStreamActive(id)); |
| 1237 | 1224 |
| 1238 active_streams_[id] = stream; | 1225 active_streams_[id] = stream; |
| 1239 } | 1226 } |
| 1240 | 1227 |
| 1241 void SpdySession::DeleteStream(SpdyStreamId id, int status) { | 1228 void SpdySession::DeleteStream(SpdyStreamId id, int status) { |
| 1242 // For push streams, if they are being deleted normally, we leave | 1229 // For push streams, if they are being deleted normally, we leave |
| 1243 // the stream in the unclaimed_pushed_streams_ list. However, if | 1230 // the stream in the unclaimed_pushed_streams_ list. However, if |
| (...skipping 719 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 |