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, close the |
| 1064 // session to free up a socket slot. |
| 1065 if (active_streams_.empty() && connection_->IsPoolStalled()) { |
| 1066 CloseSessionResult result = |
| 1067 DoCloseSession(ERR_CONNECTION_CLOSED, "Closing idle connection."); |
| 1068 DCHECK_NE(result, SESSION_ALREADY_CLOSED); |
| 1069 } |
1054 } | 1070 } |
1055 | 1071 |
1056 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it, | 1072 void SpdySession::CloseCreatedStreamIterator(CreatedStreamSet::iterator it, |
1057 int status) { | 1073 int status) { |
1058 scoped_ptr<SpdyStream> owned_stream(*it); | 1074 scoped_ptr<SpdyStream> owned_stream(*it); |
1059 created_streams_.erase(it); | 1075 created_streams_.erase(it); |
1060 DeleteStream(owned_stream.Pass(), status); | 1076 DeleteStream(owned_stream.Pass(), status); |
1061 } | 1077 } |
1062 | 1078 |
1063 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it, | 1079 void SpdySession::ResetStreamIterator(ActiveStreamMap::iterator it, |
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 if (!queue->empty()) { | 2935 if (!queue->empty()) { |
2920 SpdyStreamId stream_id = queue->front(); | 2936 SpdyStreamId stream_id = queue->front(); |
2921 queue->pop_front(); | 2937 queue->pop_front(); |
2922 return stream_id; | 2938 return stream_id; |
2923 } | 2939 } |
2924 } | 2940 } |
2925 return 0; | 2941 return 0; |
2926 } | 2942 } |
2927 | 2943 |
2928 } // namespace net | 2944 } // namespace net |
OLD | NEW |