OLD | NEW |
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" | |
23 | 22 |
24 namespace safe_browsing { | 23 namespace safe_browsing { |
25 class PrefixSet; | 24 class PrefixSet; |
26 } | 25 } |
27 | 26 |
28 class GURL; | 27 class GURL; |
29 class SafeBrowsingDatabase; | 28 class SafeBrowsingDatabase; |
30 | 29 |
31 // Factory for creating SafeBrowsingDatabase. Tests implement this factory | 30 // Factory for creating SafeBrowsingDatabase. Tests implement this factory |
32 // to create fake Databases for testing. | 31 // to create fake Databases for testing. |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 // |corruption_detected_|, |HandleCorruptDatabase()| posts | 583 // |corruption_detected_|, |HandleCorruptDatabase()| posts |
585 // |OnHandleCorruptDatabase()| to the current thread, to be run | 584 // |OnHandleCorruptDatabase()| to the current thread, to be run |
586 // after the current task completes. | 585 // after the current task completes. |
587 // TODO(shess): Wire things up to entirely abort the update | 586 // TODO(shess): Wire things up to entirely abort the update |
588 // transaction when this happens. | 587 // transaction when this happens. |
589 void HandleCorruptDatabase(); | 588 void HandleCorruptDatabase(); |
590 void OnHandleCorruptDatabase(); | 589 void OnHandleCorruptDatabase(); |
591 | 590 |
592 // Helpers for InsertChunks(). | 591 // Helpers for InsertChunks(). |
593 void InsertAddChunk(SafeBrowsingStore* store, | 592 void InsertAddChunk(SafeBrowsingStore* store, |
594 safe_browsing::ListType list_id, | 593 safe_browsing_util::ListType list_id, |
595 const SBChunkData& chunk); | 594 const SBChunkData& chunk); |
596 void InsertSubChunk(SafeBrowsingStore* store, | 595 void InsertSubChunk(SafeBrowsingStore* store, |
597 safe_browsing::ListType list_id, | 596 safe_browsing_util::ListType list_id, |
598 const SBChunkData& chunk); | 597 const SBChunkData& chunk); |
599 | 598 |
600 // Updates the |store| and stores the result on disk under |store_filename|. | 599 // Updates the |store| and stores the result on disk under |store_filename|. |
601 void UpdateHashPrefixStore(const base::FilePath& store_filename, | 600 void UpdateHashPrefixStore(const base::FilePath& store_filename, |
602 SafeBrowsingStore* store, | 601 SafeBrowsingStore* store, |
603 FailureType failure_type); | 602 FailureType failure_type); |
604 | 603 |
605 // Updates a PrefixStore store for URLs (|url_store|) which is backed on disk | 604 // 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 | 605 // 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. | 606 // to highlight the specific store who made the initial request on failure. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 const scoped_ptr<SafeBrowsingStore> ip_blacklist_store_; | 670 const scoped_ptr<SafeBrowsingStore> ip_blacklist_store_; |
672 const scoped_ptr<SafeBrowsingStore> unwanted_software_store_; | 671 const scoped_ptr<SafeBrowsingStore> unwanted_software_store_; |
673 | 672 |
674 // Used to schedule resetting the database because of corruption. This factory | 673 // 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 | 674 // and the WeakPtrs it issues should only be used on the database's main |
676 // thread. | 675 // thread. |
677 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; | 676 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; |
678 }; | 677 }; |
679 | 678 |
680 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 679 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
OLD | NEW |