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

Unified Diff: components/safe_browsing_db/v4_database.h

Issue 1952843003: Skeleton of the overall design for the database for Pver4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add space in comment Created 4 years, 7 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
« no previous file with comments | « components/safe_browsing_db/BUILD.gn ('k') | components/safe_browsing_db/v4_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..509939e68be6366928a21ca4071958d50fb574b7
--- /dev/null
+++ b/components/safe_browsing_db/v4_database.h
@@ -0,0 +1,79 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_
+#define COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_
+
+#include "base/files/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/sequenced_task_runner.h"
+#include "components/safe_browsing_db/v4_protocol_manager_util.h"
+#include "components/safe_browsing_db/v4_store.h"
+
+namespace safe_browsing {
+
+class V4Database;
+
+typedef const base::hash_map<UpdateListIdentifier,
+ const base::FilePath::CharType>
+ ListInfoMap;
+
+typedef std::unique_ptr<
+ base::hash_map<UpdateListIdentifier, std::unique_ptr<V4Store>>>
+ StoreMap;
+
+// Factory for creating V4Database. Tests implement this factory to create fake
+// databases for testing.
+class V4DatabaseFactory {
+ public:
+ virtual ~V4DatabaseFactory() {}
+ virtual V4Database* CreateV4Database(
+ const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
+ const base::FilePath& base_path,
+ ListInfoMap list_info_map) = 0;
+};
+
+// The on-disk databases are shared among all profiles, as it doesn't contain
+// user-specific data. This object is not thread-safe, i.e. all its methods
+// should be used on the same thread that it was created on, unless specified
+// otherwise.
+// The hash-prefixes of each type are managed by a V4Store (including saving to
+// and reading from disk).
+// The V4Database serves as a single place to manage all the V4Stores.
+class V4Database {
+ public:
+ // Factory method for obtaining a V4Database implementation.
+ // It is not thread safe.
+ // The availability of each list is controlled by the one flag on this
+ // method.
+ static V4Database* Create(
+ const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
+ const base::FilePath& base_path,
+ ListInfoMap list_info_map);
+
+ V4Database(
+ const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
+ StoreMap store_map);
+ virtual ~V4Database();
+
+ // Deletes the current database and creates a new one.
+ virtual bool ResetDatabase();
+
+ // Makes the passed |factory| the factory used to instantiate
+ // a V4Database. Only for tests.
+ static void RegisterFactoryForTest(V4DatabaseFactory* factory) {
+ factory_ = factory;
+ }
+
+ private:
+ // The factory that controls the creation of V4Database objects.
+ // This is used *only* by tests.
+ static V4DatabaseFactory* factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(V4Database);
+};
+
+} // namespace safe_browsing
+
+#endif // COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_
« no previous file with comments | « components/safe_browsing_db/BUILD.gn ('k') | components/safe_browsing_db/v4_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698