Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: net/spdy/spdy_write_queue.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/spdy/spdy_buffer.h" 10 #include "net/spdy/spdy_buffer.h"
11 #include "net/spdy/spdy_buffer_producer.h" 11 #include "net/spdy/spdy_buffer_producer.h"
12 #include "net/spdy/spdy_stream.h" 12 #include "net/spdy/spdy_stream.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 SpdyWriteQueue::PendingWrite::PendingWrite() : frame_producer(NULL) {} 16 SpdyWriteQueue::PendingWrite::PendingWrite() : frame_producer(NULL) {
17 }
17 18
18 SpdyWriteQueue::PendingWrite::PendingWrite( 19 SpdyWriteQueue::PendingWrite::PendingWrite(
19 SpdyFrameType frame_type, 20 SpdyFrameType frame_type,
20 SpdyBufferProducer* frame_producer, 21 SpdyBufferProducer* frame_producer,
21 const base::WeakPtr<SpdyStream>& stream) 22 const base::WeakPtr<SpdyStream>& stream)
22 : frame_type(frame_type), 23 : frame_type(frame_type),
23 frame_producer(frame_producer), 24 frame_producer(frame_producer),
24 stream(stream), 25 stream(stream),
25 has_stream(stream.get() != NULL) {} 26 has_stream(stream.get() != NULL) {
27 }
26 28
27 SpdyWriteQueue::PendingWrite::~PendingWrite() {} 29 SpdyWriteQueue::PendingWrite::~PendingWrite() {
30 }
28 31
29 SpdyWriteQueue::SpdyWriteQueue() : removing_writes_(false) {} 32 SpdyWriteQueue::SpdyWriteQueue() : removing_writes_(false) {
33 }
30 34
31 SpdyWriteQueue::~SpdyWriteQueue() { 35 SpdyWriteQueue::~SpdyWriteQueue() {
32 Clear(); 36 Clear();
33 } 37 }
34 38
35 bool SpdyWriteQueue::IsEmpty() const { 39 bool SpdyWriteQueue::IsEmpty() const {
36 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; i++) { 40 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; i++) {
37 if (!queue_[i].empty()) 41 if (!queue_[i].empty())
38 return false; 42 return false;
39 } 43 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 CHECK_LE(priority, MAXIMUM_PRIORITY); 84 CHECK_LE(priority, MAXIMUM_PRIORITY);
81 85
82 DCHECK(stream.get()); 86 DCHECK(stream.get());
83 #if DCHECK_IS_ON 87 #if DCHECK_IS_ON
84 // |stream| should not have pending writes in a queue not matching 88 // |stream| should not have pending writes in a queue not matching
85 // its priority. 89 // its priority.
86 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { 90 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) {
87 if (priority == i) 91 if (priority == i)
88 continue; 92 continue;
89 for (std::deque<PendingWrite>::const_iterator it = queue_[i].begin(); 93 for (std::deque<PendingWrite>::const_iterator it = queue_[i].begin();
90 it != queue_[i].end(); ++it) { 94 it != queue_[i].end();
95 ++it) {
91 DCHECK_NE(it->stream.get(), stream.get()); 96 DCHECK_NE(it->stream.get(), stream.get());
92 } 97 }
93 } 98 }
94 #endif 99 #endif
95 100
96 // Do the actual deletion and removal, preserving FIFO-ness. 101 // Do the actual deletion and removal, preserving FIFO-ness.
97 std::deque<PendingWrite>* queue = &queue_[priority]; 102 std::deque<PendingWrite>* queue = &queue_[priority];
98 std::deque<PendingWrite>::iterator out_it = queue->begin(); 103 std::deque<PendingWrite>::iterator out_it = queue->begin();
99 for (std::deque<PendingWrite>::const_iterator it = queue->begin(); 104 for (std::deque<PendingWrite>::const_iterator it = queue->begin();
100 it != queue->end(); ++it) { 105 it != queue->end();
106 ++it) {
101 if (it->stream.get() == stream.get()) { 107 if (it->stream.get() == stream.get()) {
102 delete it->frame_producer; 108 delete it->frame_producer;
103 } else { 109 } else {
104 *out_it = *it; 110 *out_it = *it;
105 ++out_it; 111 ++out_it;
106 } 112 }
107 } 113 }
108 queue->erase(out_it, queue->end()); 114 queue->erase(out_it, queue->end());
109 removing_writes_ = false; 115 removing_writes_ = false;
110 } 116 }
111 117
112 void SpdyWriteQueue::RemovePendingWritesForStreamsAfter( 118 void SpdyWriteQueue::RemovePendingWritesForStreamsAfter(
113 SpdyStreamId last_good_stream_id) { 119 SpdyStreamId last_good_stream_id) {
114 CHECK(!removing_writes_); 120 CHECK(!removing_writes_);
115 removing_writes_ = true; 121 removing_writes_ = true;
116 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { 122 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) {
117 // Do the actual deletion and removal, preserving FIFO-ness. 123 // Do the actual deletion and removal, preserving FIFO-ness.
118 std::deque<PendingWrite>* queue = &queue_[i]; 124 std::deque<PendingWrite>* queue = &queue_[i];
119 std::deque<PendingWrite>::iterator out_it = queue->begin(); 125 std::deque<PendingWrite>::iterator out_it = queue->begin();
120 for (std::deque<PendingWrite>::const_iterator it = queue->begin(); 126 for (std::deque<PendingWrite>::const_iterator it = queue->begin();
121 it != queue->end(); ++it) { 127 it != queue->end();
128 ++it) {
122 if (it->stream.get() && (it->stream->stream_id() > last_good_stream_id || 129 if (it->stream.get() && (it->stream->stream_id() > last_good_stream_id ||
123 it->stream->stream_id() == 0)) { 130 it->stream->stream_id() == 0)) {
124 delete it->frame_producer; 131 delete it->frame_producer;
125 } else { 132 } else {
126 *out_it = *it; 133 *out_it = *it;
127 ++out_it; 134 ++out_it;
128 } 135 }
129 } 136 }
130 queue->erase(out_it, queue->end()); 137 queue->erase(out_it, queue->end());
131 } 138 }
132 removing_writes_ = false; 139 removing_writes_ = false;
133 } 140 }
134 141
135 void SpdyWriteQueue::Clear() { 142 void SpdyWriteQueue::Clear() {
136 CHECK(!removing_writes_); 143 CHECK(!removing_writes_);
137 removing_writes_ = true; 144 removing_writes_ = true;
138 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { 145 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) {
139 for (std::deque<PendingWrite>::iterator it = queue_[i].begin(); 146 for (std::deque<PendingWrite>::iterator it = queue_[i].begin();
140 it != queue_[i].end(); ++it) { 147 it != queue_[i].end();
148 ++it) {
141 delete it->frame_producer; 149 delete it->frame_producer;
142 } 150 }
143 queue_[i].clear(); 151 queue_[i].clear();
144 } 152 }
145 removing_writes_ = false; 153 removing_writes_ = false;
146 } 154 }
147 155
148 } // namespace net 156 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698