| Index: net/spdy/hpack_encoder.h
|
| diff --git a/net/spdy/hpack_encoder.h b/net/spdy/hpack_encoder.h
|
| index 5a6b8ca8a1969c49ab052fd2fec6f655f377b845..df504f50f83e52c39e1a53ae2fe074a10cc02f5b 100644
|
| --- a/net/spdy/hpack_encoder.h
|
| +++ b/net/spdy/hpack_encoder.h
|
| @@ -7,11 +7,13 @@
|
|
|
| #include <map>
|
| #include <string>
|
| +#include <vector>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/macros.h"
|
| #include "base/strings/string_piece.h"
|
| #include "net/base/net_export.h"
|
| +#include "net/spdy/hpack_header_table.h"
|
| #include "net/spdy/hpack_output_stream.h"
|
|
|
| // An HpackEncoder encodes header sets as outlined in
|
| @@ -19,6 +21,8 @@
|
|
|
| namespace net {
|
|
|
| +class HpackHuffmanTable;
|
| +
|
| namespace test {
|
| class HpackEncoderPeer;
|
| } // namespace test
|
| @@ -27,7 +31,9 @@ class NET_EXPORT_PRIVATE HpackEncoder {
|
| public:
|
| friend class test::HpackEncoderPeer;
|
|
|
| - explicit HpackEncoder();
|
| + // |table| is an initialized HPACK Huffman table, having an
|
| + // externally-managed lifetime which spans beyond HpackEncoder.
|
| + explicit HpackEncoder(const HpackHuffmanTable& table);
|
| ~HpackEncoder();
|
|
|
| // Encodes the given header set into the given string. Returns
|
| @@ -35,15 +41,52 @@ class NET_EXPORT_PRIVATE HpackEncoder {
|
| bool EncodeHeaderSet(const std::map<std::string, std::string>& header_set,
|
| std::string* output);
|
|
|
| + // Encodes the given header set into the given string. Only non-indexed
|
| + // literal representations are emitted, bypassing the header table. Huffman
|
| + // coding is also not used. Returns whether the encoding was successful.
|
| + // TODO(jgraettinger): Enable Huffman coding once the table as stablized.
|
| + bool EncodeHeaderSetWithoutCompression(
|
| + const std::map<std::string, std::string>& header_set,
|
| + std::string* output);
|
| +
|
| + // Called upon a change to SETTINGS_HEADER_TABLE_SIZE. Specifically, this
|
| + // is to be called after receiving (and sending an acknowledgement for) a
|
| + // SETTINGS_HEADER_TABLE_SIZE update from the remote decoding endpoint.
|
| + void ApplyHeaderTableSizeSetting(size_t size_setting) {
|
| + header_table_.SetSettingsHeaderTableSize(size_setting);
|
| + }
|
| +
|
| private:
|
| - void EmitNonIndexedLiteral(base::StringPiece name,
|
| - base::StringPiece value,
|
| - HpackOutputStream* output_stream);
|
| + typedef std::pair<base::StringPiece, base::StringPiece> Representation;
|
| + typedef std::vector<Representation> Representations;
|
| +
|
| + // Emits a static/dynamic indexed representation (Section 4.2).
|
| + void EmitDynamicIndex(HpackEntry* entry);
|
| + void EmitStaticIndex(HpackEntry* entry);
|
| +
|
| + // Emits a literal representation (Section 4.3).
|
| + void EmitIndexedLiteral(const Representation& representation);
|
| + void EmitNonIndexedLiteral(const Representation& representation);
|
| + void EmitLiteral(const Representation& representation);
|
| +
|
| + // Emits a Huffman or identity string (whichever is smaller).
|
| + void EmitString(base::StringPiece str);
|
| +
|
| + // Determines the representation delta required to encode |header_set| in
|
| + // the current header table context. Entries in the reference set are
|
| + // enumerated and marked with membership in the current |header_set|.
|
| + // Representations which must be explicitly emitted are returned.
|
| + Representations DetermineEncodingDelta(
|
| + const std::map<std::string, std::string>& header_set);
|
| +
|
| + static void CookieToCrumbs(const Representation& cookie,
|
| + Representations* crumbs_out);
|
|
|
| - static void CookieToCrumbs(base::StringPiece cookie,
|
| - std::vector<base::StringPiece>* out);
|
| + HpackHeaderTable header_table_;
|
| + HpackOutputStream output_stream_;
|
|
|
| - uint32 max_string_literal_size_;
|
| + bool allow_huffman_compression_;
|
| + const HpackHuffmanTable& huffman_table_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(HpackEncoder);
|
| };
|
|
|