| OLD | NEW |
| 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 <vector> | 10 #include <vector> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 const std::map<std::string, std::string>& header_set, | 49 const std::map<std::string, std::string>& header_set, |
| 50 std::string* output); | 50 std::string* output); |
| 51 | 51 |
| 52 // Called upon a change to SETTINGS_HEADER_TABLE_SIZE. Specifically, this | 52 // Called upon a change to SETTINGS_HEADER_TABLE_SIZE. Specifically, this |
| 53 // is to be called after receiving (and sending an acknowledgement for) a | 53 // is to be called after receiving (and sending an acknowledgement for) a |
| 54 // SETTINGS_HEADER_TABLE_SIZE update from the remote decoding endpoint. | 54 // SETTINGS_HEADER_TABLE_SIZE update from the remote decoding endpoint. |
| 55 void ApplyHeaderTableSizeSetting(size_t size_setting) { | 55 void ApplyHeaderTableSizeSetting(size_t size_setting) { |
| 56 header_table_.SetSettingsHeaderTableSize(size_setting); | 56 header_table_.SetSettingsHeaderTableSize(size_setting); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Sets externally-owned storage for aggregating character counts of emitted |
| 60 // literal representations. |
| 61 void SetCharCountsStorage(std::vector<size_t>* char_counts, |
| 62 size_t* total_char_counts); |
| 63 |
| 59 private: | 64 private: |
| 60 typedef std::pair<base::StringPiece, base::StringPiece> Representation; | 65 typedef std::pair<base::StringPiece, base::StringPiece> Representation; |
| 61 typedef std::vector<Representation> Representations; | 66 typedef std::vector<Representation> Representations; |
| 62 | 67 |
| 63 // Emits a static/dynamic indexed representation (Section 4.2). | 68 // Emits a static/dynamic indexed representation (Section 4.2). |
| 64 void EmitDynamicIndex(HpackEntry* entry); | 69 void EmitDynamicIndex(HpackEntry* entry); |
| 65 void EmitStaticIndex(HpackEntry* entry); | 70 void EmitStaticIndex(HpackEntry* entry); |
| 66 | 71 |
| 67 // Emits a literal representation (Section 4.3). | 72 // Emits a literal representation (Section 4.3). |
| 68 void EmitIndexedLiteral(const Representation& representation); | 73 void EmitIndexedLiteral(const Representation& representation); |
| 69 void EmitNonIndexedLiteral(const Representation& representation); | 74 void EmitNonIndexedLiteral(const Representation& representation); |
| 70 void EmitLiteral(const Representation& representation); | 75 void EmitLiteral(const Representation& representation); |
| 71 | 76 |
| 72 // Emits a Huffman or identity string (whichever is smaller). | 77 // Emits a Huffman or identity string (whichever is smaller). |
| 73 void EmitString(base::StringPiece str); | 78 void EmitString(base::StringPiece str); |
| 74 | 79 |
| 80 void UpdateCharacterCounts(base::StringPiece str); |
| 81 |
| 75 // Determines the representation delta required to encode |header_set| in | 82 // Determines the representation delta required to encode |header_set| in |
| 76 // the current header table context. Entries in the reference set are | 83 // the current header table context. Entries in the reference set are |
| 77 // enumerated and marked with membership in the current |header_set|. | 84 // enumerated and marked with membership in the current |header_set|. |
| 78 // Representations which must be explicitly emitted are returned. | 85 // Representations which must be explicitly emitted are returned. |
| 79 Representations DetermineEncodingDelta( | 86 Representations DetermineEncodingDelta( |
| 80 const std::map<std::string, std::string>& header_set); | 87 const std::map<std::string, std::string>& header_set); |
| 81 | 88 |
| 82 static void CookieToCrumbs(const Representation& cookie, | 89 static void CookieToCrumbs(const Representation& cookie, |
| 83 Representations* crumbs_out); | 90 Representations* crumbs_out); |
| 84 | 91 |
| 85 HpackHeaderTable header_table_; | 92 HpackHeaderTable header_table_; |
| 86 HpackOutputStream output_stream_; | 93 HpackOutputStream output_stream_; |
| 87 | 94 |
| 88 bool allow_huffman_compression_; | 95 bool allow_huffman_compression_; |
| 89 const HpackHuffmanTable& huffman_table_; | 96 const HpackHuffmanTable& huffman_table_; |
| 90 | 97 |
| 98 // Externally-owned, nullable storage for character counts of literals. |
| 99 std::vector<size_t>* char_counts_; |
| 100 size_t* total_char_counts_; |
| 101 |
| 91 DISALLOW_COPY_AND_ASSIGN(HpackEncoder); | 102 DISALLOW_COPY_AND_ASSIGN(HpackEncoder); |
| 92 }; | 103 }; |
| 93 | 104 |
| 94 } // namespace net | 105 } // namespace net |
| 95 | 106 |
| 96 #endif // NET_SPDY_HPACK_ENCODER_H_ | 107 #endif // NET_SPDY_HPACK_ENCODER_H_ |
| OLD | NEW |