Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_ | 5 #ifndef NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_ |
| 6 #define NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_ | 6 #define NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 TrieWriter(const HuffmanRepresentationTable& huffman_table, | 33 TrieWriter(const HuffmanRepresentationTable& huffman_table, |
| 34 const NameIDMap& domain_ids_map, | 34 const NameIDMap& domain_ids_map, |
| 35 const NameIDMap& expect_ct_report_uri_map, | 35 const NameIDMap& expect_ct_report_uri_map, |
| 36 const NameIDMap& expect_staple_report_uri_map, | 36 const NameIDMap& expect_staple_report_uri_map, |
| 37 const NameIDMap& pinsets_map, | 37 const NameIDMap& pinsets_map, |
| 38 HuffmanBuilder* huffman_builder); | 38 HuffmanBuilder* huffman_builder); |
| 39 ~TrieWriter(); | 39 ~TrieWriter(); |
| 40 | 40 |
| 41 // Constructs a trie containing all |entries|. The output is written to | 41 // Constructs a trie containing all |entries|. The output is written to |
| 42 // |buffer_|. Returns the position of the trie root. | 42 // |buffer_|. Returns the position of the trie root. |
|
Ryan Sleevi
2017/02/14 20:53:17
Out of date comment
martijnc
2017/02/15 22:07:59
Updated.
| |
| 43 uint32_t WriteEntries(const TransportSecurityStateEntries& entries); | 43 bool WriteEntries(const TransportSecurityStateEntries& entries, |
| 44 uint32_t* position); | |
| 44 | 45 |
| 45 // Returns the position |buffer_| is currently at. The returned value | 46 // Returns the position |buffer_| is currently at. The returned value |
| 46 // represents the number of bits. | 47 // represents the number of bits. |
| 47 uint32_t position() const; | 48 uint32_t position() const; |
| 48 | 49 |
| 49 // Flushes |buffer_|. | 50 // Flushes |buffer_|. |
| 50 void Flush(); | 51 void Flush(); |
| 51 | 52 |
| 52 // Returns the trie bytes. Call Flush() first to ensure the buffer is | 53 // Returns the trie bytes. Call Flush() first to ensure the buffer is |
| 53 // complete. | 54 // complete. |
| 54 const std::vector<uint8_t>& bytes() const { return buffer_.bytes(); } | 55 const std::vector<uint8_t>& bytes() const { return buffer_.bytes(); } |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 uint32_t WriteDispatchTables(ReversedEntries::iterator start, | 58 bool WriteDispatchTables(ReversedEntries::iterator start, |
| 58 ReversedEntries::iterator end); | 59 ReversedEntries::iterator end, |
| 60 uint32_t* position); | |
| 59 | 61 |
| 60 // Serializes |*entry| and writes it to |*writer|. | 62 // Serializes |*entry| and writes it to |*writer|. |
| 61 void WriteEntry(const TransportSecurityStateEntry* entry, | 63 bool WriteEntry(const TransportSecurityStateEntry* entry, |
| 62 TrieBitBuffer* writer); | 64 TrieBitBuffer* writer); |
| 63 | 65 |
| 64 // Removes the first |length| characters from all entries between |start| and | 66 // Removes the first |length| characters from all entries between |start| and |
| 65 // |end|. | 67 // |end|. |
| 66 void RemovePrefix(size_t length, | 68 void RemovePrefix(size_t length, |
| 67 ReversedEntries::iterator start, | 69 ReversedEntries::iterator start, |
| 68 ReversedEntries::iterator end); | 70 ReversedEntries::iterator end); |
| 69 | 71 |
| 70 // Searches for the longest common prefix for all entries between |start| and | 72 // Searches for the longest common prefix for all entries between |start| and |
| 71 // |end|. | 73 // |end|. |
| 72 std::vector<uint8_t> LongestCommonPrefix(ReversedEntries::iterator start, | 74 std::vector<uint8_t> LongestCommonPrefix( |
| 73 ReversedEntries::iterator end) const; | 75 ReversedEntries::const_iterator start, |
| 76 ReversedEntries::const_iterator end) const; | |
| 74 | 77 |
| 75 // Returns the reversed |hostname| as a vector of bytes. The reversed hostname | 78 // Returns the reversed |hostname| as a vector of bytes. The reversed hostname |
| 76 // will be terminated by |kTerminalValue|. | 79 // will be terminated by |kTerminalValue|. |
| 77 std::vector<uint8_t> ReverseName(const std::string& hostname) const; | 80 std::vector<uint8_t> ReverseName(const std::string& hostname) const; |
| 78 | 81 |
| 79 BitWriter buffer_; | 82 BitWriter buffer_; |
| 80 const HuffmanRepresentationTable& huffman_table_; | 83 const HuffmanRepresentationTable& huffman_table_; |
| 81 const NameIDMap& domain_ids_map_; | 84 const NameIDMap& domain_ids_map_; |
| 82 const NameIDMap& expect_ct_report_uri_map_; | 85 const NameIDMap& expect_ct_report_uri_map_; |
| 83 const NameIDMap& expect_staple_report_uri_map_; | 86 const NameIDMap& expect_staple_report_uri_map_; |
| 84 const NameIDMap& pinsets_map_; | 87 const NameIDMap& pinsets_map_; |
| 85 HuffmanBuilder* huffman_builder_; | 88 HuffmanBuilder* huffman_builder_; |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 } // namespace transport_security_state | 91 } // namespace transport_security_state |
| 89 | 92 |
| 90 } // namespace net | 93 } // namespace net |
| 91 | 94 |
| 92 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_ | 95 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_ |
| OLD | NEW |