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

Unified Diff: components/safe_browsing_db/v4_database.h

Issue 2675063002: Browser tests for using the new SafeBrowsing protocol (v4) (Closed)
Patch Set: Use ANNOTATE_LEAKING_OBJECT_PTR Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/safe_browsing_db/v4_database.h
diff --git a/components/safe_browsing_db/v4_database.h b/components/safe_browsing_db/v4_database.h
index cc07d4e308a8be28944a2ba2e84e0d7eaae50fde..acb1855a147a535daf0671e4f43ba67eb317cbf9 100644
--- a/components/safe_browsing_db/v4_database.h
+++ b/components/safe_browsing_db/v4_database.h
@@ -78,10 +78,9 @@ typedef std::vector<ListInfo> ListInfos;
class V4DatabaseFactory {
public:
virtual ~V4DatabaseFactory() {}
- virtual V4Database* CreateV4Database(
+ virtual std::unique_ptr<V4Database> Create(
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
- const base::FilePath& base_dir_path,
- const ListInfos& list_infos) = 0;
+ std::unique_ptr<StoreMap> store_map);
};
// The on-disk databases are shared among all profiles, as it doesn't contain
@@ -101,7 +100,7 @@ class V4Database {
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
const base::FilePath& base_path,
const ListInfos& list_infos,
- NewDatabaseReadyCallback callback);
+ NewDatabaseReadyCallback new_db_callback);
// Destroys the provided v4_database on its task_runner since this may be a
// long operation.
@@ -153,7 +152,9 @@ class V4Database {
std::unique_ptr<StoreMap> store_map);
private:
+ friend class V4DatabaseFactory;
friend class V4DatabaseTest;
+ friend class V4SafeBrowsingServiceTest;
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestSetupDatabaseWithFakeStores);
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest,
TestSetupDatabaseWithFakeStoresFailsReset);
@@ -163,12 +164,6 @@ class V4Database {
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithInvalidUpdate);
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestSomeStoresMatchFullHash);
- // Makes the passed |factory| the factory used to instantiate a V4Store. Only
- // for tests.
- static void RegisterStoreFactoryForTest(V4StoreFactory* factory) {
- factory_ = factory;
- }
-
// Factory method to create a V4Database. When the database creation is
// complete, it calls the NewDatabaseReadyCallback on |callback_task_runner|.
static void CreateOnTaskRunner(
@@ -179,6 +174,16 @@ class V4Database {
NewDatabaseReadyCallback callback,
const base::TimeTicks create_start_time);
+ // Makes the passed |factory| the factory used to instantiate a V4Database.
+ // Only for tests.
+ static void RegisterDatabaseFactoryForTest(
+ std::unique_ptr<V4DatabaseFactory> factory);
+
+ // Makes the passed |factory| the factory used to instantiate a V4Store. Only
+ // for tests.
+ static void RegisterStoreFactoryForTest(
+ std::unique_ptr<V4StoreFactory> factory);
+
// Callback called when a new store has been created and is ready to be used.
// This method updates the store_map_ to point to the new store, which causes
// the old store to get deleted.
@@ -190,15 +195,20 @@ class V4Database {
const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner,
DatabaseReadyForUpdatesCallback db_ready_for_updates_callback);
- const scoped_refptr<base::SequencedTaskRunner> db_task_runner_;
-
+ protected:
// Map of ListIdentifier to the V4Store.
const std::unique_ptr<StoreMap> store_map_;
+ private:
+ const scoped_refptr<base::SequencedTaskRunner> db_task_runner_;
+
DatabaseUpdatedCallback db_updated_callback_;
+ // The factory that controls the creation of the V4Database object.
+ static V4DatabaseFactory* db_factory_;
+
// The factory that controls the creation of V4Store objects.
- static V4StoreFactory* factory_;
+ static V4StoreFactory* store_factory_;
// The number of stores for which the update request is pending. When this
// goes down to 0, that indicates that the database has updated all the stores
« no previous file with comments | « chrome/browser/safe_browsing/test_safe_browsing_service.cc ('k') | components/safe_browsing_db/v4_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698