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 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 return id; | 1608 return id; |
1609 } | 1609 } |
1610 | 1610 |
1611 void SpdySession::CloseSessionOnError(Error err, | 1611 void SpdySession::CloseSessionOnError(Error err, |
1612 const std::string& description) { | 1612 const std::string& description) { |
1613 // We may be called from anywhere, so we can't expect a particular | 1613 // We may be called from anywhere, so we can't expect a particular |
1614 // return value. | 1614 // return value. |
1615 ignore_result(DoCloseSession(err, description)); | 1615 ignore_result(DoCloseSession(err, description)); |
1616 } | 1616 } |
1617 | 1617 |
| 1618 void SpdySession::MakeUnavailable() { |
| 1619 if (availability_state_ < STATE_GOING_AWAY) { |
| 1620 availability_state_ = STATE_GOING_AWAY; |
| 1621 // |pool_| will be NULL when |InitializeWithSocket()| is in the |
| 1622 // call stack. |
| 1623 if (pool_) |
| 1624 pool_->MakeSessionUnavailable(GetWeakPtr()); |
| 1625 } |
| 1626 } |
| 1627 |
1618 base::Value* SpdySession::GetInfoAsValue() const { | 1628 base::Value* SpdySession::GetInfoAsValue() const { |
1619 base::DictionaryValue* dict = new base::DictionaryValue(); | 1629 base::DictionaryValue* dict = new base::DictionaryValue(); |
1620 | 1630 |
1621 dict->SetInteger("source_id", net_log_.source().id); | 1631 dict->SetInteger("source_id", net_log_.source().id); |
1622 | 1632 |
1623 dict->SetString("host_port_pair", host_port_pair().ToString()); | 1633 dict->SetString("host_port_pair", host_port_pair().ToString()); |
1624 if (!pooled_aliases_.empty()) { | 1634 if (!pooled_aliases_.empty()) { |
1625 base::ListValue* alias_list = new base::ListValue(); | 1635 base::ListValue* alias_list = new base::ListValue(); |
1626 for (std::set<SpdySessionKey>::const_iterator it = | 1636 for (std::set<SpdySessionKey>::const_iterator it = |
1627 pooled_aliases_.begin(); | 1637 pooled_aliases_.begin(); |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 | 2374 |
2365 if (availability_state_ == STATE_CLOSED) | 2375 if (availability_state_ == STATE_CLOSED) |
2366 return; | 2376 return; |
2367 | 2377 |
2368 net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_GOAWAY, | 2378 net_log_.AddEvent(NetLog::TYPE_SPDY_SESSION_GOAWAY, |
2369 base::Bind(&NetLogSpdyGoAwayCallback, | 2379 base::Bind(&NetLogSpdyGoAwayCallback, |
2370 last_accepted_stream_id, | 2380 last_accepted_stream_id, |
2371 active_streams_.size(), | 2381 active_streams_.size(), |
2372 unclaimed_pushed_streams_.size(), | 2382 unclaimed_pushed_streams_.size(), |
2373 status)); | 2383 status)); |
2374 if (availability_state_ < STATE_GOING_AWAY) { | 2384 MakeUnavailable(); |
2375 availability_state_ = STATE_GOING_AWAY; | |
2376 // |pool_| will be NULL when |InitializeWithSocket()| is in the | |
2377 // call stack. | |
2378 if (pool_) | |
2379 pool_->MakeSessionUnavailable(GetWeakPtr()); | |
2380 } | |
2381 StartGoingAway(last_accepted_stream_id, ERR_ABORTED); | 2385 StartGoingAway(last_accepted_stream_id, ERR_ABORTED); |
2382 // This is to handle the case when we already don't have any active | 2386 // This is to handle the case when we already don't have any active |
2383 // streams (i.e., StartGoingAway() did nothing). Otherwise, we have | 2387 // streams (i.e., StartGoingAway() did nothing). Otherwise, we have |
2384 // active streams and so the last one being closed will finish the | 2388 // active streams and so the last one being closed will finish the |
2385 // going away process (see DeleteStream()). | 2389 // going away process (see DeleteStream()). |
2386 MaybeFinishGoingAway(); | 2390 MaybeFinishGoingAway(); |
2387 } | 2391 } |
2388 | 2392 |
2389 void SpdySession::OnPing(uint32 unique_id) { | 2393 void SpdySession::OnPing(uint32 unique_id) { |
2390 CHECK(in_io_loop_); | 2394 CHECK(in_io_loop_); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3032 if (!queue->empty()) { | 3036 if (!queue->empty()) { |
3033 SpdyStreamId stream_id = queue->front(); | 3037 SpdyStreamId stream_id = queue->front(); |
3034 queue->pop_front(); | 3038 queue->pop_front(); |
3035 return stream_id; | 3039 return stream_id; |
3036 } | 3040 } |
3037 } | 3041 } |
3038 return 0; | 3042 return 0; |
3039 } | 3043 } |
3040 | 3044 |
3041 } // namespace net | 3045 } // namespace net |
OLD | NEW |