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

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

Issue 220493003: Safebrowsing: change gethash caching to match api 2.3 rules, fix some corner cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (including 227613008) Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_STORE_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 SBSubPrefix() : chunk_id(), add_chunk_id(), add_prefix() {} 67 SBSubPrefix() : chunk_id(), add_chunk_id(), add_prefix() {}
68 68
69 int32 GetAddChunkId() const { return add_chunk_id; } 69 int32 GetAddChunkId() const { return add_chunk_id; }
70 SBPrefix GetAddPrefix() const { return add_prefix; } 70 SBPrefix GetAddPrefix() const { return add_prefix; }
71 }; 71 };
72 72
73 typedef std::deque<SBSubPrefix> SBSubPrefixes; 73 typedef std::deque<SBSubPrefix> SBSubPrefixes;
74 74
75 struct SBAddFullHash { 75 struct SBAddFullHash {
76 int32 chunk_id; 76 int32 chunk_id;
77 int32 received; 77 // Received field is not used anymore, but is kept for DB compatability.
78 // TODO(mattm): Remove it next time the DB format is changed.
79 int32 deprecated_received;
78 SBFullHash full_hash; 80 SBFullHash full_hash;
79 81
80 SBAddFullHash(int32 id, base::Time r, const SBFullHash& h) 82 SBAddFullHash(int32 id, const SBFullHash& h)
81 : chunk_id(id), 83 : chunk_id(id), deprecated_received(), full_hash(h) {}
82 received(static_cast<int32>(r.ToTimeT())),
83 full_hash(h) {
84 }
85 84
86 // Provided for ReadAddHashes() implementations, which already have 85 SBAddFullHash() : chunk_id(), deprecated_received(), full_hash() {}
87 // an int32 for the time.
88 SBAddFullHash(int32 id, int32 r, const SBFullHash& h)
89 : chunk_id(id), received(r), full_hash(h) {}
90
91 SBAddFullHash() : chunk_id(), received(), full_hash() {}
92 86
93 int32 GetAddChunkId() const { return chunk_id; } 87 int32 GetAddChunkId() const { return chunk_id; }
94 SBPrefix GetAddPrefix() const { return full_hash.prefix; } 88 SBPrefix GetAddPrefix() const { return full_hash.prefix; }
95 }; 89 };
96 90
97 struct SBSubFullHash { 91 struct SBSubFullHash {
98 int32 chunk_id; 92 int32 chunk_id;
99 int32 add_chunk_id; 93 int32 add_chunk_id;
100 SBFullHash full_hash; 94 SBFullHash full_hash;
101 95
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 171
178 // Start a chunk of data. None of the methods through FinishChunk() 172 // Start a chunk of data. None of the methods through FinishChunk()
179 // should be called unless this returns true. 173 // should be called unless this returns true.
180 // TODO(shess): Would it make sense for this to accept |chunk_id|? 174 // TODO(shess): Would it make sense for this to accept |chunk_id|?
181 // Possibly not, because of possible confusion between sub_chunk_id 175 // Possibly not, because of possible confusion between sub_chunk_id
182 // and add_chunk_id. 176 // and add_chunk_id.
183 virtual bool BeginChunk() = 0; 177 virtual bool BeginChunk() = 0;
184 178
185 virtual bool WriteAddPrefix(int32 chunk_id, SBPrefix prefix) = 0; 179 virtual bool WriteAddPrefix(int32 chunk_id, SBPrefix prefix) = 0;
186 virtual bool WriteAddHash(int32 chunk_id, 180 virtual bool WriteAddHash(int32 chunk_id,
187 base::Time receive_time,
188 const SBFullHash& full_hash) = 0; 181 const SBFullHash& full_hash) = 0;
189 virtual bool WriteSubPrefix(int32 chunk_id, 182 virtual bool WriteSubPrefix(int32 chunk_id,
190 int32 add_chunk_id, SBPrefix prefix) = 0; 183 int32 add_chunk_id, SBPrefix prefix) = 0;
191 virtual bool WriteSubHash(int32 chunk_id, int32 add_chunk_id, 184 virtual bool WriteSubHash(int32 chunk_id, int32 add_chunk_id,
192 const SBFullHash& full_hash) = 0; 185 const SBFullHash& full_hash) = 0;
193 186
194 // Collect the chunk data and preferrably store it on disk to 187 // Collect the chunk data and preferrably store it on disk to
195 // release memory. Shoul not modify the data in-place. 188 // release memory. Shoul not modify the data in-place.
196 virtual bool FinishChunk() = 0; 189 virtual bool FinishChunk() = 0;
197 190
(...skipping 15 matching lines...) Expand all
213 // calls the corruption callback and return false. 206 // calls the corruption callback and return false.
214 // NOTE(shess): When storage was SQLite, there was no guarantee that 207 // NOTE(shess): When storage was SQLite, there was no guarantee that
215 // a structurally sound database actually contained valid data, 208 // a structurally sound database actually contained valid data,
216 // whereas SafeBrowsingStoreFile checksums the data. For now, this 209 // whereas SafeBrowsingStoreFile checksums the data. For now, this
217 // distinction doesn't matter. 210 // distinction doesn't matter.
218 virtual bool CheckValidity() = 0; 211 virtual bool CheckValidity() = 0;
219 212
220 // Pass the collected chunks through SBPRocessSubs() and commit to 213 // Pass the collected chunks through SBPRocessSubs() and commit to
221 // permanent storage. The resulting add prefixes and hashes will be 214 // permanent storage. The resulting add prefixes and hashes will be
222 // stored in |add_prefixes_result| and |add_full_hashes_result|. 215 // stored in |add_prefixes_result| and |add_full_hashes_result|.
223 // |pending_adds| is the set of full hashes which have been received
224 // since the previous update, and is provided as a convenience
225 // (could be written via WriteAddHash(), but that would flush the
226 // chunk to disk).
227 virtual bool FinishUpdate( 216 virtual bool FinishUpdate(
228 const std::vector<SBAddFullHash>& pending_adds,
229 safe_browsing::PrefixSetBuilder* builder, 217 safe_browsing::PrefixSetBuilder* builder,
230 std::vector<SBAddFullHash>* add_full_hashes_result) = 0; 218 std::vector<SBAddFullHash>* add_full_hashes_result) = 0;
231 219
232 // Cancel the update in process and remove any temporary disk 220 // Cancel the update in process and remove any temporary disk
233 // storage, leaving the original data unmodified. 221 // storage, leaving the original data unmodified.
234 virtual bool CancelUpdate() = 0; 222 virtual bool CancelUpdate() = 0;
235 223
236 private: 224 private:
237 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore); 225 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore);
238 }; 226 };
239 227
240 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ 228 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698