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

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

Issue 11615011: Small modifications to safebrowsing code to make it simpler to add the extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: seriously there is a macro called check() in AssertMacros.h wow Created 7 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 // Returns true if the whitelist is disabled or if any of the given hashes 266 // Returns true if the whitelist is disabled or if any of the given hashes
267 // matches the whitelist. 267 // matches the whitelist.
268 bool ContainsWhitelistedHashes(const SBWhitelist& whitelist, 268 bool ContainsWhitelistedHashes(const SBWhitelist& whitelist,
269 const std::vector<SBFullHash>& hashes); 269 const std::vector<SBFullHash>& hashes);
270 270
271 // Return the browse_store_, download_store_, download_whitelist_store or 271 // Return the browse_store_, download_store_, download_whitelist_store or
272 // csd_whitelist_store_ based on list_id. 272 // csd_whitelist_store_ based on list_id.
273 SafeBrowsingStore* GetStore(int list_id); 273 SafeBrowsingStore* GetStore(int list_id);
274 274
275 // Deletes the files on disk. 275 // Deletes the files on disk.
276 bool Delete(); 276 bool Delete();
277 277
278 // Load the prefix set off disk, if available. 278 // Load the prefix set off disk, if available.
279 void LoadPrefixSet(); 279 void LoadPrefixSet();
280 280
281 // Writes the current prefix set to disk. 281 // Writes the current prefix set to disk.
282 void WritePrefixSet(); 282 void WritePrefixSet();
283 283
284 // Loads the given full-length hashes to the given whitelist. If the number 284 // Loads the given full-length hashes to the given whitelist. If the number
285 // of hashes is too large or if the kill switch URL is on the whitelist 285 // of hashes is too large or if the kill switch URL is on the whitelist
(...skipping 10 matching lines...) Expand all
296 // |corruption_detected_|, |HandleCorruptDatabase()| posts 296 // |corruption_detected_|, |HandleCorruptDatabase()| posts
297 // |OnHandleCorruptDatabase()| to the current thread, to be run 297 // |OnHandleCorruptDatabase()| to the current thread, to be run
298 // after the current task completes. 298 // after the current task completes.
299 // TODO(shess): Wire things up to entirely abort the update 299 // TODO(shess): Wire things up to entirely abort the update
300 // transaction when this happens. 300 // transaction when this happens.
301 void HandleCorruptDatabase(); 301 void HandleCorruptDatabase();
302 void OnHandleCorruptDatabase(); 302 void OnHandleCorruptDatabase();
303 303
304 // Helpers for InsertChunks(). 304 // Helpers for InsertChunks().
305 void InsertAdd(int chunk, SBPrefix host, const SBEntry* entry, int list_id); 305 void InsertAdd(int chunk, SBPrefix host, const SBEntry* entry, int list_id);
306 void InsertAddChunks(int list_id, const SBChunkList& chunks); 306 void InsertAddChunks(safe_browsing_util::ListType list_id,
307 const SBChunkList& chunks);
307 void InsertSub(int chunk, SBPrefix host, const SBEntry* entry, int list_id); 308 void InsertSub(int chunk, SBPrefix host, const SBEntry* entry, int list_id);
308 void InsertSubChunks(int list_id, const SBChunkList& chunks); 309 void InsertSubChunks(safe_browsing_util::ListType list_id,
310 const SBChunkList& chunks);
309 311
310 void UpdateDownloadStore(); 312 void UpdateDownloadStore();
311 void UpdateBrowseStore(); 313 void UpdateBrowseStore();
312 void UpdateWhitelistStore(const FilePath& store_filename, 314 void UpdateWhitelistStore(const FilePath& store_filename,
313 SafeBrowsingStore* store, 315 SafeBrowsingStore* store,
314 SBWhitelist* whitelist); 316 SBWhitelist* whitelist);
315 317
316 // Helper function to compare addprefixes in download_store_ with |prefixes|.
317 // The |list_bit| indicates which list (download url or download hash)
318 // to compare.
319 // Returns true if there is a match, |*prefix_hits| will contain the actual
320 // matching prefixes.
321 bool MatchDownloadAddPrefixes(int list_bit,
322 const std::vector<SBPrefix>& prefixes,
323 std::vector<SBPrefix>* prefix_hits);
324
325 // Used to verify that various calls are made from the thread the 318 // Used to verify that various calls are made from the thread the
326 // object was created on. 319 // object was created on.
327 MessageLoop* creation_loop_; 320 MessageLoop* creation_loop_;
328 321
329 // Lock for protecting access to variables that may be used on the 322 // Lock for protecting access to variables that may be used on the
330 // IO thread. This includes |prefix_set_|, |full_browse_hashes_|, 323 // IO thread. This includes |prefix_set_|, |full_browse_hashes_|,
331 // |pending_browse_hashes_|, |prefix_miss_cache_|, |csd_whitelist_|, 324 // |pending_browse_hashes_|, |prefix_miss_cache_|, |csd_whitelist_|,
332 // and |csd_whitelist_all_urls_|. 325 // and |csd_whitelist_all_urls_|.
333 base::Lock lookup_lock_; 326 base::Lock lookup_lock_;
334 327
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // Set to true if any chunks are added or deleted during an update. 371 // Set to true if any chunks are added or deleted during an update.
379 // Used to optimize away database update. 372 // Used to optimize away database update.
380 bool change_detected_; 373 bool change_detected_;
381 374
382 // Used to check if a prefix was in the database. 375 // Used to check if a prefix was in the database.
383 FilePath prefix_set_filename_; 376 FilePath prefix_set_filename_;
384 scoped_ptr<safe_browsing::PrefixSet> prefix_set_; 377 scoped_ptr<safe_browsing::PrefixSet> prefix_set_;
385 }; 378 };
386 379
387 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 380 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698