| OLD | NEW |
| 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.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/optional.h" | 10 #include "base/optional.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 QueuePendingTask(base::Bind(&PreviewsBlackList::ClearBlackListSync, | 151 QueuePendingTask(base::Bind(&PreviewsBlackList::ClearBlackListSync, |
| 152 base::Unretained(this), begin_time, end_time)); | 152 base::Unretained(this), begin_time, end_time)); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 void PreviewsBlackList::ClearBlackListSync(base::Time begin_time, | 156 void PreviewsBlackList::ClearBlackListSync(base::Time begin_time, |
| 157 base::Time end_time) { | 157 base::Time end_time) { |
| 158 DCHECK(thread_checker_.CalledOnValidThread()); | 158 DCHECK(thread_checker_.CalledOnValidThread()); |
| 159 DCHECK(loaded_); | 159 DCHECK(loaded_); |
| 160 DCHECK_LE(begin_time, end_time); | 160 DCHECK_LE(begin_time, end_time); |
| 161 |
| 162 // Clear last_opt_out_time_ if the period being cleared is larger than the |
| 163 // short black list timeout and the last time the user opted out was before |
| 164 // |end_time|. |
| 165 if (end_time - begin_time > params::SingleOptOutDuration() && |
| 166 last_opt_out_time_ && last_opt_out_time_.value() < end_time) { |
| 167 last_opt_out_time_.reset(); |
| 168 } |
| 161 black_list_item_map_.reset(); | 169 black_list_item_map_.reset(); |
| 162 host_indifferent_black_list_item_.reset(); | 170 host_indifferent_black_list_item_.reset(); |
| 163 loaded_ = false; | 171 loaded_ = false; |
| 164 // Delete relevant entries and reload the blacklist into memory. | 172 // Delete relevant entries and reload the blacklist into memory. |
| 165 if (opt_out_store_) { | 173 if (opt_out_store_) { |
| 166 opt_out_store_->ClearBlackList(begin_time, end_time); | 174 opt_out_store_->ClearBlackList(begin_time, end_time); |
| 167 opt_out_store_->LoadBlackList(base::Bind( | 175 opt_out_store_->LoadBlackList(base::Bind( |
| 168 &PreviewsBlackList::LoadBlackListDone, weak_factory_.GetWeakPtr())); | 176 &PreviewsBlackList::LoadBlackListDone, weak_factory_.GetWeakPtr())); |
| 169 } else { | 177 } else { |
| 170 LoadBlackListDone(base::MakeUnique<BlackListItemMap>(), | 178 LoadBlackListDone(base::MakeUnique<BlackListItemMap>(), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // static | 229 // static |
| 222 std::unique_ptr<PreviewsBlackListItem> | 230 std::unique_ptr<PreviewsBlackListItem> |
| 223 PreviewsBlackList::CreateHostIndifferentBlackListItem() { | 231 PreviewsBlackList::CreateHostIndifferentBlackListItem() { |
| 224 return base::MakeUnique<PreviewsBlackListItem>( | 232 return base::MakeUnique<PreviewsBlackListItem>( |
| 225 params::MaxStoredHistoryLengthForHostIndifferentBlackList(), | 233 params::MaxStoredHistoryLengthForHostIndifferentBlackList(), |
| 226 params::HostIndifferentBlackListOptOutThreshold(), | 234 params::HostIndifferentBlackListOptOutThreshold(), |
| 227 params::HostIndifferentBlackListPerHostDuration()); | 235 params::HostIndifferentBlackListPerHostDuration()); |
| 228 } | 236 } |
| 229 | 237 |
| 230 } // namespace previews | 238 } // namespace previews |
| OLD | NEW |