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

Side by Side Diff: net/spdy/hpack/hpack_output_stream.h

Issue 2832973003: Split net/spdy into core and chromium subdirectories. (Closed)
Patch Set: Fix some more build rules. Created 3 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
« no previous file with comments | « net/spdy/hpack/hpack_input_stream_test.cc ('k') | net/spdy/hpack/hpack_output_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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_SPDY_HPACK_HPACK_OUTPUT_STREAM_H_
6 #define NET_SPDY_HPACK_HPACK_OUTPUT_STREAM_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <map>
12
13 #include "base/macros.h"
14 #include "net/base/net_export.h"
15 #include "net/spdy/hpack/hpack_constants.h"
16 #include "net/spdy/platform/api/spdy_string.h"
17 #include "net/spdy/platform/api/spdy_string_piece.h"
18
19 // All section references below are to
20 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
21
22 namespace net {
23
24 // An HpackOutputStream handles all the low-level details of encoding
25 // header fields.
26 class NET_EXPORT_PRIVATE HpackOutputStream {
27 public:
28 HpackOutputStream();
29 ~HpackOutputStream();
30
31 // Appends the lower |bit_size| bits of |bits| to the internal buffer.
32 //
33 // |bit_size| must be > 0 and <= 8. |bits| must not have any bits
34 // set other than the lower |bit_size| bits.
35 void AppendBits(uint8_t bits, size_t bit_size);
36
37 // Simply forwards to AppendBits(prefix.bits, prefix.bit-size).
38 void AppendPrefix(HpackPrefix prefix);
39
40 // Directly appends |buffer|.
41 void AppendBytes(SpdyStringPiece buffer);
42
43 // Appends the given integer using the representation described in
44 // 6.1. If the internal buffer ends on a byte boundary, the prefix
45 // length N is taken to be 8; otherwise, it is taken to be the
46 // number of bits to the next byte boundary.
47 //
48 // It is guaranteed that the internal buffer will end on a byte
49 // boundary after this function is called.
50 void AppendUint32(uint32_t I);
51
52 // Swaps the internal buffer with |output|, then resets state.
53 void TakeString(SpdyString* output);
54
55 // Gives up to |max_size| bytes of the internal buffer to |output|. Resets
56 // internal state with the overflow.
57 void BoundedTakeString(size_t max_size, SpdyString* output);
58
59 // Size in bytes of stream's internal buffer.
60 size_t size() const { return buffer_.size(); }
61
62 // Returns the estimate of dynamically allocated memory in bytes.
63 size_t EstimateMemoryUsage() const;
64
65 private:
66 // The internal bit buffer.
67 SpdyString buffer_;
68
69 // If 0, the buffer ends on a byte boundary. If non-zero, the buffer
70 // ends on the nth most significant bit. Guaranteed to be < 8.
71 size_t bit_offset_;
72
73 DISALLOW_COPY_AND_ASSIGN(HpackOutputStream);
74 };
75
76 } // namespace net
77
78 #endif // NET_SPDY_HPACK_HPACK_OUTPUT_STREAM_H_
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_input_stream_test.cc ('k') | net/spdy/hpack/hpack_output_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698