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

Unified Diff: net/filter/block_buffer.h

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor common logic 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.h
diff --git a/net/filter/block_buffer.h b/net/filter/block_buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..c040a006c4d24129ced1d6137535fd8e0de53276
--- /dev/null
+++ b/net/filter/block_buffer.h
@@ -0,0 +1,42 @@
+// 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.
+
+#ifndef NET_FILTER_BLOCK_BUFFER_H
+#define NET_FILTER_BLOCK_BUFFER_H
+
+#include "base/memory/scoped_ptr.h"
+#include "net/base/io_buffer.h"
+
+namespace net {
+
+// A refillable input buffer, wrapping an IOBuffer.
+// The |WasRefilled| and |WasDrained| methods are responsible for maintaining
+// this class's state machine. A client class should call |WasDrained| when
+// bytes are drained from the buffer, and |WasRefilled| when new bytes are
+// placed in the underlying IOBuffer. Note that it is an error to drain more
+// bytes than are available in the BlockBuffer or to refill the BlockBuffer when
+// its previous block is not completely drained.
Randy Smith (Not in Mondays) 2016/03/09 23:03:56 suggestion: Put these last two requirements in ter
xunjieli 2016/04/20 19:16:09 Done.
+class BlockBuffer {
+ public:
+ BlockBuffer();
+ ~BlockBuffer();
+
+ bool HasMoreBytes() const;
+ void WasRefilled(size_t filled_bytes);
+ void WasDrained(size_t drained_bytes);
+
+ size_t size() const;
+ char* bytes() const { return bytes_; }
+ size_t bytes_left() const { return bytes_left_; }
+ IOBuffer* buffer() { return buffer_.get(); }
Randy Smith (Not in Mondays) 2016/03/09 23:03:55 I think it's important to document the distinction
xunjieli 2016/04/20 19:16:08 Done.
+
+ private:
+ scoped_refptr<IOBuffer> buffer_;
+ char* bytes_;
+ size_t bytes_left_;
+};
+
+} // namespace net
+
+#endif // NET_FILTER_BLOCK_BUFFER_H
« no previous file with comments | « net/docs/filter.md ('k') | net/filter/block_buffer.cc » ('j') | net/filter/gzip_stream_source.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698