Chromium Code Reviews| Index: chrome/browser/safe_browsing/prefix_set.h |
| diff --git a/chrome/browser/safe_browsing/prefix_set.h b/chrome/browser/safe_browsing/prefix_set.h |
| index cb2cd9f6debfa64071cc776fed1993682aab6505..246beea5d28140fa6858d48104caa0c66ef09e1b 100644 |
| --- a/chrome/browser/safe_browsing/prefix_set.h |
| +++ b/chrome/browser/safe_browsing/prefix_set.h |
| @@ -37,8 +37,7 @@ |
| // 2^16 apart, which would need 512k (versus 256k to store the raw |
| // data). |
| // |
| -// TODO(shess): Write serialization code. Something like this should |
| -// work: |
| +// The on-disk format looks like: |
| // 4 byte magic number |
| // 4 byte version number |
| // 4 byte |index_.size()| |
| @@ -55,6 +54,8 @@ |
| #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| +class FilePath; |
| + |
| namespace safe_browsing { |
| class PrefixSet { |
| @@ -65,6 +66,10 @@ class PrefixSet { |
| // |true| if |prefix| was in |prefixes| passed to the constructor. |
| bool Exists(SBPrefix prefix) const; |
| + // Persist the set on disk. |
| + static PrefixSet* LoadFile(const FilePath& filter_name); |
| + bool WriteFile(const FilePath& filter_name) const; |
| + |
| // Regenerate the vector of prefixes passed to the constructor into |
| // |prefixes|. Prefixes will be added in sorted order. |
| void GetPrefixes(std::vector<SBPrefix>* prefixes); |
| @@ -78,6 +83,11 @@ class PrefixSet { |
| // for |Exists()| under control. |
| static const size_t kMaxRun = 100; |
| + // Helper for |LoadFile()|. Steals the contents of |index| and |
|
lzheng
2011/03/08 01:15:51
Are there two spaces between "." and "Steals?"
Scott Hess - ex-Googler
2011/03/08 01:26:41
Yeah? All my prose has two spaces after sentence-
|
| + // |deltas| using |swap()|. |
| + PrefixSet(std::vector<std::pair<SBPrefix,size_t> > *index, |
| + std::vector<uint16> *deltas); |
| + |
| // Top-level index of prefix to offset in |deltas_|. Each pair |
| // indicates a base prefix and where the deltas from that prefix |
| // begin in |deltas_|. The deltas for a pair end at the next pair's |