Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: net/spdy/spdy_session.cc

Issue 9667016: Close idle connections / SPDY sessions when needed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address mmenke's comments Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_spdy2_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | net/spdy/spdy_session_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698