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

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 TODO comment about not storing current_list_states_ in v4_local_database_manager 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
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..5c93b670f93140135afa7ab7d47be1a3382d3a7d
--- /dev/null
+++ b/components/safe_browsing_db/v4_database.h
@@ -0,0 +1,74 @@
+// 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,
Nathan Parker 2016/05/06 16:46:35 Are the values here filename post-fixes?
vakh (use Gerrit instead) 2016/05/06 21:27:57 Yes.
+ 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:
+ V4DatabaseFactory() {}
+ ~V4DatabaseFactory() {}
+ V4Database* CreateV4Database(
+ const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
+ const base::FilePath& base_path,
+ ListInfoMap list_info_map);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(V4DatabaseFactory);
+};
+
+// 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(
Nathan Parker 2016/05/06 16:46:35 You probably want the factory stashed as a static
vakh (use Gerrit instead) 2016/05/06 21:27:57 Done.
vakh (use Gerrit instead) 2016/05/06 21:32:21 A lot of classes under safe_browsing[_db]/ use the
+ V4DatabaseFactory* factory,
+ 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();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(V4Database);
+};
+
+} // namespace safe_browsing
+
+#endif // COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_

Powered by Google App Engine
This is Rietveld 408576698