| 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> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 enum class PreviewsType { | 23 enum class PreviewsType { |
| 24 NONE = 0, | 24 NONE = 0, |
| 25 OFFLINE = 1, | 25 OFFLINE = 1, |
| 26 LAST = 2, | 26 LAST = 2, |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 typedef std::unordered_map<std::string, std::unique_ptr<PreviewsBlackListItem>> | 29 typedef std::unordered_map<std::string, std::unique_ptr<PreviewsBlackListItem>> |
| 30 BlackListItemMap; | 30 BlackListItemMap; |
| 31 | 31 |
| 32 typedef base::Callback<void(std::unique_ptr<BlackListItemMap>)> | 32 typedef base::Callback<void(std::unique_ptr<BlackListItemMap>, |
| 33 std::unique_ptr<PreviewsBlackListItem>)> |
| 33 LoadBlackListCallback; | 34 LoadBlackListCallback; |
| 34 | 35 |
| 35 // PreviewsOptOutStore keeps opt out information for the previews. | 36 // PreviewsOptOutStore keeps opt out information for the previews. |
| 36 // Ability to create multiple instances of the store as well as behavior of | 37 // Ability to create multiple instances of the store as well as behavior of |
| 37 // asynchronous operations when the object is being destroyed, before such | 38 // asynchronous operations when the object is being destroyed, before such |
| 38 // operation finishes will depend on implementation. It is possible to issue | 39 // operation finishes will depend on implementation. It is possible to issue |
| 39 // multiple asynchronous operations in parallel and maintain ordering. | 40 // multiple asynchronous operations in parallel and maintain ordering. |
| 40 class PreviewsOptOutStore { | 41 class PreviewsOptOutStore { |
| 41 public: | 42 public: |
| 42 virtual ~PreviewsOptOutStore() {} | 43 virtual ~PreviewsOptOutStore() {} |
| 43 | 44 |
| 44 // Adds a new navigation to the store. |opt_out| is whether the user opted out | 45 // Adds a new navigation to the store. |opt_out| is whether the user opted out |
| 45 // of the preview. | 46 // of the preview. |
| 46 virtual void AddPreviewNavigation(bool opt_out, | 47 virtual void AddPreviewNavigation(bool opt_out, |
| 47 const std::string& host_name, | 48 const std::string& host_name, |
| 48 PreviewsType type, | 49 PreviewsType type, |
| 49 base::Time now) = 0; | 50 base::Time now) = 0; |
| 50 | 51 |
| 51 // Asynchronously loads a map of host names to PreviewsBlackListItem for that | 52 // Asynchronously loads a map of host names to PreviewsBlackListItem for that |
| 52 // host from the store. And runs |callback| once loading is finished. | 53 // host from the store. And runs |callback| once loading is finished. |
| 53 virtual void LoadBlackList(LoadBlackListCallback callback) = 0; | 54 virtual void LoadBlackList(LoadBlackListCallback callback) = 0; |
| 54 | 55 |
| 55 // Deletes all history in the store between |begin_time| and |end_time|. | 56 // Deletes all history in the store between |begin_time| and |end_time|. |
| 56 virtual void ClearBlackList(base::Time begin_time, base::Time end_time) = 0; | 57 virtual void ClearBlackList(base::Time begin_time, base::Time end_time) = 0; |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 } // namespace previews | 60 } // namespace previews |
| 60 | 61 |
| 61 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ | 62 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_OPT_OUT_STORE_H_ |
| OLD | NEW |