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 base::FilePath& store_path() const { return store_path_; } | |
41 | |
42 const std::string& state() const { return state_; } | |
43 | |
44 void ApplyUpdate(const ListUpdateResponse&, | |
45 const scoped_refptr<base::SingleThreadTaskRunner>&, | |
46 UpdatedStoreReadyCallback); | |
47 | |
35 // Reset internal state and delete the backing file. | 48 // Reset internal state and delete the backing file. |
36 virtual bool Reset(); | 49 virtual bool Reset(); |
37 | 50 |
38 const base::FilePath& store_path() const { | 51 std::string DebugString() const; |
39 return store_path_; | |
40 } | |
41 | 52 |
42 protected: | 53 protected: |
43 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | 54 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
44 const base::FilePath store_path_; | 55 const base::FilePath store_path_; |
56 std::string state_; | |
45 | 57 |
46 DISALLOW_COPY_AND_ASSIGN(V4Store); | 58 private: |
59 V4Store(const V4Store& other); | |
60 | |
61 std::string GetHumanReadableState() const; | |
47 }; | 62 }; |
48 | 63 |
64 inline std::ostream& operator<<(std::ostream& os, const V4Store& store) { | |
65 os << store.DebugString(); | |
Nathan Parker
2016/06/15 21:24:21
Does this need to be inline? The code could do in
vakh (use Gerrit instead)
2016/06/16 01:07:35
Done.
| |
66 return os; | |
67 } | |
68 | |
49 } // namespace safe_browsing | 69 } // namespace safe_browsing |
50 | 70 |
51 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 71 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
OLD | NEW |