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

Unified Diff: net/filter/block_buffer.cc

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: net/filter/block_buffer.cc
diff --git a/net/filter/block_buffer.cc b/net/filter/block_buffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..701e30c7e348d72c0d8d4122c618234730e30220
--- /dev/null
+++ b/net/filter/block_buffer.cc
@@ -0,0 +1,41 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/filter/block_buffer.h"
+
+namespace {
+
+const size_t kBufferSize = 32 * 1024;
+
+} // namespace
+
+namespace net {
+
+BlockBuffer::BlockBuffer()
+ : buffer_(new IOBuffer(kBufferSize)),
+ bytes_(buffer_->data()),
+ bytes_left_(0) {}
+BlockBuffer::~BlockBuffer() {}
+
+bool BlockBuffer::HasMoreBytes() const {
+ return bytes_left_ > 0;
+}
+
+void BlockBuffer::WasRefilled(size_t filled_bytes) {
+ DCHECK(bytes_left_ == 0);
+ bytes_ = buffer_->data();
+ bytes_left_ = filled_bytes;
+}
+
+void BlockBuffer::WasDrained(size_t drained_bytes) {
+ DCHECK(drained_bytes <= bytes_left_);
+ bytes_left_ -= drained_bytes;
+ bytes_ += drained_bytes;
+}
+
+size_t BlockBuffer::size() const {
+ return kBufferSize;
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698