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

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

Issue 2760063002: Add support to previews/ for Server LoFi and LitePages (Closed)
Patch Set: rebase and previews_service_unittest.cc Created 3 years, 7 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 #include "components/previews/core/previews_black_list.h" 5 #include "components/previews/core/previews_black_list.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram.h"
10 #include "base/optional.h" 10 #include "base/optional.h"
11 #include "base/time/clock.h" 11 #include "base/time/clock.h"
12 #include "components/previews/core/previews_black_list_item.h" 12 #include "components/previews/core/previews_black_list_item.h"
13 #include "components/previews/core/previews_experiments.h" 13 #include "components/previews/core/previews_experiments.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace previews { 16 namespace previews {
17 17
18 namespace { 18 namespace {
19 19
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 } 68 }
69 69
70 PreviewsBlackList::~PreviewsBlackList() {} 70 PreviewsBlackList::~PreviewsBlackList() {}
71 71
72 void PreviewsBlackList::AddPreviewNavigation(const GURL& url, 72 void PreviewsBlackList::AddPreviewNavigation(const GURL& url,
73 bool opt_out, 73 bool opt_out,
74 PreviewsType type) { 74 PreviewsType type) {
75 DCHECK(thread_checker_.CalledOnValidThread()); 75 DCHECK(thread_checker_.CalledOnValidThread());
76 DCHECK(url.has_host()); 76 DCHECK(url.has_host());
77 switch (type) { 77 std::string histogram_name("Previews.OptOut.UserOptedOut.");
tbansal1 2017/05/02 21:49:31 Use StringPiece or base::StringPrintf to reduce
RyanSturm 2017/05/02 22:57:18 Done.
78 case PreviewsType::OFFLINE: 78 histogram_name.append(GetStringNameForType(type));
79 UMA_HISTOGRAM_BOOLEAN("Previews.OptOut.UserOptedOut.Offline", opt_out); 79
80 break; 80 base::BooleanHistogram::FactoryGet(
81 default: 81 histogram_name, base::HistogramBase::kUmaTargetedHistogramFlag)
82 NOTREACHED(); 82 ->Add(opt_out);
83 }
84 if (opt_out) { 83 if (opt_out) {
85 last_opt_out_time_ = clock_->Now(); 84 last_opt_out_time_ = clock_->Now();
86 } 85 }
87 // If the |black_list_item_map_| has been loaded from |opt_out_store_|, 86 // If the |black_list_item_map_| has been loaded from |opt_out_store_|,
88 // synchronous operations will be accurate. Otherwise, queue the task to run 87 // synchronous operations will be accurate. Otherwise, queue the task to run
89 // asynchronously. 88 // asynchronously.
90 if (loaded_) { 89 if (loaded_) {
91 AddPreviewNavigationSync(url, opt_out, type); 90 AddPreviewNavigationSync(url, opt_out, type);
92 } else { 91 } else {
93 QueuePendingTask(base::Bind(&PreviewsBlackList::AddPreviewNavigationSync, 92 QueuePendingTask(base::Bind(&PreviewsBlackList::AddPreviewNavigationSync,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // static 220 // static
222 std::unique_ptr<PreviewsBlackListItem> 221 std::unique_ptr<PreviewsBlackListItem>
223 PreviewsBlackList::CreateHostIndifferentBlackListItem() { 222 PreviewsBlackList::CreateHostIndifferentBlackListItem() {
224 return base::MakeUnique<PreviewsBlackListItem>( 223 return base::MakeUnique<PreviewsBlackListItem>(
225 params::MaxStoredHistoryLengthForHostIndifferentBlackList(), 224 params::MaxStoredHistoryLengthForHostIndifferentBlackList(),
226 params::HostIndifferentBlackListOptOutThreshold(), 225 params::HostIndifferentBlackListOptOutThreshold(),
227 params::HostIndifferentBlackListPerHostDuration()); 226 params::HostIndifferentBlackListPerHostDuration());
228 } 227 }
229 228
230 } // namespace previews 229 } // namespace previews
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698