Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(845)

Side by Side Diff: components/previews/core/previews_black_list.h

Issue 2387823002: Adding ClearBlackList to the PreviewsBlackList and plumbing to UI (Closed)
Patch Set: tbansal comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // the backing store. If the in memory map has reached the max number of hosts 52 // 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 53 // allowed, and |url| is a new host, a host will be evicted based on recency
54 // of the hosts most recent opt out. 54 // of the hosts most recent opt out.
55 void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type); 55 void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type);
56 56
57 // Synchronously determines if |host_name| should be allowed to show previews. 57 // 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 58 // If the black list has loaded yet, this will always return false. |type| is
59 // not used to make this decision. 59 // not used to make this decision.
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
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
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);
67
62 private: 68 private:
63 // Synchronous version of AddPreviewNavigation method. 69 // Synchronous version of AddPreviewNavigation method.
64 void AddPreviewNavigationSync(const GURL& host_name, 70 void AddPreviewNavigationSync(const GURL& host_name,
65 bool opt_out, 71 bool opt_out,
66 PreviewsType type); 72 PreviewsType type);
67 73
68 // Returns the PreviewsBlackListItem representing |host_name|. If there is no 74 // Returns the PreviewsBlackListItem representing |host_name|. If there is no
69 // item for |host_name|, returns null. 75 // item for |host_name|, returns null.
70 PreviewsBlackListItem* GetBlackListItem(const std::string& host_name) const; 76 PreviewsBlackListItem* GetBlackListItem(const std::string& host_name) const;
71 77
78 // Synchronous version of ClearBlackList method.
79 void ClearBlackListSync(base::Time begin_time, base::Time end_time);
80
72 // Returns a new PreviewsBlackListItem representing |host_name|. Adds the new 81 // Returns a new PreviewsBlackListItem representing |host_name|. Adds the new
73 // item to the in-memory map. 82 // item to the in-memory map.
74 PreviewsBlackListItem* CreateBlackListItem(const std::string& host_name); 83 PreviewsBlackListItem* CreateBlackListItem(const std::string& host_name);
75 84
76 // Callback passed to the backing store when loading black list information. 85 // Callback passed to the backing store when loading black list information.
77 // Moves the returned map into the in-memory black list and runs any 86 // Moves the returned map into the in-memory black list and runs any
78 // outstanding tasks. 87 // outstanding tasks.
79 void LoadBlackListDone(std::unique_ptr<BlackListItemMap> black_list_item_map); 88 void LoadBlackListDone(std::unique_ptr<BlackListItemMap> black_list_item_map);
80 89
81 // Called while waiting for the black list to be loaded from the backing 90 // Called while waiting for the black list to be loaded from the backing
(...skipping 24 matching lines...) Expand all
106 base::ThreadChecker thread_checker_; 115 base::ThreadChecker thread_checker_;
107 116
108 base::WeakPtrFactory<PreviewsBlackList> weak_factory_; 117 base::WeakPtrFactory<PreviewsBlackList> weak_factory_;
109 118
110 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); 119 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList);
111 }; 120 };
112 121
113 } // namespace previews 122 } // namespace previews
114 123
115 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ 124 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_
OLDNEW
« no previous file with comments | « chrome/browser/previews/previews_service_factory.cc ('k') | components/previews/core/previews_black_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698