OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
11 | 13 |
12 namespace safe_browsing { | 14 namespace safe_browsing { |
13 | 15 |
14 class V4Store; | 16 class V4Store; |
15 | 17 |
| 18 typedef base::Callback<void(std::unique_ptr<V4Store>)> |
| 19 UpdatedStoreReadyCallback; |
| 20 |
16 // Factory for creating V4Store. Tests implement this factory to create fake | 21 // Factory for creating V4Store. Tests implement this factory to create fake |
17 // stores for testing. | 22 // stores for testing. |
18 class V4StoreFactory { | 23 class V4StoreFactory { |
19 public: | 24 public: |
20 virtual ~V4StoreFactory() {} | 25 virtual ~V4StoreFactory() {} |
21 virtual V4Store* CreateV4Store( | 26 virtual V4Store* CreateV4Store( |
22 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 27 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
23 const base::FilePath& store_path); | 28 const base::FilePath& store_path); |
24 }; | 29 }; |
25 | 30 |
26 class V4Store { | 31 class V4Store { |
27 public: | 32 public: |
28 // The |task_runner| is used to ensure that the operations in this file are | 33 // The |task_runner| is used to ensure that the operations in this file are |
29 // performed on the correct thread. |store_path| specifies the location on | 34 // performed on the correct thread. |store_path| specifies the location on |
30 // disk for this file. | 35 // disk for this file. |
31 V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 36 V4Store(const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
32 const base::FilePath& store_path); | 37 const base::FilePath& store_path); |
33 virtual ~V4Store(); | 38 virtual ~V4Store(); |
34 | 39 |
| 40 const std::string& state() const { return state_; } |
| 41 |
| 42 const base::FilePath& store_path() const { return store_path_; } |
| 43 |
| 44 void ApplyUpdate(const ListUpdateResponse&, |
| 45 const scoped_refptr<base::SingleThreadTaskRunner>&, |
| 46 UpdatedStoreReadyCallback); |
| 47 |
| 48 std::string DebugString() const; |
| 49 |
35 // Reset internal state and delete the backing file. | 50 // Reset internal state and delete the backing file. |
36 virtual bool Reset(); | 51 virtual bool Reset(); |
37 | 52 |
38 const base::FilePath& store_path() const { | 53 private: |
39 return store_path_; | 54 // The state of the store as returned by the PVer4 server in the last applied |
40 } | 55 // update response. |
| 56 std::string state_; |
| 57 const base::FilePath store_path_; |
| 58 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 59 }; |
41 | 60 |
42 protected: | 61 std::ostream& operator<<(std::ostream& os, const V4Store& store); |
43 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
44 const base::FilePath store_path_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(V4Store); | |
47 }; | |
48 | 62 |
49 } // namespace safe_browsing | 63 } // namespace safe_browsing |
50 | 64 |
51 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 65 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
OLD | NEW |