OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | |
7 | |
8 #include "base/files/file_path.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/sequenced_task_runner.h" | |
11 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | |
12 #include "components/safe_browsing_db/v4_store.h" | |
13 | |
14 namespace safe_browsing { | |
15 | |
16 class V4Database; | |
17 | |
18 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.
| |
19 const base::FilePath::CharType> | |
20 ListInfoMap; | |
21 | |
22 typedef std::unique_ptr< | |
23 base::hash_map<UpdateListIdentifier, std::unique_ptr<V4Store>>> | |
24 StoreMap; | |
25 | |
26 // Factory for creating V4Database. Tests implement this factory to create fake | |
27 // databases for testing. | |
28 class V4DatabaseFactory { | |
29 public: | |
30 V4DatabaseFactory() {} | |
31 ~V4DatabaseFactory() {} | |
32 V4Database* CreateV4Database( | |
33 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, | |
34 const base::FilePath& base_path, | |
35 ListInfoMap list_info_map); | |
36 | |
37 private: | |
38 DISALLOW_COPY_AND_ASSIGN(V4DatabaseFactory); | |
39 }; | |
40 | |
41 // The on-disk databases are shared among all profiles, as it doesn't contain | |
42 // user-specific data. This object is not thread-safe, i.e. all its methods | |
43 // should be used on the same thread that it was created on, unless specified | |
44 // otherwise. | |
45 // The hash-prefixes of each type are managed by a V4Store (including saving to | |
46 // and reading from disk). | |
47 // The V4Database serves as a single place to manage all the V4Stores. | |
48 class V4Database { | |
49 public: | |
50 // Factory method for obtaining a V4Database implementation. | |
51 // It is not thread safe. | |
52 // The availability of each list is controlled by the one flag on this | |
53 // method. | |
54 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
| |
55 V4DatabaseFactory* factory, | |
56 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, | |
57 const base::FilePath& base_path, | |
58 ListInfoMap list_info_map); | |
59 | |
60 V4Database( | |
61 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, | |
62 StoreMap store_map); | |
63 virtual ~V4Database(); | |
64 | |
65 // Deletes the current database and creates a new one. | |
66 virtual bool ResetDatabase(); | |
67 | |
68 private: | |
69 DISALLOW_COPY_AND_ASSIGN(V4Database); | |
70 }; | |
71 | |
72 } // namespace safe_browsing | |
73 | |
74 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | |
OLD | NEW |