Chromium Code Reviews| 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 #ifndef NET_FILTER_BLOCK_BUFFER_H | |
| 6 #define NET_FILTER_BLOCK_BUFFER_H | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "net/base/io_buffer.h" | |
| 10 | |
| 11 namespace net { | |
| 12 | |
| 13 // A refillable input buffer, wrapping an IOBuffer. | |
| 14 // The |WasRefilled| and |WasDrained| methods are responsible for maintaining | |
| 15 // this class's state machine. A client class should call |WasDrained| when | |
| 16 // bytes are drained from the buffer, and |WasRefilled| when new bytes are | |
| 17 // placed in the underlying IOBuffer. Note that it is an error to drain more | |
| 18 // bytes than are available in the BlockBuffer or to refill the BlockBuffer when | |
| 19 // 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.
| |
| 20 class BlockBuffer { | |
| 21 public: | |
| 22 BlockBuffer(); | |
| 23 ~BlockBuffer(); | |
| 24 | |
| 25 bool HasMoreBytes() const; | |
| 26 void WasRefilled(size_t filled_bytes); | |
| 27 void WasDrained(size_t drained_bytes); | |
| 28 | |
| 29 size_t size() const; | |
| 30 char* bytes() const { return bytes_; } | |
| 31 size_t bytes_left() const { return bytes_left_; } | |
| 32 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.
| |
| 33 | |
| 34 private: | |
| 35 scoped_refptr<IOBuffer> buffer_; | |
| 36 char* bytes_; | |
| 37 size_t bytes_left_; | |
| 38 }; | |
| 39 | |
| 40 } // namespace net | |
| 41 | |
| 42 #endif // NET_FILTER_BLOCK_BUFFER_H | |
| OLD | NEW |