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