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

Unified Diff: net/tools/transport_security_state_generator/trie/trie_writer.cc

Issue 2906483003: Experiment with a compact mode for simple preloaded entries. (Closed)
Patch Set: Initialize all struct members. Created 3 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/transport_security_state_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/transport_security_state_generator/trie/trie_writer.cc
diff --git a/net/tools/transport_security_state_generator/trie/trie_writer.cc b/net/tools/transport_security_state_generator/trie/trie_writer.cc
index 3dd8163bb7de20ce043c944365ed5c711dbbcafc..0f92d5be611c2b832d319dc0e296c5653aaf0574 100644
--- a/net/tools/transport_security_state_generator/trie/trie_writer.cc
+++ b/net/tools/transport_security_state_generator/trie/trie_writer.cc
@@ -20,6 +20,14 @@ bool CompareReversedEntries(const std::unique_ptr<ReversedEntry>& lhs,
return lhs->reversed_name < rhs->reversed_name;
}
+// Returns true if the entry only configures HSTS with includeSubdomains.
+// Such entries, when written, can be represented more compactly, and thus
+// reduce the overall size of the trie.
+bool IsSimpleEntry(const TransportSecurityStateEntry* entry) {
+ return entry->force_https && entry->include_subdomains &&
+ entry->pinset.empty() && !entry->expect_ct && !entry->expect_staple;
+}
+
} // namespace
ReversedEntry::ReversedEntry(std::vector<uint8_t> reversed_name,
@@ -124,6 +132,13 @@ bool TrieWriter::WriteDispatchTables(ReversedEntries::iterator start,
bool TrieWriter::WriteEntry(const TransportSecurityStateEntry* entry,
TrieBitBuffer* writer) {
+ if (IsSimpleEntry(entry)) {
+ writer->WriteBit(1);
+ return true;
+ } else {
+ writer->WriteBit(0);
+ }
+
uint8_t include_subdomains = 0;
if (entry->include_subdomains) {
include_subdomains = 1;
« no previous file with comments | « net/http/transport_security_state_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698