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_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ | 5 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ |
6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ | 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <unordered_map> | 12 #include <unordered_map> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "components/previews/core/previews_black_list_item.h" | 17 #include "components/previews/core/previews_black_list_item.h" |
18 #include "components/previews/core/previews_experiments.h" | 18 #include "components/previews/core/previews_experiments.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 | 21 |
22 namespace previews { | 22 namespace previews { |
23 | 23 |
24 typedef std::unordered_map<std::string, std::unique_ptr<PreviewsBlackListItem>> | 24 typedef std::unordered_map<std::string, std::unique_ptr<PreviewsBlackListItem>> |
25 BlackListItemMap; | 25 BlackListItemMap; |
26 | 26 |
27 typedef base::Callback<void(std::unique_ptr<BlackListItemMap>)> | 27 typedef base::Callback<void(std::unique_ptr<BlackListItemMap>, |
| 28 std::unique_ptr<PreviewsBlackListItem>)> |
28 LoadBlackListCallback; | 29 LoadBlackListCallback; |
29 | 30 |
30 // PreviewsOptOutStore keeps opt out information for the previews. | 31 // PreviewsOptOutStore keeps opt out information for the previews. |
31 // Ability to create multiple instances of the store as well as behavior of | 32 // Ability to create multiple instances of the store as well as behavior of |
32 // asynchronous operations when the object is being destroyed, before such | 33 // asynchronous operations when the object is being destroyed, before such |
33 // operation finishes will depend on implementation. It is possible to issue | 34 // operation finishes will depend on implementation. It is possible to issue |
34 // multiple asynchronous operations in parallel and maintain ordering. | 35 // multiple asynchronous operations in parallel and maintain ordering. |
35 class PreviewsOptOutStore { | 36 class PreviewsOptOutStore { |
36 public: | 37 public: |
37 virtual ~PreviewsOptOutStore() {} | 38 virtual ~PreviewsOptOutStore() {} |
38 | 39 |
39 // Adds a new navigation to the store. |opt_out| is whether the user opted out | 40 // Adds a new navigation to the store. |opt_out| is whether the user opted out |
40 // of the preview. | 41 // of the preview. |
41 virtual void AddPreviewNavigation(bool opt_out, | 42 virtual void AddPreviewNavigation(bool opt_out, |
42 const std::string& host_name, | 43 const std::string& host_name, |
43 PreviewsType type, | 44 PreviewsType type, |
44 base::Time now) = 0; | 45 base::Time now) = 0; |
45 | 46 |
46 // Asynchronously loads a map of host names to PreviewsBlackListItem for that | 47 // Asynchronously loads a map of host names to PreviewsBlackListItem for that |
47 // host from the store. And runs |callback| once loading is finished. | 48 // host from the store. And runs |callback| once loading is finished. |
48 virtual void LoadBlackList(LoadBlackListCallback callback) = 0; | 49 virtual void LoadBlackList(LoadBlackListCallback callback) = 0; |
49 | 50 |
50 // Deletes all history in the store between |begin_time| and |end_time|. | 51 // Deletes all history in the store between |begin_time| and |end_time|. |
51 virtual void ClearBlackList(base::Time begin_time, base::Time end_time) = 0; | 52 virtual void ClearBlackList(base::Time begin_time, base::Time end_time) = 0; |
52 }; | 53 }; |
53 | 54 |
54 } // namespace previews | 55 } // namespace previews |
55 | 56 |
56 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ | 57 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ |
OLD | NEW |