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_BLACK_LIST_H_ | 5 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ |
6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ | 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 28 matching lines...) Expand all Loading... |
39 class PreviewsBlackList { | 39 class PreviewsBlackList { |
40 public: | 40 public: |
41 // |opt_out_store| is the backing store to retrieve and store black list | 41 // |opt_out_store| is the backing store to retrieve and store black list |
42 // information, and can be null. When |opt_out_store| is null, the in-memory | 42 // information, and can be null. When |opt_out_store| is null, the in-memory |
43 // map will be immediately loaded to empty. If |opt_out_store| is non-null, | 43 // map will be immediately loaded to empty. If |opt_out_store| is non-null, |
44 // it will be used to load the in-memory map asynchronously. | 44 // it will be used to load the in-memory map asynchronously. |
45 PreviewsBlackList(std::unique_ptr<PreviewsOptOutStore> opt_out_store, | 45 PreviewsBlackList(std::unique_ptr<PreviewsOptOutStore> opt_out_store, |
46 std::unique_ptr<base::Clock> clock); | 46 std::unique_ptr<base::Clock> clock); |
47 ~PreviewsBlackList(); | 47 ~PreviewsBlackList(); |
48 | 48 |
| 49 // Begins loading the black list from the backing store if one was passed in. |
| 50 void Initialize(); |
| 51 |
49 // Asynchronously adds a new navigation to to the in-memory black list and | 52 // Asynchronously adds a new navigation to to the in-memory black list and |
50 // backing store. |opt_out| is whether the user opted out of the preview or | 53 // backing store. |opt_out| is whether the user opted out of the preview or |
51 // navigated away from the page without opting out. |type| is only passed to | 54 // navigated away from the page without opting out. |type| is only passed to |
52 // the backing store. If the in memory map has reached the max number of hosts | 55 // the backing store. If the in memory map has reached the max number of hosts |
53 // allowed, and |url| is a new host, a host will be evicted based on recency | 56 // allowed, and |url| is a new host, a host will be evicted based on recency |
54 // of the hosts most recent opt out. | 57 // of the hosts most recent opt out. |
55 void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type); | 58 void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type); |
56 | 59 |
57 // Synchronously determines if |host_name| should be allowed to show previews. | 60 // Synchronously determines if |host_name| should be allowed to show previews. |
58 // If the black list has loaded yet, this will always return false. |type| is | 61 // If the black list has loaded yet, this will always return false. |type| is |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::ThreadChecker thread_checker_; | 109 base::ThreadChecker thread_checker_; |
107 | 110 |
108 base::WeakPtrFactory<PreviewsBlackList> weak_factory_; | 111 base::WeakPtrFactory<PreviewsBlackList> weak_factory_; |
109 | 112 |
110 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); | 113 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); |
111 }; | 114 }; |
112 | 115 |
113 } // namespace previews | 116 } // namespace previews |
114 | 117 |
115 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ | 118 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ |
OLD | NEW |