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

Unified Diff: components/previews/core/previews_black_list.cc

Issue 2477073002: Adding UMA to track previews opt outs and blacklist eligibility (Closed)
Patch Set: typo 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 side-by-side diff with in-line comments
Download patch
Index: components/previews/core/previews_black_list.cc
diff --git a/components/previews/core/previews_black_list.cc b/components/previews/core/previews_black_list.cc
index fa5d1262f1eaa03ba1770685997668769fceecc2..ea5de7d822f6ebb8cf9d5504a500ad896895303a 100644
--- a/components/previews/core/previews_black_list.cc
+++ b/components/previews/core/previews_black_list.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/time/clock.h"
#include "components/previews/core/previews_black_list_item.h"
@@ -73,6 +74,13 @@ void PreviewsBlackList::AddPreviewNavigation(const GURL& url,
PreviewsType type) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(url.has_host());
+ switch (type) {
+ case PreviewsType::OFFLINE:
+ UMA_HISTOGRAM_BOOLEAN("Previews.OptOut.UserOptedOut.Offline", opt_out);
+ break;
+ default:
+ NOTREACHED();
+ }
if (opt_out) {
last_opt_out_time_ = clock_->Now();
}
@@ -108,23 +116,26 @@ void PreviewsBlackList::AddPreviewNavigationSync(const GURL& url,
opt_out_store_->AddPreviewNavigation(opt_out, host_name, type, now);
}
-bool PreviewsBlackList::IsLoadedAndAllowed(const GURL& url,
- PreviewsType type) const {
+PreviewsEligibilityReason PreviewsBlackList::IsLoadedAndAllowed(
+ const GURL& url,
+ PreviewsType type) const {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(url.has_host());
if (!loaded_)
- return false;
+ return PreviewsEligibilityReason::BLACKLIST_DATA_NOT_LOADED;
DCHECK(black_list_item_map_);
if (last_opt_out_time_ &&
clock_->Now() <
last_opt_out_time_.value() + params::SingleOptOutDuration()) {
- return false;
+ return PreviewsEligibilityReason::USER_RECENTLY_OPTED_OUT;
}
if (host_indifferent_black_list_item_->IsBlackListed(clock_->Now()))
- return false;
+ return PreviewsEligibilityReason::USER_BLACKLISTED;
PreviewsBlackListItem* black_list_item =
GetBlackListItemFromMap(*black_list_item_map_, url.host());
- return !black_list_item || !black_list_item->IsBlackListed(clock_->Now());
+ if (black_list_item && black_list_item->IsBlackListed(clock_->Now()))
+ return PreviewsEligibilityReason::HOST_BLACKLISTED;
+ return PreviewsEligibilityReason::ALLOWED;
}
void PreviewsBlackList::ClearBlackList(base::Time begin_time,
« no previous file with comments | « components/previews/core/previews_black_list.h ('k') | components/previews/core/previews_black_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698