| 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/optional.h" | 9 #include "base/optional.h" |
| 10 #include "base/time/clock.h" | 10 #include "base/time/clock.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 base::Time end_time) { | 82 base::Time end_time) { |
| 83 DCHECK(thread_checker_.CalledOnValidThread()); | 83 DCHECK(thread_checker_.CalledOnValidThread()); |
| 84 DCHECK_LE(begin_time, end_time); | 84 DCHECK_LE(begin_time, end_time); |
| 85 // If the |black_list_item_map_| has been loaded from |opt_out_store_|, | 85 // If the |black_list_item_map_| has been loaded from |opt_out_store_|, |
| 86 // synchronous operations will be accurate. Otherwise, queue the task to run | 86 // synchronous operations will be accurate. Otherwise, queue the task to run |
| 87 // asynchronously. | 87 // asynchronously. |
| 88 if (loaded_) { | 88 if (loaded_) { |
| 89 ClearBlackListSync(begin_time, end_time); | 89 ClearBlackListSync(begin_time, end_time); |
| 90 } else { | 90 } else { |
| 91 QueuePendingTask(base::Bind(&PreviewsBlackList::ClearBlackListSync, | 91 QueuePendingTask(base::Bind(&PreviewsBlackList::ClearBlackListSync, |
| 92 weak_factory_.GetWeakPtr(), begin_time, | 92 base::Unretained(this), begin_time, end_time)); |
| 93 end_time)); | |
| 94 } | 93 } |
| 95 } | 94 } |
| 96 | 95 |
| 97 void PreviewsBlackList::ClearBlackListSync(base::Time begin_time, | 96 void PreviewsBlackList::ClearBlackListSync(base::Time begin_time, |
| 98 base::Time end_time) { | 97 base::Time end_time) { |
| 99 DCHECK(thread_checker_.CalledOnValidThread()); | 98 DCHECK(thread_checker_.CalledOnValidThread()); |
| 100 DCHECK(loaded_); | 99 DCHECK(loaded_); |
| 101 DCHECK_LE(begin_time, end_time); | 100 DCHECK_LE(begin_time, end_time); |
| 102 black_list_item_map_.reset(nullptr); | 101 black_list_item_map_.reset(nullptr); |
| 103 loaded_ = false; | 102 loaded_ = false; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 173 } |
| 175 if (iter->second->most_recent_opt_out_time().value() < oldest_opt_out) { | 174 if (iter->second->most_recent_opt_out_time().value() < oldest_opt_out) { |
| 176 oldest_opt_out = iter->second->most_recent_opt_out_time().value(); | 175 oldest_opt_out = iter->second->most_recent_opt_out_time().value(); |
| 177 item_to_delete = iter; | 176 item_to_delete = iter; |
| 178 } | 177 } |
| 179 } | 178 } |
| 180 black_list_item_map_->erase(item_to_delete); | 179 black_list_item_map_->erase(item_to_delete); |
| 181 } | 180 } |
| 182 | 181 |
| 183 } // namespace previews | 182 } // namespace previews |
| OLD | NEW |