| 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.
|
| +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(); }
|
| +
|
| + private:
|
| + scoped_refptr<IOBuffer> buffer_;
|
| + char* bytes_;
|
| + size_t bytes_left_;
|
| +};
|
| +
|
| +} // namespace net
|
| +
|
| +#endif // NET_FILTER_BLOCK_BUFFER_H
|
|
|