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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 | 372 |
373 net::Error SpdySession::InitializeWithSocket( | 373 net::Error SpdySession::InitializeWithSocket( |
374 ClientSocketHandle* connection, | 374 ClientSocketHandle* connection, |
375 bool is_secure, | 375 bool is_secure, |
376 int certificate_error_code) { | 376 int certificate_error_code) { |
377 base::StatsCounter spdy_sessions("spdy.sessions"); | 377 base::StatsCounter spdy_sessions("spdy.sessions"); |
378 spdy_sessions.Increment(); | 378 spdy_sessions.Increment(); |
379 | 379 |
380 state_ = CONNECTED; | 380 state_ = CONNECTED; |
381 connection_.reset(connection); | 381 connection_.reset(connection); |
382 connection_->AddLayeredPool(this); | |
382 is_secure_ = is_secure; | 383 is_secure_ = is_secure; |
383 certificate_error_code_ = certificate_error_code; | 384 certificate_error_code_ = certificate_error_code; |
384 | 385 |
385 SSLClientSocket::NextProto protocol = default_protocol_; | 386 SSLClientSocket::NextProto protocol = default_protocol_; |
386 if (is_secure_) { | 387 if (is_secure_) { |
387 SSLClientSocket* ssl_socket = GetSSLClientSocket(); | 388 SSLClientSocket* ssl_socket = GetSSLClientSocket(); |
388 | 389 |
389 SSLClientSocket::NextProto protocol_negotiated = | 390 SSLClientSocket::NextProto protocol_negotiated = |
390 ssl_socket->protocol_negotiated(); | 391 ssl_socket->protocol_negotiated(); |
391 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { | 392 if (protocol_negotiated != SSLClientSocket::kProtoUnknown) { |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 return connection_->socket()->GetPeerAddress(address); | 1170 return connection_->socket()->GetPeerAddress(address); |
1170 } | 1171 } |
1171 | 1172 |
1172 int SpdySession::GetLocalAddress(IPEndPoint* address) const { | 1173 int SpdySession::GetLocalAddress(IPEndPoint* address) const { |
1173 if (!connection_->socket()) | 1174 if (!connection_->socket()) |
1174 return ERR_SOCKET_NOT_CONNECTED; | 1175 return ERR_SOCKET_NOT_CONNECTED; |
1175 | 1176 |
1176 return connection_->socket()->GetLocalAddress(address); | 1177 return connection_->socket()->GetLocalAddress(address); |
1177 } | 1178 } |
1178 | 1179 |
1180 bool SpdySession::CloseOneIdleConnection() { | |
1181 if (spdy_session_pool_ && num_active_streams() == 0) { | |
1182 bool ret = HasOneRef(); | |
1183 // Will remove a reference to this. | |
1184 RemoveFromPool(); | |
1185 // Since the underlying socket it only returned when |this| is destroyed | |
mmenke
2012/03/19 19:29:28
nit: it->is
Ryan Hamilton
2012/03/19 22:34:27
Done.
| |
1186 // we should only return true if RemoveFromPool() removed the last ref. | |
1187 return ret; | |
1188 } | |
1189 return false; | |
1190 } | |
1191 | |
1179 void SpdySession::ActivateStream(SpdyStream* stream) { | 1192 void SpdySession::ActivateStream(SpdyStream* stream) { |
1180 const spdy::SpdyStreamId id = stream->stream_id(); | 1193 const spdy::SpdyStreamId id = stream->stream_id(); |
1181 DCHECK(!IsStreamActive(id)); | 1194 DCHECK(!IsStreamActive(id)); |
1182 | 1195 |
1183 active_streams_[id] = stream; | 1196 active_streams_[id] = stream; |
1184 } | 1197 } |
1185 | 1198 |
1186 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { | 1199 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { |
1187 // For push streams, if they are being deleted normally, we leave | 1200 // For push streams, if they are being deleted normally, we leave |
1188 // the stream in the unclaimed_pushed_streams_ list. However, if | 1201 // the stream in the unclaimed_pushed_streams_ list. However, if |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1941 SSLClientSocket* SpdySession::GetSSLClientSocket() const { | 1954 SSLClientSocket* SpdySession::GetSSLClientSocket() const { |
1942 if (!is_secure_) | 1955 if (!is_secure_) |
1943 return NULL; | 1956 return NULL; |
1944 SSLClientSocket* ssl_socket = | 1957 SSLClientSocket* ssl_socket = |
1945 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 1958 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
1946 DCHECK(ssl_socket); | 1959 DCHECK(ssl_socket); |
1947 return ssl_socket; | 1960 return ssl_socket; |
1948 } | 1961 } |
1949 | 1962 |
1950 } // namespace net | 1963 } // namespace net |
OLD | NEW |