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

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

Issue 2491803002: Revert "Adding UMA to track previews opt outs and blacklist eligibility" (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « components/previews/core/BUILD.gn ('k') | components/previews/core/previews_black_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 12 matching lines...) Expand all
23 23
24 class GURL; 24 class GURL;
25 25
26 namespace base { 26 namespace base {
27 class Clock; 27 class Clock;
28 } 28 }
29 29
30 namespace previews { 30 namespace previews {
31 class PreviewsBlackListItem; 31 class PreviewsBlackListItem;
32 32
33 enum class PreviewsEligibilityReason {
34 // The preview navigation was allowed.
35 ALLOWED = 0,
36 // The black list was not initialized.
37 BLACKLIST_UNAVAILABLE = 1,
38 // The black list has not loaded from disk yet.
39 BLACKLIST_DATA_NOT_LOADED = 2,
40 // The user has opted out of a preview recently.
41 USER_RECENTLY_OPTED_OUT = 3,
42 // The user has opted out of previews often, and is no longer shown previews
43 // on any host.
44 USER_BLACKLISTED = 4,
45 // The user has opted out of previews on a specific host often, and was not
46 // not shown a previews on that host.
47 HOST_BLACKLISTED = 5,
48 // The network quality estimate is not available.
49 NETWORK_QUALITY_UNAVAILABLE = 6,
50 // The network was fast enough to not warrant previews.
51 NETWORK_NOT_SLOW = 7,
52 LAST = 8,
53 };
54
55 // Manages the state of black listed domains for the previews experiment. Loads 33 // Manages the state of black listed domains for the previews experiment. Loads
56 // the stored black list from |opt_out_store| and manages an in memory black 34 // the stored black list from |opt_out_store| and manages an in memory black
57 // list on the IO thread. Updates to the black list are stored in memory and 35 // list on the IO thread. Updates to the black list are stored in memory and
58 // pushed to the store. Asynchronous modifications are stored in a queue and 36 // pushed to the store. Asynchronous modifications are stored in a queue and
59 // executed in order. Reading from the black list is always synchronous, and if 37 // executed in order. Reading from the black list is always synchronous, and if
60 // the black list is not currently loaded (e.g., at startup, after clearing 38 // the black list is not currently loaded (e.g., at startup, after clearing
61 // browsing history), domains are reported as black listed. The list stores no 39 // browsing history), domains are reported as black listed. The list stores no
62 // more than previews::params::MaxInMemoryHostsInBlackList hosts in-memory, 40 // more than previews::params::MaxInMemoryHostsInBlackList hosts in-memory,
63 // which defaults to 100. 41 // which defaults to 100.
64 class PreviewsBlackList { 42 class PreviewsBlackList {
65 public: 43 public:
66 // |opt_out_store| is the backing store to retrieve and store black list 44 // |opt_out_store| is the backing store to retrieve and store black list
67 // information, and can be null. When |opt_out_store| is null, the in-memory 45 // information, and can be null. When |opt_out_store| is null, the in-memory
68 // map will be immediately loaded to empty. If |opt_out_store| is non-null, 46 // map will be immediately loaded to empty. If |opt_out_store| is non-null,
69 // it will be used to load the in-memory map asynchronously. 47 // it will be used to load the in-memory map asynchronously.
70 PreviewsBlackList(std::unique_ptr<PreviewsOptOutStore> opt_out_store, 48 PreviewsBlackList(std::unique_ptr<PreviewsOptOutStore> opt_out_store,
71 std::unique_ptr<base::Clock> clock); 49 std::unique_ptr<base::Clock> clock);
72 ~PreviewsBlackList(); 50 ~PreviewsBlackList();
73 51
74 // 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
75 // 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
76 // 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
77 // 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
78 // 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
79 // of the hosts most recent opt out. 57 // of the hosts most recent opt out.
80 void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type); 58 void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type);
81 59
82 // Synchronously determines if |host_name| should be allowed to show previews. 60 // Synchronously determines if |host_name| should be allowed to show previews.
83 // Returns the reason the blacklist disallowed the preview, or 61 // If the black list has loaded yet, this will always return false. |type| is
84 // PreviewsEligibilityReason::ALLOWED if the preview is allowed. 62 // not used to make this decision.
85 PreviewsEligibilityReason IsLoadedAndAllowed(const GURL& url, 63 bool IsLoadedAndAllowed(const GURL& url, PreviewsType type) const;
86 PreviewsType type) const;
87 64
88 // Asynchronously deletes all entries in the in-memory black list. Informs 65 // Asynchronously deletes all entries in the in-memory black list. Informs
89 // the backing store to delete entries between |begin_time| and |end_time|, 66 // the backing store to delete entries between |begin_time| and |end_time|,
90 // and reloads entries into memory from the backing store. If the embedder 67 // and reloads entries into memory from the backing store. If the embedder
91 // passed in a null store, resets all history in the in-memory black list. 68 // passed in a null store, resets all history in the in-memory black list.
92 void ClearBlackList(base::Time begin_time, base::Time end_time); 69 void ClearBlackList(base::Time begin_time, base::Time end_time);
93 70
94 // Returns a new PreviewsBlackListItem representing |host_name|. Adds the new 71 // Returns a new PreviewsBlackListItem representing |host_name|. Adds the new
95 // item to |black_list_item_map|. 72 // item to |black_list_item_map|.
96 static PreviewsBlackListItem* GetOrCreateBlackListItemForMap( 73 static PreviewsBlackListItem* GetOrCreateBlackListItemForMap(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 base::ThreadChecker thread_checker_; 125 base::ThreadChecker thread_checker_;
149 126
150 base::WeakPtrFactory<PreviewsBlackList> weak_factory_; 127 base::WeakPtrFactory<PreviewsBlackList> weak_factory_;
151 128
152 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); 129 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList);
153 }; 130 };
154 131
155 } // namespace previews 132 } // namespace previews
156 133
157 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ 134 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_
OLDNEW
« no previous file with comments | « components/previews/core/BUILD.gn ('k') | components/previews/core/previews_black_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698