Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 | 510 |
| 511 net_log_.AddEvent( | 511 net_log_.AddEvent( |
| 512 NetLog::TYPE_SPDY_SESSION_INITIALIZED, | 512 NetLog::TYPE_SPDY_SESSION_INITIALIZED, |
| 513 connection_->socket()->NetLog().source().ToEventParametersCallback()); | 513 connection_->socket()->NetLog().source().ToEventParametersCallback()); |
| 514 | 514 |
| 515 int error = DoReadLoop(READ_STATE_DO_READ, OK); | 515 int error = DoReadLoop(READ_STATE_DO_READ, OK); |
| 516 if (error == ERR_IO_PENDING) | 516 if (error == ERR_IO_PENDING) |
| 517 error = OK; | 517 error = OK; |
| 518 if (error == OK) { | 518 if (error == OK) { |
| 519 DCHECK_NE(availability_state_, STATE_CLOSED); | 519 DCHECK_NE(availability_state_, STATE_CLOSED); |
| 520 connection_->AddLayeredPool(this); | 520 connection_->AddHigherLayeredPool(this); |
| 521 if (enable_sending_initial_data_) | 521 if (enable_sending_initial_data_) |
| 522 SendInitialData(); | 522 SendInitialData(); |
| 523 pool_ = pool; | 523 pool_ = pool; |
| 524 } else { | 524 } else { |
| 525 DcheckClosed(); | 525 DcheckClosed(); |
| 526 } | 526 } |
| 527 return static_cast<Error>(error); | 527 return static_cast<Error>(error); |
| 528 } | 528 } |
| 529 | 529 |
| 530 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { | 530 bool SpdySession::VerifyDomainAuthentication(const std::string& domain) { |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1041 active_streams_.erase(it); | 1041 active_streams_.erase(it); |
| 1042 | 1042 |
| 1043 // TODO(akalin): When SpdyStream was ref-counted (and | 1043 // TODO(akalin): When SpdyStream was ref-counted (and |
| 1044 // |unclaimed_pushed_streams_| held scoped_refptr<SpdyStream>), this | 1044 // |unclaimed_pushed_streams_| held scoped_refptr<SpdyStream>), this |
| 1045 // was only done when status was not OK. This meant that pushed | 1045 // was only done when status was not OK. This meant that pushed |
| 1046 // streams can still be claimed after they're closed. This is | 1046 // streams can still be claimed after they're closed. This is |
| 1047 // probably something that we still want to support, although server | 1047 // probably something that we still want to support, although server |
| 1048 // push is hardly used. Write tests for this and fix this. (See | 1048 // push is hardly used. Write tests for this and fix this. (See |
| 1049 // http://crbug.com/261712 .) | 1049 // http://crbug.com/261712 .) |
| 1050 if (owned_stream->type() == SPDY_PUSH_STREAM) | 1050 if (owned_stream->type() == SPDY_PUSH_STREAM) |
| 1051 unclaimed_pushed_streams_.erase(owned_stream->url()); | 1051 unclaimed_pushed_streams_.erase(owned_stream->url()); |
| 1052 | |
| 1053 base::WeakPtr<SpdySession> weak_this = GetWeakPtr(); | |
| 1052 | 1054 |
| 1053 DeleteStream(owned_stream.Pass(), status); | 1055 DeleteStream(owned_stream.Pass(), status); |
| 1056 | |
| 1057 if (!weak_this) | |
| 1058 return; | |
| 1059 | |
| 1060 if (availability_state_ == STATE_CLOSED) | |
| 1061 return; | |
| 1062 | |
| 1063 // If there are no active streams, and the socket pool is stalled, try to free | |
|
akalin
2013/08/21 21:01:18
I think the comment could be a bit clearer:
// If
mmenke
2013/08/21 21:10:08
Done.
| |
| 1064 // up a socket slot. | |
| 1065 if (active_streams_.empty() && connection_->IsPoolStalled()) | |
| 1066 CloseIfIdle(); | |
|
akalin
2013/08/21 21:01:18
can you remove CloseIfIdle and just inline the cod
mmenke
2013/08/21 21:10:08
Done. I also got rid of the check that pool_ is n
| |
| 1054 } | 1067 } |
| 1055 | 1068 |
| 1056 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it, | 1069 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it, |
| 1057 int status) { | 1070 int status) { |
| 1058 scoped_ptr<SpdyStream> owned_stream(*it); | 1071 scoped_ptr<SpdyStream> owned_stream(*it); |
| 1059 created_streams_.erase(it); | 1072 created_streams_.erase(it); |
| 1060 DeleteStream(owned_stream.Pass(), status); | 1073 DeleteStream(owned_stream.Pass(), status); |
| 1061 } | 1074 } |
| 1062 | 1075 |
| 1063 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it, | 1076 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it, |
| (...skipping 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2918 std::deque<SpdyStreamId>* queue = &stream_send_unstall_queue_[i]; | 2931 std::deque<SpdyStreamId>* queue = &stream_send_unstall_queue_[i]; |
| 2919 if (!queue->empty()) { | 2932 if (!queue->empty()) { |
| 2920 SpdyStreamId stream_id = queue->front(); | 2933 SpdyStreamId stream_id = queue->front(); |
| 2921 queue->pop_front(); | 2934 queue->pop_front(); |
| 2922 return stream_id; | 2935 return stream_id; |
| 2923 } | 2936 } |
| 2924 } | 2937 } |
| 2925 return 0; | 2938 return 0; |
| 2926 } | 2939 } |
| 2927 | 2940 |
| 2941 void SpdySession::CloseIfIdle() { | |
| 2942 // If the session isn't idle, or it has already been closed, do nothing. | |
| 2943 if (!active_streams_.empty() || availability_state_ == STATE_CLOSED || !pool_) | |
| 2944 return; | |
| 2945 DoCloseSession(ERR_CONNECTION_CLOSED, "Closing idle connection."); | |
| 2946 } | |
| 2947 | |
| 2928 } // namespace net | 2948 } // namespace net |
| OLD | NEW |