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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 return OK; | 749 return OK; |
750 } | 750 } |
751 | 751 |
752 void SpdySession::CancelStreamRequest( | 752 void SpdySession::CancelStreamRequest( |
753 const base::WeakPtr<SpdyStreamRequest>& request) { | 753 const base::WeakPtr<SpdyStreamRequest>& request) { |
754 DCHECK(request); | 754 DCHECK(request); |
755 RequestPriority priority = request->priority(); | 755 RequestPriority priority = request->priority(); |
756 CHECK_GE(priority, MINIMUM_PRIORITY); | 756 CHECK_GE(priority, MINIMUM_PRIORITY); |
757 CHECK_LE(priority, MAXIMUM_PRIORITY); | 757 CHECK_LE(priority, MAXIMUM_PRIORITY); |
758 | 758 |
759 if (DCHECK_IS_ON()) { | 759 #if DCHECK_IS_ON |
760 // |request| should not be in a queue not matching its priority. | 760 // |request| should not be in a queue not matching its priority. |
761 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { | 761 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { |
762 if (priority == i) | 762 if (priority == i) |
763 continue; | 763 continue; |
764 PendingStreamRequestQueue* queue = &pending_create_stream_queues_[i]; | 764 PendingStreamRequestQueue* queue = &pending_create_stream_queues_[i]; |
765 DCHECK(std::find_if(queue->begin(), | 765 DCHECK(std::find_if(queue->begin(), |
766 queue->end(), | 766 queue->end(), |
767 RequestEquals(request)) == queue->end()); | 767 RequestEquals(request)) == queue->end()); |
768 } | |
769 } | 768 } |
| 769 #endif |
770 | 770 |
771 PendingStreamRequestQueue* queue = | 771 PendingStreamRequestQueue* queue = |
772 &pending_create_stream_queues_[priority]; | 772 &pending_create_stream_queues_[priority]; |
773 // Remove |request| from |queue| while preserving the order of the | 773 // Remove |request| from |queue| while preserving the order of the |
774 // other elements. | 774 // other elements. |
775 PendingStreamRequestQueue::iterator it = | 775 PendingStreamRequestQueue::iterator it = |
776 std::find_if(queue->begin(), queue->end(), RequestEquals(request)); | 776 std::find_if(queue->begin(), queue->end(), RequestEquals(request)); |
777 // The request may already be removed if there's a | 777 // The request may already be removed if there's a |
778 // CompleteStreamRequest() in flight. | 778 // CompleteStreamRequest() in flight. |
779 if (it != queue->end()) { | 779 if (it != queue->end()) { |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 in_flight_write_frame_size_ = 0; | 1452 in_flight_write_frame_size_ = 0; |
1453 in_flight_write_stream_.reset(); | 1453 in_flight_write_stream_.reset(); |
1454 } | 1454 } |
1455 } | 1455 } |
1456 | 1456 |
1457 write_state_ = WRITE_STATE_DO_WRITE; | 1457 write_state_ = WRITE_STATE_DO_WRITE; |
1458 return OK; | 1458 return OK; |
1459 } | 1459 } |
1460 | 1460 |
1461 void SpdySession::DcheckGoingAway() const { | 1461 void SpdySession::DcheckGoingAway() const { |
| 1462 #if DCHECK_IS_ON |
1462 DCHECK_GE(availability_state_, STATE_GOING_AWAY); | 1463 DCHECK_GE(availability_state_, STATE_GOING_AWAY); |
1463 if (DCHECK_IS_ON()) { | 1464 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { |
1464 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { | 1465 DCHECK(pending_create_stream_queues_[i].empty()); |
1465 DCHECK(pending_create_stream_queues_[i].empty()); | |
1466 } | |
1467 } | 1466 } |
1468 DCHECK(created_streams_.empty()); | 1467 DCHECK(created_streams_.empty()); |
| 1468 #endif |
1469 } | 1469 } |
1470 | 1470 |
1471 void SpdySession::DcheckClosed() const { | 1471 void SpdySession::DcheckClosed() const { |
1472 DcheckGoingAway(); | 1472 DcheckGoingAway(); |
1473 DCHECK_EQ(availability_state_, STATE_CLOSED); | 1473 DCHECK_EQ(availability_state_, STATE_CLOSED); |
1474 DCHECK_LT(error_on_close_, ERR_IO_PENDING); | 1474 DCHECK_LT(error_on_close_, ERR_IO_PENDING); |
1475 DCHECK(active_streams_.empty()); | 1475 DCHECK(active_streams_.empty()); |
1476 DCHECK(unclaimed_pushed_streams_.empty()); | 1476 DCHECK(unclaimed_pushed_streams_.empty()); |
1477 DCHECK(write_queue_.IsEmpty()); | 1477 DCHECK(write_queue_.IsEmpty()); |
1478 } | 1478 } |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3007 void SpdySession::ResumeSendStalledStreams() { | 3007 void SpdySession::ResumeSendStalledStreams() { |
3008 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3008 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
3009 | 3009 |
3010 // We don't have to worry about new streams being queued, since | 3010 // We don't have to worry about new streams being queued, since |
3011 // doing so would cause IsSendStalled() to return true. But we do | 3011 // doing so would cause IsSendStalled() to return true. But we do |
3012 // have to worry about streams being closed, as well as ourselves | 3012 // have to worry about streams being closed, as well as ourselves |
3013 // being closed. | 3013 // being closed. |
3014 | 3014 |
3015 while (availability_state_ != STATE_CLOSED && !IsSendStalled()) { | 3015 while (availability_state_ != STATE_CLOSED && !IsSendStalled()) { |
3016 size_t old_size = 0; | 3016 size_t old_size = 0; |
3017 if (DCHECK_IS_ON()) | 3017 #if DCHECK_IS_ON |
3018 old_size = GetTotalSize(stream_send_unstall_queue_); | 3018 old_size = GetTotalSize(stream_send_unstall_queue_); |
| 3019 #endif |
3019 | 3020 |
3020 SpdyStreamId stream_id = PopStreamToPossiblyResume(); | 3021 SpdyStreamId stream_id = PopStreamToPossiblyResume(); |
3021 if (stream_id == 0) | 3022 if (stream_id == 0) |
3022 break; | 3023 break; |
3023 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); | 3024 ActiveStreamMap::const_iterator it = active_streams_.find(stream_id); |
3024 // The stream may actually still be send-stalled after this (due | 3025 // The stream may actually still be send-stalled after this (due |
3025 // to its own send window) but that's okay -- it'll then be | 3026 // to its own send window) but that's okay -- it'll then be |
3026 // resumed once its send window increases. | 3027 // resumed once its send window increases. |
3027 if (it != active_streams_.end()) | 3028 if (it != active_streams_.end()) |
3028 it->second.stream->PossiblyResumeIfSendStalled(); | 3029 it->second.stream->PossiblyResumeIfSendStalled(); |
(...skipping 10 matching lines...) Expand all Loading... |
3039 if (!queue->empty()) { | 3040 if (!queue->empty()) { |
3040 SpdyStreamId stream_id = queue->front(); | 3041 SpdyStreamId stream_id = queue->front(); |
3041 queue->pop_front(); | 3042 queue->pop_front(); |
3042 return stream_id; | 3043 return stream_id; |
3043 } | 3044 } |
3044 } | 3045 } |
3045 return 0; | 3046 return 0; |
3046 } | 3047 } |
3047 | 3048 |
3048 } // namespace net | 3049 } // namespace net |
OLD | NEW |