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

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

Issue 2397783004: Queued ClearBlackList() shouldn't use weak pointer. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698