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