Index: components/previews/core/previews_black_list.h |
diff --git a/components/previews/core/previews_black_list.h b/components/previews/core/previews_black_list.h |
index ad192463f17372ea9b166b89fa643976b99d4584..cdc2e000e208c54132d78e40df7400e2b6e2fa88 100644 |
--- a/components/previews/core/previews_black_list.h |
+++ b/components/previews/core/previews_black_list.h |
@@ -23,20 +23,38 @@ |
class GURL; |
namespace base { |
class Clock; |
} |
namespace previews { |
class PreviewsBlackListItem; |
+enum class PreviewsEligibilityReason { |
tbansal1
2016/11/08 00:30:52
nit: Is there a reason to use this style of commen
RyanSturm
2016/11/08 22:22:29
Done.
|
+ ALLOWED = 0, // The preview navigation was allowed. |
+ BLACKLIST_UNAVAILABLE = 1, // The black list was not initialized. |
+ BLACKLIST_DATA_NOT_LOADED = |
+ 2, // The black list has not loaded from disk yet. |
+ USER_RECENTLY_OPTED_OUT = 3, // The user has opted out of a preview |
+ // recently. |
+ USER_BLACKLISTED = 4, // The user has opted out of previews often, and is no |
+ // longer shown previews on any host. |
+ HOST_BLACKLISTED = 5, // The user has opted out of previews on a specific |
+ // host often, and was not not shown a previews on that |
+ // host. |
+ NETWORK_QUALITY_UNAVAILABLE = |
+ 6, // the network quality estimate is not available. |
+ NETWORK_NOT_SLOW = 7, // The network was fast enough to not warrant previews. |
+ LAST = 8, |
+}; |
+ |
// Manages the state of black listed domains for the previews experiment. Loads |
// the stored black list from |opt_out_store| and manages an in memory black |
// list on the IO thread. Updates to the black list are stored in memory and |
// pushed to the store. Asynchronous modifications are stored in a queue and |
// executed in order. Reading from the black list is always synchronous, and if |
// the black list is not currently loaded (e.g., at startup, after clearing |
// browsing history), domains are reported as black listed. The list stores no |
// more than previews::params::MaxInMemoryHostsInBlackList hosts in-memory, |
// which defaults to 100. |
class PreviewsBlackList { |
@@ -51,23 +69,24 @@ class PreviewsBlackList { |
// Asynchronously adds a new navigation to to the in-memory black list and |
// backing store. |opt_out| is whether the user opted out of the preview or |
// navigated away from the page without opting out. |type| is only passed to |
// the backing store. If the in memory map has reached the max number of hosts |
// allowed, and |url| is a new host, a host will be evicted based on recency |
// of the hosts most recent opt out. |
void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type); |
// Synchronously determines if |host_name| should be allowed to show previews. |
- // If the black list has loaded yet, this will always return false. |type| is |
- // not used to make this decision. |
- bool IsLoadedAndAllowed(const GURL& url, PreviewsType type) const; |
+ // Returns the reason the blacklist disallowed the preview, or |
+ // PreviewsEligibilityReason::ALLOWED if the preview is allowed. |
+ PreviewsEligibilityReason IsLoadedAndAllowed(const GURL& url, |
+ PreviewsType type) const; |
// Asynchronously deletes all entries in the in-memory black list. Informs |
// the backing store to delete entries between |begin_time| and |end_time|, |
// and reloads entries into memory from the backing store. If the embedder |
// passed in a null store, resets all history in the in-memory black list. |
void ClearBlackList(base::Time begin_time, base::Time end_time); |
// Returns a new PreviewsBlackListItem representing |host_name|. Adds the new |
// item to |black_list_item_map|. |
static PreviewsBlackListItem* GetOrCreateBlackListItemForMap( |