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

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

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Remove '// namespace safe_browsing' for a small fwd decl block. Created 5 years, 1 month 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
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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_store.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_store.h"
22 #include "components/safe_browsing_db/util.h" 22 #include "components/safe_browsing_db/util.h"
23 23
24 class GURL;
25
24 namespace safe_browsing { 26 namespace safe_browsing {
27
25 class PrefixSet; 28 class PrefixSet;
26 }
27
28 class GURL;
29 class SafeBrowsingDatabase; 29 class SafeBrowsingDatabase;
30 30
31 // Factory for creating SafeBrowsingDatabase. Tests implement this factory 31 // Factory for creating SafeBrowsingDatabase. Tests implement this factory
32 // to create fake Databases for testing. 32 // to create fake Databases for testing.
33 class SafeBrowsingDatabaseFactory { 33 class SafeBrowsingDatabaseFactory {
34 public: 34 public:
35 SafeBrowsingDatabaseFactory() { } 35 SafeBrowsingDatabaseFactory() { }
36 virtual ~SafeBrowsingDatabaseFactory() { } 36 virtual ~SafeBrowsingDatabaseFactory() { }
37 virtual SafeBrowsingDatabase* CreateSafeBrowsingDatabase( 37 virtual SafeBrowsingDatabase* CreateSafeBrowsingDatabase(
38 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 38 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 SBWhitelist csd_whitelist_; 426 SBWhitelist csd_whitelist_;
427 SBWhitelist download_whitelist_; 427 SBWhitelist download_whitelist_;
428 SBWhitelist inclusion_whitelist_; 428 SBWhitelist inclusion_whitelist_;
429 429
430 // The IP blacklist should be small. At most a couple hundred IPs. 430 // The IP blacklist should be small. At most a couple hundred IPs.
431 IPBlacklist ip_blacklist_; 431 IPBlacklist ip_blacklist_;
432 432
433 // PrefixSets to speed up lookups for particularly large lists. The 433 // PrefixSets to speed up lookups for particularly large lists. The
434 // PrefixSet themselves are never modified, instead a new one is swapped in 434 // PrefixSet themselves are never modified, instead a new one is swapped in
435 // on update. 435 // on update.
436 scoped_ptr<const safe_browsing::PrefixSet> browse_prefix_set_; 436 scoped_ptr<const PrefixSet> browse_prefix_set_;
437 scoped_ptr<const safe_browsing::PrefixSet> unwanted_software_prefix_set_; 437 scoped_ptr<const PrefixSet> unwanted_software_prefix_set_;
438 438
439 // Cache of gethash results for prefix stores. Entries should not be used if 439 // Cache of gethash results for prefix stores. Entries should not be used if
440 // they are older than their expire_after field. Cached misses will have 440 // they are older than their expire_after field. Cached misses will have
441 // empty full_hashes field. Cleared on each update. The cache is "mutable" 441 // empty full_hashes field. Cleared on each update. The cache is "mutable"
442 // as it can be written to from any transaction holding the lock, including 442 // as it can be written to from any transaction holding the lock, including
443 // ReadTransactions. 443 // ReadTransactions.
444 mutable PrefixGetHashCache prefix_gethash_cache_; 444 mutable PrefixGetHashCache prefix_gethash_cache_;
445 445
446 DISALLOW_COPY_AND_ASSIGN(ThreadSafeStateManager); 446 DISALLOW_COPY_AND_ASSIGN(ThreadSafeStateManager);
447 }; 447 };
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 // |corruption_detected_|, |HandleCorruptDatabase()| posts 584 // |corruption_detected_|, |HandleCorruptDatabase()| posts
585 // |OnHandleCorruptDatabase()| to the current thread, to be run 585 // |OnHandleCorruptDatabase()| to the current thread, to be run
586 // after the current task completes. 586 // after the current task completes.
587 // TODO(shess): Wire things up to entirely abort the update 587 // TODO(shess): Wire things up to entirely abort the update
588 // transaction when this happens. 588 // transaction when this happens.
589 void HandleCorruptDatabase(); 589 void HandleCorruptDatabase();
590 void OnHandleCorruptDatabase(); 590 void OnHandleCorruptDatabase();
591 591
592 // Helpers for InsertChunks(). 592 // Helpers for InsertChunks().
593 void InsertAddChunk(SafeBrowsingStore* store, 593 void InsertAddChunk(SafeBrowsingStore* store,
594 safe_browsing::ListType list_id, 594 ListType list_id,
595 const SBChunkData& chunk); 595 const SBChunkData& chunk);
596 void InsertSubChunk(SafeBrowsingStore* store, 596 void InsertSubChunk(SafeBrowsingStore* store,
597 safe_browsing::ListType list_id, 597 ListType list_id,
598 const SBChunkData& chunk); 598 const SBChunkData& chunk);
599 599
600 // Updates the |store| and stores the result on disk under |store_filename|. 600 // Updates the |store| and stores the result on disk under |store_filename|.
601 void UpdateHashPrefixStore(const base::FilePath& store_filename, 601 void UpdateHashPrefixStore(const base::FilePath& store_filename,
602 SafeBrowsingStore* store, 602 SafeBrowsingStore* store,
603 FailureType failure_type); 603 FailureType failure_type);
604 604
605 // Updates a PrefixStore store for URLs (|url_store|) which is backed on disk 605 // Updates a PrefixStore store for URLs (|url_store|) which is backed on disk
606 // by a "|db_filename| Prefix Set" file. Specific failure types are provided 606 // by a "|db_filename| Prefix Set" file. Specific failure types are provided
607 // to highlight the specific store who made the initial request on failure. 607 // to highlight the specific store who made the initial request on failure.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 const scoped_ptr<SafeBrowsingStore> extension_blacklist_store_; 670 const scoped_ptr<SafeBrowsingStore> extension_blacklist_store_;
671 const scoped_ptr<SafeBrowsingStore> ip_blacklist_store_; 671 const scoped_ptr<SafeBrowsingStore> ip_blacklist_store_;
672 const scoped_ptr<SafeBrowsingStore> unwanted_software_store_; 672 const scoped_ptr<SafeBrowsingStore> unwanted_software_store_;
673 673
674 // Used to schedule resetting the database because of corruption. This factory 674 // Used to schedule resetting the database because of corruption. This factory
675 // and the WeakPtrs it issues should only be used on the database's main 675 // and the WeakPtrs it issues should only be used on the database's main
676 // thread. 676 // thread.
677 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; 677 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_;
678 }; 678 };
679 679
680 } // namespace safe_browsing
681
680 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 682 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698