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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 bool IsLoadedAndAllowed(const GURL& url, PreviewsType type) const; | 60 bool IsLoadedAndAllowed(const GURL& url, PreviewsType type) const; |
61 | 61 |
62 // Asynchronously deletes all entries in the in-memory black list. Informs | 62 // Asynchronously deletes all entries in the in-memory black list. Informs |
63 // the backing store to delete entries between |begin_time| and |end_time|, | 63 // the backing store to delete entries between |begin_time| and |end_time|, |
64 // and reloads entries into memory from the backing store. If the embedder | 64 // and reloads entries into memory from the backing store. If the embedder |
65 // passed in a null store, resets all history in the in-memory black list. | 65 // passed in a null store, resets all history in the in-memory black list. |
66 void ClearBlackList(base::Time begin_time, base::Time end_time); | 66 void ClearBlackList(base::Time begin_time, base::Time end_time); |
67 | 67 |
68 // Returns a new PreviewsBlackListItem representing |host_name|. Adds the new | 68 // Returns a new PreviewsBlackListItem representing |host_name|. Adds the new |
69 // item to |black_list_item_map|. | 69 // item to |black_list_item_map|. |
70 static PreviewsBlackListItem* GetOrCreateBlackListItem( | 70 static PreviewsBlackListItem* GetOrCreateBlackListItemForMap( |
71 BlackListItemMap* black_list_item_map, | 71 BlackListItemMap* black_list_item_map, |
72 const std::string& host_name); | 72 const std::string& host_name); |
73 | 73 |
74 // Returns the PreviewsBlackListItem representing |host_name| in | 74 // Returns a new PreviewsBlackListItem for the general black list that does |
tbansal1
2016/10/21 22:56:26
"general" is very vague. Can you use a more specif
RyanSturm
2016/10/24 22:24:40
Done.
| |
75 // |black_list_item_map|. If there is no item for |host_name|, returns null. | 75 // not consider host name. |
76 static PreviewsBlackListItem* GetBlackListItem( | 76 static std::unique_ptr<PreviewsBlackListItem> CreateGeneralBlackListItem(); |
77 const BlackListItemMap& black_list_item_map, | |
78 const std::string& host_name); | |
79 | 77 |
80 private: | 78 private: |
81 // Synchronous version of AddPreviewNavigation method. | 79 // Synchronous version of AddPreviewNavigation method. |
82 void AddPreviewNavigationSync(const GURL& host_name, | 80 void AddPreviewNavigationSync(const GURL& host_name, |
83 bool opt_out, | 81 bool opt_out, |
84 PreviewsType type); | 82 PreviewsType type); |
85 | 83 |
86 // Synchronous version of ClearBlackList method. | 84 // Synchronous version of ClearBlackList method. |
87 void ClearBlackListSync(base::Time begin_time, base::Time end_time); | 85 void ClearBlackListSync(base::Time begin_time, base::Time end_time); |
88 | 86 |
89 // Callback passed to the backing store when loading black list information. | 87 // Callback passed to the backing store when loading black list information. |
90 // Moves the returned map into the in-memory black list and runs any | 88 // Moves the |black_list_item_map| and |general_black_list_item| into the |
91 // outstanding tasks. | 89 // in-memory black list and runs any outstanding tasks. |
92 void LoadBlackListDone(std::unique_ptr<BlackListItemMap> black_list_item_map); | 90 void LoadBlackListDone( |
91 std::unique_ptr<BlackListItemMap> black_list_item_map, | |
92 std::unique_ptr<PreviewsBlackListItem> general_black_list_item); | |
93 | 93 |
94 // Called while waiting for the black list to be loaded from the backing | 94 // Called while waiting for the black list to be loaded from the backing |
95 // store. | 95 // store. |
96 // Enqueues a task to run when when loading black list information has | 96 // Enqueues a task to run when when loading black list information has |
97 // completed. Maintains the order that tasks were called in. | 97 // completed. Maintains the order that tasks were called in. |
98 void QueuePendingTask(base::Closure callback); | 98 void QueuePendingTask(base::Closure callback); |
99 | 99 |
100 // Map maintaining the in-memory black list. | 100 // Map maintaining the in-memory black list. |
101 std::unique_ptr<BlackListItemMap> black_list_item_map_; | 101 std::unique_ptr<BlackListItemMap> black_list_item_map_; |
102 | 102 |
103 // General opt out history not based on host. | |
104 std::unique_ptr<PreviewsBlackListItem> general_black_list_item_; | |
105 | |
103 // Whether the black list is done being loaded from the backing store. | 106 // Whether the black list is done being loaded from the backing store. |
104 bool loaded_; | 107 bool loaded_; |
105 | 108 |
106 // The backing store of the black list information. | 109 // The backing store of the black list information. |
107 std::unique_ptr<PreviewsOptOutStore> opt_out_store_; | 110 std::unique_ptr<PreviewsOptOutStore> opt_out_store_; |
108 | 111 |
109 // Callbacks to be run after loading information from the backing store has | 112 // Callbacks to be run after loading information from the backing store has |
110 // completed. | 113 // completed. |
111 std::queue<base::Closure> pending_callbacks_; | 114 std::queue<base::Closure> pending_callbacks_; |
112 | 115 |
113 std::unique_ptr<base::Clock> clock_; | 116 std::unique_ptr<base::Clock> clock_; |
114 | 117 |
115 base::ThreadChecker thread_checker_; | 118 base::ThreadChecker thread_checker_; |
116 | 119 |
117 base::WeakPtrFactory<PreviewsBlackList> weak_factory_; | 120 base::WeakPtrFactory<PreviewsBlackList> weak_factory_; |
118 | 121 |
119 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); | 122 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); |
120 }; | 123 }; |
121 | 124 |
122 } // namespace previews | 125 } // namespace previews |
123 | 126 |
124 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ | 127 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ |
OLD | NEW |