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

Side by Side Diff: net/spdy/hpack_encoder.h

Issue 448433002: Update HPACK implementation to draft-09 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Generate examples_07.hpack. Created 6 years, 4 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_SPDY_HPACK_ENCODER_H_ 5 #ifndef NET_SPDY_HPACK_ENCODER_H_
6 #define NET_SPDY_HPACK_ENCODER_H_ 6 #define NET_SPDY_HPACK_ENCODER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility>
Johnny 2014/08/06 15:04:50 Not used.
Bence 2014/08/06 20:20:22 git cl lint complaining about it when using std::p
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
16 #include "net/spdy/hpack_header_table.h" 17 #include "net/spdy/hpack_header_table.h"
17 #include "net/spdy/hpack_output_stream.h" 18 #include "net/spdy/hpack_output_stream.h"
18 19
19 // An HpackEncoder encodes header sets as outlined in 20 // An HpackEncoder encodes header sets as outlined in
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Sets externally-owned storage for aggregating character counts of emitted 60 // Sets externally-owned storage for aggregating character counts of emitted
60 // literal representations. 61 // literal representations.
61 void SetCharCountsStorage(std::vector<size_t>* char_counts, 62 void SetCharCountsStorage(std::vector<size_t>* char_counts,
62 size_t* total_char_counts); 63 size_t* total_char_counts);
63 64
64 private: 65 private:
65 typedef std::pair<base::StringPiece, base::StringPiece> Representation; 66 typedef std::pair<base::StringPiece, base::StringPiece> Representation;
66 typedef std::vector<Representation> Representations; 67 typedef std::vector<Representation> Representations;
67 68
68 // Emits a static/dynamic indexed representation (Section 7.1). 69 // Emits a static/dynamic indexed representation (Section 7.1).
69 void EmitDynamicIndex(HpackEntry* entry); 70 void EmitIndex(HpackEntry* entry);
70 void EmitStaticIndex(HpackEntry* entry);
71 71
72 // Emits a literal representation (Section 7.2). 72 // Emits a literal representation (Section 7.2).
73 void EmitIndexedLiteral(const Representation& representation); 73 void EmitIndexedLiteral(const Representation& representation);
74 void EmitNonIndexedLiteral(const Representation& representation); 74 void EmitNonIndexedLiteral(const Representation& representation);
75 void EmitLiteral(const Representation& representation); 75 void EmitLiteral(const Representation& representation);
76 76
77 // Emits a Huffman or identity string (whichever is smaller). 77 // Emits a Huffman or identity string (whichever is smaller).
78 void EmitString(base::StringPiece str); 78 void EmitString(base::StringPiece str);
79 79
80 void UpdateCharacterCounts(base::StringPiece str); 80 void UpdateCharacterCounts(base::StringPiece str);
81 81
82 // Determines the representation delta required to encode |header_set| in
83 // the current header table context. Entries in the reference set are
84 // enumerated and marked with membership in the current |header_set|.
85 // Representations which must be explicitly emitted are returned.
86 Representations DetermineEncodingDelta(
87 const std::map<std::string, std::string>& header_set);
88
89 // Crumbles a cookie header into sorted, de-duplicated crumbs. 82 // Crumbles a cookie header into sorted, de-duplicated crumbs.
90 static void CookieToCrumbs(const Representation& cookie, 83 static void CookieToCrumbs(const Representation& cookie,
91 Representations* crumbs_out); 84 Representations* crumbs_out);
92 85
93 HpackHeaderTable header_table_; 86 HpackHeaderTable header_table_;
94 HpackOutputStream output_stream_; 87 HpackOutputStream output_stream_;
95 88
96 bool allow_huffman_compression_; 89 bool allow_huffman_compression_;
97 const HpackHuffmanTable& huffman_table_; 90 const HpackHuffmanTable& huffman_table_;
98 91
99 // Externally-owned, nullable storage for character counts of literals. 92 // Externally-owned, nullable storage for character counts of literals.
100 std::vector<size_t>* char_counts_; 93 std::vector<size_t>* char_counts_;
101 size_t* total_char_counts_; 94 size_t* total_char_counts_;
102 95
103 DISALLOW_COPY_AND_ASSIGN(HpackEncoder); 96 DISALLOW_COPY_AND_ASSIGN(HpackEncoder);
104 }; 97 };
105 98
106 } // namespace net 99 } // namespace net
107 100
108 #endif // NET_SPDY_HPACK_ENCODER_H_ 101 #endif // NET_SPDY_HPACK_ENCODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698