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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database.h

Issue 9639: Port flush_cache tool. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 // Called when the user's machine has resumed from a lower power state. 83 // Called when the user's machine has resumed from a lower power state.
84 virtual void HandleResume() = 0; 84 virtual void HandleResume() = 0;
85 85
86 virtual bool UpdateStarted() { return true; } 86 virtual bool UpdateStarted() { return true; }
87 virtual void UpdateFinished(bool update_succeeded) {} 87 virtual void UpdateFinished(bool update_succeeded) {}
88 88
89 virtual std::wstring filename() const { return filename_; } 89 virtual std::wstring filename() const { return filename_; }
90 90
91 protected: 91 protected:
92 friend class SafeBrowsingDatabaseTest;
93 FRIEND_TEST(SafeBrowsingDatabase, HashCaching);
94
92 static std::wstring BloomFilterFilename(const std::wstring& db_filename); 95 static std::wstring BloomFilterFilename(const std::wstring& db_filename);
93 96
94 // Load the bloom filter off disk, or generates one if it doesn't exist. 97 // Load the bloom filter off disk, or generates one if it doesn't exist.
95 virtual void LoadBloomFilter(); 98 virtual void LoadBloomFilter();
96 99
97 // Deletes the on-disk bloom filter, i.e. because it's stale. 100 // Deletes the on-disk bloom filter, i.e. because it's stale.
98 virtual void DeleteBloomFilter(); 101 virtual void DeleteBloomFilter();
99 102
100 // Writes the current bloom filter to disk. 103 // Writes the current bloom filter to disk.
101 virtual void WriteBloomFilter(); 104 virtual void WriteBloomFilter();
102 105
103 // Implementation specific bloom filter building. 106 // Implementation specific bloom filter building.
104 virtual void BuildBloomFilter() = 0; 107 virtual void BuildBloomFilter() = 0;
105 108
106 // Measuring false positive rate. Call this each time we look in the filter. 109 // Measuring false positive rate. Call this each time we look in the filter.
107 virtual void IncrementBloomFilterReadCount() {} 110 virtual void IncrementBloomFilterReadCount() {}
108 111
109 // Full hash cache support.
110 FRIEND_TEST(SafeBrowsingDatabase, HashCaching);
111
112 typedef struct HashCacheEntry { 112 typedef struct HashCacheEntry {
113 SBFullHash full_hash; 113 SBFullHash full_hash;
114 int list_id; 114 int list_id;
115 int add_chunk_id; 115 int add_chunk_id;
116 int sub_chunk_id; 116 int sub_chunk_id;
117 base::Time received; 117 base::Time received;
118 } HashCacheEntry; 118 } HashCacheEntry;
119 119
120 typedef std::list<HashCacheEntry> HashList; 120 typedef std::list<HashCacheEntry> HashList;
121 typedef base::hash_map<SBPrefix, HashList> HashCache; 121 typedef base::hash_map<SBPrefix, HashList> HashCache;
122 122
123 scoped_ptr<HashCache> hash_cache_; 123 scoped_ptr<HashCache> hash_cache_;
124 HashCache* hash_cache() { return hash_cache_.get(); } 124 HashCache* hash_cache() { return hash_cache_.get(); }
125 125
126 // Cache of prefixes that returned empty results (no full hash match). 126 // Cache of prefixes that returned empty results (no full hash match).
127 typedef std::set<SBPrefix> PrefixCache; 127 typedef std::set<SBPrefix> PrefixCache;
128 PrefixCache prefix_miss_cache_; 128 PrefixCache prefix_miss_cache_;
129 PrefixCache* prefix_miss_cache() { return &prefix_miss_cache_; } 129 PrefixCache* prefix_miss_cache() { return &prefix_miss_cache_; }
130 130
131 std::wstring filename_; 131 std::wstring filename_;
132 std::wstring bloom_filter_filename_; 132 std::wstring bloom_filter_filename_;
133 scoped_refptr<BloomFilter> bloom_filter_; 133 scoped_refptr<BloomFilter> bloom_filter_;
134 }; 134 };
135 135
136 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 136 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/database_perftest.cc ('k') | chrome/browser/visitedlink_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698