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

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

Issue 8825014: Revert 113300 - Revert of 112134 of Revert 112130 - Close idle connections / SPDY sessions when n... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/linked_ptr.h" 9 #include "base/memory/linked_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 net::Error SpdySession::InitializeWithSocket( 330 net::Error SpdySession::InitializeWithSocket(
331 ClientSocketHandle* connection, 331 ClientSocketHandle* connection,
332 bool is_secure, 332 bool is_secure,
333 int certificate_error_code) { 333 int certificate_error_code) {
334 base::StatsCounter spdy_sessions("spdy.sessions"); 334 base::StatsCounter spdy_sessions("spdy.sessions");
335 spdy_sessions.Increment(); 335 spdy_sessions.Increment();
336 336
337 state_ = CONNECTED; 337 state_ = CONNECTED;
338 connection_.reset(connection); 338 connection_.reset(connection);
339 connection_->AddLayeredPool(this);
340 is_secure_ = is_secure; 339 is_secure_ = is_secure;
341 certificate_error_code_ = certificate_error_code; 340 certificate_error_code_ = certificate_error_code;
342 341
343 // Write out any data that we might have to send, such as the settings frame. 342 // Write out any data that we might have to send, such as the settings frame.
344 WriteSocketLater(); 343 WriteSocketLater();
345 net::Error error = ReadSocket(); 344 net::Error error = ReadSocket();
346 if (error == ERR_IO_PENDING) 345 if (error == ERR_IO_PENDING)
347 return OK; 346 return OK;
348 return error; 347 return error;
349 } 348 }
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 return connection_->socket()->GetPeerAddress(address); 977 return connection_->socket()->GetPeerAddress(address);
979 } 978 }
980 979
981 int SpdySession::GetLocalAddress(IPEndPoint* address) const { 980 int SpdySession::GetLocalAddress(IPEndPoint* address) const {
982 if (!connection_->socket()) 981 if (!connection_->socket())
983 return ERR_SOCKET_NOT_CONNECTED; 982 return ERR_SOCKET_NOT_CONNECTED;
984 983
985 return connection_->socket()->GetLocalAddress(address); 984 return connection_->socket()->GetLocalAddress(address);
986 } 985 }
987 986
988 bool SpdySession::CloseOneIdleConnection() {
989 if (num_active_streams() == 0) {
990 // Should delete this.
991 RemoveFromPool();
992 return true;
993 }
994 return false;
995 }
996
997 void SpdySession::ActivateStream(SpdyStream* stream) { 987 void SpdySession::ActivateStream(SpdyStream* stream) {
998 const spdy::SpdyStreamId id = stream->stream_id(); 988 const spdy::SpdyStreamId id = stream->stream_id();
999 DCHECK(!IsStreamActive(id)); 989 DCHECK(!IsStreamActive(id));
1000 990
1001 active_streams_[id] = stream; 991 active_streams_[id] = stream;
1002 } 992 }
1003 993
1004 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) { 994 void SpdySession::DeleteStream(spdy::SpdyStreamId id, int status) {
1005 // For push streams, if they are being deleted normally, we leave 995 // For push streams, if they are being deleted normally, we leave
1006 // the stream in the unclaimed_pushed_streams_ list. However, if 996 // the stream in the unclaimed_pushed_streams_ list. However, if
(...skipping 14 matching lines...) Expand all
1021 ActiveStreamMap::iterator it2 = active_streams_.find(id); 1011 ActiveStreamMap::iterator it2 = active_streams_.find(id);
1022 if (it2 == active_streams_.end()) 1012 if (it2 == active_streams_.end())
1023 return; 1013 return;
1024 1014
1025 // If this is an active stream, call the callback. 1015 // If this is an active stream, call the callback.
1026 const scoped_refptr<SpdyStream> stream(it2->second); 1016 const scoped_refptr<SpdyStream> stream(it2->second);
1027 active_streams_.erase(it2); 1017 active_streams_.erase(it2);
1028 if (stream) 1018 if (stream)
1029 stream->OnClose(status); 1019 stream->OnClose(status);
1030 ProcessPendingCreateStreams(); 1020 ProcessPendingCreateStreams();
1031 if (num_active_streams() == 0 && connection_->is_initialized() &&
1032 connection_->IsPoolStalled()) {
1033 // Should delete this.
1034 RemoveFromPool();
1035 }
1036 } 1021 }
1037 1022
1038 void SpdySession::RemoveFromPool() { 1023 void SpdySession::RemoveFromPool() {
1039 if (spdy_session_pool_) { 1024 if (spdy_session_pool_) {
1040 SpdySessionPool* pool = spdy_session_pool_; 1025 spdy_session_pool_->Remove(make_scoped_refptr(this));
1041 spdy_session_pool_ = NULL; 1026 spdy_session_pool_ = NULL;
1042 pool->Remove(make_scoped_refptr(this));
1043 } 1027 }
1044 } 1028 }
1045 1029
1046 scoped_refptr<SpdyStream> SpdySession::GetActivePushStream( 1030 scoped_refptr<SpdyStream> SpdySession::GetActivePushStream(
1047 const std::string& path) { 1031 const std::string& path) {
1048 base::StatsCounter used_push_streams("spdy.claimed_push_streams"); 1032 base::StatsCounter used_push_streams("spdy.claimed_push_streams");
1049 1033
1050 PushedStreamMap::iterator it = unclaimed_pushed_streams_.find(path); 1034 PushedStreamMap::iterator it = unclaimed_pushed_streams_.find(path);
1051 if (it != unclaimed_pushed_streams_.end()) { 1035 if (it != unclaimed_pushed_streams_.end()) {
1052 net_log_.AddEvent(NetLog::TYPE_SPDY_STREAM_ADOPTED_PUSH_STREAM, NULL); 1036 net_log_.AddEvent(NetLog::TYPE_SPDY_STREAM_ADOPTED_PUSH_STREAM, NULL);
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 if (it == pending_callback_map_.end()) 1738 if (it == pending_callback_map_.end())
1755 return; 1739 return;
1756 1740
1757 OldCompletionCallback* callback = it->second.callback; 1741 OldCompletionCallback* callback = it->second.callback;
1758 int result = it->second.result; 1742 int result = it->second.result;
1759 pending_callback_map_.erase(it); 1743 pending_callback_map_.erase(it);
1760 callback->Run(result); 1744 callback->Run(result);
1761 } 1745 }
1762 1746
1763 } // namespace net 1747 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698