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

Unified Diff: components/safe_browsing_db/v4_database.h

Issue 2675063002: Browser tests for using the new SafeBrowsing protocol (v4) (Closed)
Patch Set: shess@'s review 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..0d8b30a733ef0adb3dbc2312b470cbe16024b434 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 V4Database* Create(
Nathan Parker 2017/02/08 01:22:54 Should this return a unique_ptr? That's the canoni
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,12 +100,18 @@ 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.
static void Destroy(std::unique_ptr<V4Database> v4_database);
+ // Makes the passed |factory| the factory used to instantiate a V4Database.
+ // Only for tests.
+ static void RegisterFactory(V4DatabaseFactory* factory) {
+ db_factory_ = factory;
+ }
+
virtual ~V4Database();
// Updates the stores with the response received from the SafeBrowsing service
@@ -153,6 +158,7 @@ class V4Database {
std::unique_ptr<StoreMap> store_map);
private:
+ friend class V4DatabaseFactory;
friend class V4DatabaseTest;
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestSetupDatabaseWithFakeStores);
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest,
@@ -166,7 +172,7 @@ class V4Database {
// Makes the passed |factory| the factory used to instantiate a V4Store. Only
// for tests.
static void RegisterStoreFactoryForTest(V4StoreFactory* factory) {
- factory_ = factory;
+ store_factory_ = factory;
}
// Factory method to create a V4Database. When the database creation is
@@ -190,15 +196,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

Powered by Google App Engine
This is Rietveld 408576698