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

Side by Side Diff: net/tools/transport_security_state_generator/trie/trie_writer.h

Issue 2681733008: Improve error handling of the transport security state generator. (Closed)
Patch Set: Remove ErrorList Created 3 years, 9 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 (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
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_| and |*position| is set to the position of the trie root. Returns
43 uint32_t WriteEntries(const TransportSecurityStateEntries& entries); 43 // true on success and false on failure.
44 bool WriteEntries(const TransportSecurityStateEntries& entries,
45 uint32_t* position);
44 46
45 // Returns the position |buffer_| is currently at. The returned value 47 // Returns the position |buffer_| is currently at. The returned value
46 // represents the number of bits. 48 // represents the number of bits.
47 uint32_t position() const; 49 uint32_t position() const;
48 50
49 // Flushes |buffer_|. 51 // Flushes |buffer_|.
50 void Flush(); 52 void Flush();
51 53
52 // Returns the trie bytes. Call Flush() first to ensure the buffer is 54 // Returns the trie bytes. Call Flush() first to ensure the buffer is
53 // complete. 55 // complete.
54 const std::vector<uint8_t>& bytes() const { return buffer_.bytes(); } 56 const std::vector<uint8_t>& bytes() const { return buffer_.bytes(); }
55 57
56 private: 58 private:
57 uint32_t WriteDispatchTables(ReversedEntries::iterator start, 59 bool WriteDispatchTables(ReversedEntries::iterator start,
58 ReversedEntries::iterator end); 60 ReversedEntries::iterator end,
61 uint32_t* position);
59 62
60 // Serializes |*entry| and writes it to |*writer|. 63 // Serializes |*entry| and writes it to |*writer|.
61 void WriteEntry(const TransportSecurityStateEntry* entry, 64 bool WriteEntry(const TransportSecurityStateEntry* entry,
62 TrieBitBuffer* writer); 65 TrieBitBuffer* writer);
63 66
64 // Removes the first |length| characters from all entries between |start| and 67 // Removes the first |length| characters from all entries between |start| and
65 // |end|. 68 // |end|.
66 void RemovePrefix(size_t length, 69 void RemovePrefix(size_t length,
67 ReversedEntries::iterator start, 70 ReversedEntries::iterator start,
68 ReversedEntries::iterator end); 71 ReversedEntries::iterator end);
69 72
70 // Searches for the longest common prefix for all entries between |start| and 73 // Searches for the longest common prefix for all entries between |start| and
71 // |end|. 74 // |end|.
72 std::vector<uint8_t> LongestCommonPrefix(ReversedEntries::iterator start, 75 std::vector<uint8_t> LongestCommonPrefix(
73 ReversedEntries::iterator end) const; 76 ReversedEntries::const_iterator start,
77 ReversedEntries::const_iterator end) const;
74 78
75 // Returns the reversed |hostname| as a vector of bytes. The reversed hostname 79 // Returns the reversed |hostname| as a vector of bytes. The reversed hostname
76 // will be terminated by |kTerminalValue|. 80 // will be terminated by |kTerminalValue|.
77 std::vector<uint8_t> ReverseName(const std::string& hostname) const; 81 std::vector<uint8_t> ReverseName(const std::string& hostname) const;
78 82
79 BitWriter buffer_; 83 BitWriter buffer_;
80 const HuffmanRepresentationTable& huffman_table_; 84 const HuffmanRepresentationTable& huffman_table_;
81 const NameIDMap& domain_ids_map_; 85 const NameIDMap& domain_ids_map_;
82 const NameIDMap& expect_ct_report_uri_map_; 86 const NameIDMap& expect_ct_report_uri_map_;
83 const NameIDMap& expect_staple_report_uri_map_; 87 const NameIDMap& expect_staple_report_uri_map_;
84 const NameIDMap& pinsets_map_; 88 const NameIDMap& pinsets_map_;
85 HuffmanBuilder* huffman_builder_; 89 HuffmanBuilder* huffman_builder_;
86 }; 90 };
87 91
88 } // namespace transport_security_state 92 } // namespace transport_security_state
89 93
90 } // namespace net 94 } // namespace net
91 95
92 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_ 96 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_TRIE_TRIE_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698