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

Unified Diff: chrome/browser/safe_browsing/prefix_set.h

Issue 6625002: safe_browsing::PrefixSet persistence code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lei's comments. Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/prefix_set.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+ // |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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/prefix_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698