| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/filter/block_buffer.h" |
| 6 |
| 7 namespace { |
| 8 |
| 9 const size_t kBufferSize = 32 * 1024; |
| 10 |
| 11 } // namespace |
| 12 |
| 13 namespace net { |
| 14 |
| 15 BlockBuffer::BlockBuffer() |
| 16 : buffer_(new IOBuffer(kBufferSize)), |
| 17 bytes_(buffer_->data()), |
| 18 bytes_left_(0) {} |
| 19 BlockBuffer::~BlockBuffer() {} |
| 20 |
| 21 bool BlockBuffer::HasMoreBytes() const { |
| 22 return bytes_left_ > 0; |
| 23 } |
| 24 |
| 25 void BlockBuffer::WasRefilled(size_t filled_bytes) { |
| 26 DCHECK(bytes_left_ == 0); |
| 27 bytes_ = buffer_->data(); |
| 28 bytes_left_ = filled_bytes; |
| 29 } |
| 30 |
| 31 void BlockBuffer::WasDrained(size_t drained_bytes) { |
| 32 DCHECK(drained_bytes <= bytes_left_); |
| 33 bytes_left_ -= drained_bytes; |
| 34 bytes_ += drained_bytes; |
| 35 } |
| 36 |
| 37 size_t BlockBuffer::size() const { |
| 38 return kBufferSize; |
| 39 } |
| 40 |
| 41 } // namespace net |
| OLD | NEW |