Chromium Code Reviews| 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_ |