| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/browsing_data/browsing_data_remover_impl.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 net::ChannelIDService* channel_id_service = | 144 net::ChannelIDService* channel_id_service = |
| 145 rq_context->GetURLRequestContext()->channel_id_service(); | 145 rq_context->GetURLRequestContext()->channel_id_service(); |
| 146 channel_id_service->GetChannelIDStore()->DeleteForDomainsCreatedBetween( | 146 channel_id_service->GetChannelIDStore()->DeleteForDomainsCreatedBetween( |
| 147 domain_predicate, delete_begin, delete_end, | 147 domain_predicate, delete_begin, delete_end, |
| 148 base::Bind(&OnClearedChannelIDsOnIOThread, | 148 base::Bind(&OnClearedChannelIDsOnIOThread, |
| 149 base::RetainedRef(std::move(rq_context)), callback)); | 149 base::RetainedRef(std::move(rq_context)), callback)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 BrowsingDataRemoverImpl::CompletionInhibitor* | |
| 155 BrowsingDataRemoverImpl::completion_inhibitor_ = nullptr; | |
| 156 | |
| 157 BrowsingDataRemoverImpl::SubTask::SubTask(const base::Closure& forward_callback) | 154 BrowsingDataRemoverImpl::SubTask::SubTask(const base::Closure& forward_callback) |
| 158 : is_pending_(false), | 155 : is_pending_(false), |
| 159 forward_callback_(forward_callback), | 156 forward_callback_(forward_callback), |
| 160 weak_ptr_factory_(this) { | 157 weak_ptr_factory_(this) { |
| 161 DCHECK(!forward_callback_.is_null()); | 158 DCHECK(!forward_callback_.is_null()); |
| 162 } | 159 } |
| 163 | 160 |
| 164 BrowsingDataRemoverImpl::SubTask::~SubTask() {} | 161 BrowsingDataRemoverImpl::SubTask::~SubTask() {} |
| 165 | 162 |
| 166 void BrowsingDataRemoverImpl::SubTask::Start() { | 163 void BrowsingDataRemoverImpl::SubTask::Start() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 189 is_removing_(false), | 186 is_removing_(false), |
| 190 sub_task_forward_callback_( | 187 sub_task_forward_callback_( |
| 191 base::Bind(&BrowsingDataRemoverImpl::NotifyIfDone, | 188 base::Bind(&BrowsingDataRemoverImpl::NotifyIfDone, |
| 192 base::Unretained(this))), | 189 base::Unretained(this))), |
| 193 synchronous_clear_operations_(sub_task_forward_callback_), | 190 synchronous_clear_operations_(sub_task_forward_callback_), |
| 194 clear_embedder_data_(sub_task_forward_callback_), | 191 clear_embedder_data_(sub_task_forward_callback_), |
| 195 clear_cache_(sub_task_forward_callback_), | 192 clear_cache_(sub_task_forward_callback_), |
| 196 clear_channel_ids_(sub_task_forward_callback_), | 193 clear_channel_ids_(sub_task_forward_callback_), |
| 197 clear_http_auth_cache_(sub_task_forward_callback_), | 194 clear_http_auth_cache_(sub_task_forward_callback_), |
| 198 clear_storage_partition_data_(sub_task_forward_callback_), | 195 clear_storage_partition_data_(sub_task_forward_callback_), |
| 196 storage_partition_for_testing_(nullptr), |
| 199 weak_ptr_factory_(this) { | 197 weak_ptr_factory_(this) { |
| 200 DCHECK(browser_context_); | 198 DCHECK(browser_context_); |
| 201 } | 199 } |
| 202 | 200 |
| 203 BrowsingDataRemoverImpl::~BrowsingDataRemoverImpl() { | 201 BrowsingDataRemoverImpl::~BrowsingDataRemoverImpl() { |
| 204 if (!task_queue_.empty()) { | 202 if (!task_queue_.empty()) { |
| 205 VLOG(1) << "BrowsingDataRemoverImpl shuts down with " << task_queue_.size() | 203 VLOG(1) << "BrowsingDataRemoverImpl shuts down with " << task_queue_.size() |
| 206 << " pending tasks"; | 204 << " pending tasks"; |
| 207 } | 205 } |
| 208 | 206 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 568 } |
| 571 | 569 |
| 572 void BrowsingDataRemoverImpl::AddObserver(Observer* observer) { | 570 void BrowsingDataRemoverImpl::AddObserver(Observer* observer) { |
| 573 observer_list_.AddObserver(observer); | 571 observer_list_.AddObserver(observer); |
| 574 } | 572 } |
| 575 | 573 |
| 576 void BrowsingDataRemoverImpl::RemoveObserver(Observer* observer) { | 574 void BrowsingDataRemoverImpl::RemoveObserver(Observer* observer) { |
| 577 observer_list_.RemoveObserver(observer); | 575 observer_list_.RemoveObserver(observer); |
| 578 } | 576 } |
| 579 | 577 |
| 578 void BrowsingDataRemoverImpl::SetWouldCompleteCallbackForTesting( |
| 579 const base::Callback<void(const base::Closure& continue_to_completion)>& |
| 580 callback) { |
| 581 would_complete_callback_ = callback; |
| 582 } |
| 583 |
| 580 void BrowsingDataRemoverImpl::OverrideStoragePartitionForTesting( | 584 void BrowsingDataRemoverImpl::OverrideStoragePartitionForTesting( |
| 581 content::StoragePartition* storage_partition) { | 585 content::StoragePartition* storage_partition) { |
| 582 storage_partition_for_testing_ = storage_partition; | 586 storage_partition_for_testing_ = storage_partition; |
| 583 } | 587 } |
| 584 | 588 |
| 585 const base::Time& BrowsingDataRemoverImpl::GetLastUsedBeginTime() { | 589 const base::Time& BrowsingDataRemoverImpl::GetLastUsedBeginTime() { |
| 586 return delete_begin_; | 590 return delete_begin_; |
| 587 } | 591 } |
| 588 | 592 |
| 589 const base::Time& BrowsingDataRemoverImpl::GetLastUsedEndTime() { | 593 const base::Time& BrowsingDataRemoverImpl::GetLastUsedEndTime() { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 } | 664 } |
| 661 | 665 |
| 662 void BrowsingDataRemoverImpl::NotifyIfDone() { | 666 void BrowsingDataRemoverImpl::NotifyIfDone() { |
| 663 // TODO(brettw) http://crbug.com/305259: This should also observe session | 667 // TODO(brettw) http://crbug.com/305259: This should also observe session |
| 664 // clearing (what about other things such as passwords, etc.?) and wait for | 668 // clearing (what about other things such as passwords, etc.?) and wait for |
| 665 // them to complete before continuing. | 669 // them to complete before continuing. |
| 666 | 670 |
| 667 if (!AllDone()) | 671 if (!AllDone()) |
| 668 return; | 672 return; |
| 669 | 673 |
| 670 if (completion_inhibitor_) { | 674 if (!would_complete_callback_.is_null()) { |
| 671 completion_inhibitor_->OnBrowsingDataRemoverWouldComplete( | 675 would_complete_callback_.Run( |
| 672 this, base::Bind(&BrowsingDataRemoverImpl::Notify, GetWeakPtr())); | 676 base::Bind(&BrowsingDataRemoverImpl::Notify, GetWeakPtr())); |
| 673 return; | 677 return; |
| 674 } | 678 } |
| 675 | 679 |
| 676 Notify(); | 680 Notify(); |
| 677 } | 681 } |
| 678 | 682 |
| 679 base::WeakPtr<BrowsingDataRemoverImpl> BrowsingDataRemoverImpl::GetWeakPtr() { | 683 base::WeakPtr<BrowsingDataRemoverImpl> BrowsingDataRemoverImpl::GetWeakPtr() { |
| 680 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 684 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 681 base::WeakPtr<BrowsingDataRemoverImpl> weak_ptr = | 685 base::WeakPtr<BrowsingDataRemoverImpl> weak_ptr = |
| 682 weak_ptr_factory_.GetWeakPtr(); | 686 weak_ptr_factory_.GetWeakPtr(); |
| 683 | 687 |
| 684 // Immediately bind the weak pointer to the UI thread. This makes it easier | 688 // Immediately bind the weak pointer to the UI thread. This makes it easier |
| 685 // to discover potential misuse on the IO thread. | 689 // to discover potential misuse on the IO thread. |
| 686 weak_ptr.get(); | 690 weak_ptr.get(); |
| 687 | 691 |
| 688 return weak_ptr; | 692 return weak_ptr; |
| 689 } | 693 } |
| OLD | NEW |