| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/spdy/hpack_header_table.h" | 16 #include "net/spdy/hpack_header_table.h" |
| 17 #include "net/spdy/hpack_output_stream.h" | 17 #include "net/spdy/hpack_output_stream.h" |
| 18 | 18 |
| 19 // An HpackEncoder encodes header sets as outlined in | 19 // An HpackEncoder encodes header sets as outlined in |
| 20 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07 | 20 // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 | 23 |
| 24 class HpackHuffmanTable; | 24 class HpackHuffmanTable; |
| 25 | 25 |
| 26 namespace test { | 26 namespace test { |
| 27 class HpackEncoderPeer; | 27 class HpackEncoderPeer; |
| 28 } // namespace test | 28 } // namespace test |
| 29 | 29 |
| 30 class NET_EXPORT_PRIVATE HpackEncoder { | 30 class NET_EXPORT_PRIVATE HpackEncoder { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 // Sets externally-owned storage for aggregating character counts of emitted | 59 // Sets externally-owned storage for aggregating character counts of emitted |
| 60 // literal representations. | 60 // literal representations. |
| 61 void SetCharCountsStorage(std::vector<size_t>* char_counts, | 61 void SetCharCountsStorage(std::vector<size_t>* char_counts, |
| 62 size_t* total_char_counts); | 62 size_t* total_char_counts); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 typedef std::pair<base::StringPiece, base::StringPiece> Representation; | 65 typedef std::pair<base::StringPiece, base::StringPiece> Representation; |
| 66 typedef std::vector<Representation> Representations; | 66 typedef std::vector<Representation> Representations; |
| 67 | 67 |
| 68 // Emits a static/dynamic indexed representation (Section 4.2). | 68 // Emits a static/dynamic indexed representation (Section 7.1). |
| 69 void EmitDynamicIndex(HpackEntry* entry); | 69 void EmitDynamicIndex(HpackEntry* entry); |
| 70 void EmitStaticIndex(HpackEntry* entry); | 70 void EmitStaticIndex(HpackEntry* entry); |
| 71 | 71 |
| 72 // Emits a literal representation (Section 4.3). | 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 | 82 // Determines the representation delta required to encode |header_set| in |
| (...skipping 16 matching lines...) Expand all Loading... |
| 99 // Externally-owned, nullable storage for character counts of literals. | 99 // Externally-owned, nullable storage for character counts of literals. |
| 100 std::vector<size_t>* char_counts_; | 100 std::vector<size_t>* char_counts_; |
| 101 size_t* total_char_counts_; | 101 size_t* total_char_counts_; |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(HpackEncoder); | 103 DISALLOW_COPY_AND_ASSIGN(HpackEncoder); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace net | 106 } // namespace net |
| 107 | 107 |
| 108 #endif // NET_SPDY_HPACK_ENCODER_H_ | 108 #endif // NET_SPDY_HPACK_ENCODER_H_ |
| OLD | NEW |