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

Side by Side 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: Address comments Created 4 years, 8 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 unified diff | Download patch
OLDNEW
(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/ref_counted.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.
18 class BlockBuffer {
mmenke 2016/04/29 19:10:54 Can we just use DrainableIOBuffer instead?
xunjieli 2016/07/20 21:00:47 Done.
19 public:
20 BlockBuffer();
21 ~BlockBuffer();
22
23 bool HasMoreBytes() const;
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 Personal preference, therefore suggestion: I find
xunjieli 2016/07/20 21:00:47 Acknowledged. I got rid of this class per Matt's s
24 // Marks that the buffer has been refilled |filled_bytes| bytes. It is illegal
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 nit, suggestion: I think this would be clearer wit
xunjieli 2016/07/20 21:00:47 Acknowledged.
25 // to refill the buffer when there are undrained bytes.
26 void WasRefilled(size_t filled_bytes);
27 // Marks that the buffer has been drained |drained_bytes| bytes. It is illegal
28 // to drain more bytes than that are availbale.
29 void WasDrained(size_t drained_bytes);
30
31 // Returns the size of the IOBuffer.
32 size_t size() const;
33 // Returns the underlying IOBuffer.
34 IOBuffer* buffer() { return buffer_.get(); }
35 // Returns the pointer to the next byte that may be read or drained.
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 nit, suggestion: I'd leave out the "or drained"; i
xunjieli 2016/07/20 21:00:47 Acknowledged.
36 char* bytes() const { return bytes_; }
37 // Returns the number of bytes that are remaining.
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 nit: I'd use the same language as above in the com
xunjieli 2016/07/20 21:00:47 Acknowledged.
38 size_t bytes_left() const { return bytes_left_; }
39
40 private:
41 scoped_refptr<IOBuffer> buffer_;
42 // Points to the next byte that may be read or drained.
43 char* bytes_;
44 size_t bytes_left_;
45 };
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 Should there be a DISALLOW_COPY_AND_ASSIGN?
xunjieli 2016/07/20 21:00:47 Acknowledged.
46
47 } // namespace net
48
49 #endif // NET_FILTER_BLOCK_BUFFER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698