| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" |
| 12 #include "net/spdy/spdy_buffer.h" | 13 #include "net/spdy/spdy_buffer.h" |
| 13 #include "net/spdy/spdy_buffer_producer.h" | 14 #include "net/spdy/spdy_buffer_producer.h" |
| 14 #include "net/spdy/spdy_stream.h" | 15 #include "net/spdy/spdy_stream.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 SpdyWriteQueue::PendingWrite::PendingWrite() {} | 19 SpdyWriteQueue::PendingWrite::PendingWrite() {} |
| 19 | 20 |
| 20 SpdyWriteQueue::PendingWrite::PendingWrite( | 21 SpdyWriteQueue::PendingWrite::PendingWrite( |
| 21 SpdyFrameType frame_type, | 22 SpdyFrameType frame_type, |
| 22 std::unique_ptr<SpdyBufferProducer> frame_producer, | 23 std::unique_ptr<SpdyBufferProducer> frame_producer, |
| 23 const base::WeakPtr<SpdyStream>& stream) | 24 const base::WeakPtr<SpdyStream>& stream) |
| 24 : frame_type(frame_type), | 25 : frame_type(frame_type), |
| 25 frame_producer(std::move(frame_producer)), | 26 frame_producer(std::move(frame_producer)), |
| 26 stream(stream), | 27 stream(stream), |
| 27 has_stream(stream.get() != nullptr) {} | 28 has_stream(stream.get() != nullptr) {} |
| 28 | 29 |
| 29 SpdyWriteQueue::PendingWrite::~PendingWrite() {} | 30 SpdyWriteQueue::PendingWrite::~PendingWrite() {} |
| 30 | 31 |
| 31 SpdyWriteQueue::PendingWrite::PendingWrite(PendingWrite&& other) = default; | 32 SpdyWriteQueue::PendingWrite::PendingWrite(PendingWrite&& other) = default; |
| 32 SpdyWriteQueue::PendingWrite& SpdyWriteQueue::PendingWrite::operator=( | 33 SpdyWriteQueue::PendingWrite& SpdyWriteQueue::PendingWrite::operator=( |
| 33 PendingWrite&& other) = default; | 34 PendingWrite&& other) = default; |
| 34 | 35 |
| 36 size_t SpdyWriteQueue::PendingWrite::EstimateMemoryUsage() const { |
| 37 return SpdyEstimateMemoryUsage(frame_producer); |
| 38 } |
| 39 |
| 35 SpdyWriteQueue::SpdyWriteQueue() : removing_writes_(false) {} | 40 SpdyWriteQueue::SpdyWriteQueue() : removing_writes_(false) {} |
| 36 | 41 |
| 37 SpdyWriteQueue::~SpdyWriteQueue() { | 42 SpdyWriteQueue::~SpdyWriteQueue() { |
| 38 Clear(); | 43 Clear(); |
| 39 } | 44 } |
| 40 | 45 |
| 41 bool SpdyWriteQueue::IsEmpty() const { | 46 bool SpdyWriteQueue::IsEmpty() const { |
| 42 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; i++) { | 47 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; i++) { |
| 43 if (!queue_[i].empty()) | 48 if (!queue_[i].empty()) |
| 44 return false; | 49 return false; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 153 |
| 149 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { | 154 for (int i = MINIMUM_PRIORITY; i <= MAXIMUM_PRIORITY; ++i) { |
| 150 for (auto it = queue_[i].begin(); it != queue_[i].end(); ++it) { | 155 for (auto it = queue_[i].begin(); it != queue_[i].end(); ++it) { |
| 151 erased_buffer_producers.push_back(std::move(it->frame_producer)); | 156 erased_buffer_producers.push_back(std::move(it->frame_producer)); |
| 152 } | 157 } |
| 153 queue_[i].clear(); | 158 queue_[i].clear(); |
| 154 } | 159 } |
| 155 removing_writes_ = false; | 160 removing_writes_ = false; |
| 156 } | 161 } |
| 157 | 162 |
| 163 size_t SpdyWriteQueue::EstimateMemoryUsage() const { |
| 164 return SpdyEstimateMemoryUsage(queue_); |
| 165 } |
| 166 |
| 158 } // namespace net | 167 } // namespace net |
| OLD | NEW |