OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_write_queue.h" | 5 #include "net/spdy/spdy_write_queue.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 it != queue->end(); ++it) { | 110 it != queue->end(); ++it) { |
111 if (it->stream.get() == stream.get()) { | 111 if (it->stream.get() == stream.get()) { |
112 erased_buffer_producers.push_back(it->frame_producer); | 112 erased_buffer_producers.push_back(it->frame_producer); |
113 } else { | 113 } else { |
114 *out_it = *it; | 114 *out_it = *it; |
115 ++out_it; | 115 ++out_it; |
116 } | 116 } |
117 } | 117 } |
118 queue->erase(out_it, queue->end()); | 118 queue->erase(out_it, queue->end()); |
119 removing_writes_ = false; | 119 removing_writes_ = false; |
120 STLDeleteElements(&erased_buffer_producers); // Invokes callbacks. | 120 base::STLDeleteElements(&erased_buffer_producers); // Invokes callbacks. |
121 } | 121 } |
122 | 122 |
123 void SpdyWriteQueue::RemovePendingWritesForStreamsAfter( | 123 void SpdyWriteQueue::RemovePendingWritesForStreamsAfter( |
124 SpdyStreamId last_good_stream_id) { | 124 SpdyStreamId last_good_stream_id) { |
125 CHECK(!removing_writes_); | 125 CHECK(!removing_writes_); |
126 removing_writes_ = true; | 126 removing_writes_ = true; |
127 std::vector<SpdyBufferProducer*> erased_buffer_producers; | 127 std::vector<SpdyBufferProducer*> erased_buffer_producers; |
128 | 128 |
129 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { | 129 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { |
130 // Do the actual deletion and removal, preserving FIFO-ness. | 130 // Do the actual deletion and removal, preserving FIFO-ness. |
131 std::deque<PendingWrite>* queue = &queue_[i]; | 131 std::deque<PendingWrite>* queue = &queue_[i]; |
132 std::deque<PendingWrite>::iterator out_it = queue->begin(); | 132 std::deque<PendingWrite>::iterator out_it = queue->begin(); |
133 for (std::deque<PendingWrite>::const_iterator it = queue->begin(); | 133 for (std::deque<PendingWrite>::const_iterator it = queue->begin(); |
134 it != queue->end(); ++it) { | 134 it != queue->end(); ++it) { |
135 if (it->stream.get() && (it->stream->stream_id() > last_good_stream_id || | 135 if (it->stream.get() && (it->stream->stream_id() > last_good_stream_id || |
136 it->stream->stream_id() == 0)) { | 136 it->stream->stream_id() == 0)) { |
137 erased_buffer_producers.push_back(it->frame_producer); | 137 erased_buffer_producers.push_back(it->frame_producer); |
138 } else { | 138 } else { |
139 *out_it = *it; | 139 *out_it = *it; |
140 ++out_it; | 140 ++out_it; |
141 } | 141 } |
142 } | 142 } |
143 queue->erase(out_it, queue->end()); | 143 queue->erase(out_it, queue->end()); |
144 } | 144 } |
145 removing_writes_ = false; | 145 removing_writes_ = false; |
146 STLDeleteElements(&erased_buffer_producers); // Invokes callbacks. | 146 base::STLDeleteElements(&erased_buffer_producers); // Invokes callbacks. |
147 } | 147 } |
148 | 148 |
149 void SpdyWriteQueue::Clear() { | 149 void SpdyWriteQueue::Clear() { |
150 CHECK(!removing_writes_); | 150 CHECK(!removing_writes_); |
151 removing_writes_ = true; | 151 removing_writes_ = true; |
152 std::vector<SpdyBufferProducer*> erased_buffer_producers; | 152 std::vector<SpdyBufferProducer*> erased_buffer_producers; |
153 | 153 |
154 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { | 154 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { |
155 for (std::deque<PendingWrite>::iterator it = queue_[i].begin(); | 155 for (std::deque<PendingWrite>::iterator it = queue_[i].begin(); |
156 it != queue_[i].end(); ++it) { | 156 it != queue_[i].end(); ++it) { |
157 erased_buffer_producers.push_back(it->frame_producer); | 157 erased_buffer_producers.push_back(it->frame_producer); |
158 } | 158 } |
159 queue_[i].clear(); | 159 queue_[i].clear(); |
160 } | 160 } |
161 removing_writes_ = false; | 161 removing_writes_ = false; |
162 STLDeleteElements(&erased_buffer_producers); // Invokes callbacks. | 162 base::STLDeleteElements(&erased_buffer_producers); // Invokes callbacks. |
163 } | 163 } |
164 | 164 |
165 } // namespace net | 165 } // namespace net |
OLD | NEW |