| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_test_util.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 6 | 6 |
| 7 BrowsingDataRemoverCompletionObserver::BrowsingDataRemoverCompletionObserver( | 7 BrowsingDataRemoverCompletionObserver::BrowsingDataRemoverCompletionObserver( |
| 8 BrowsingDataRemover* remover) | 8 BrowsingDataRemover* remover) |
| 9 : message_loop_runner_(new content::MessageLoopRunner), observer_(this) { | 9 : message_loop_runner_(new content::MessageLoopRunner), observer_(this) { |
| 10 observer_.Add(remover); | 10 observer_.Add(remover); |
| 11 } | 11 } |
| 12 | 12 |
| 13 BrowsingDataRemoverCompletionObserver:: | 13 BrowsingDataRemoverCompletionObserver:: |
| 14 ~BrowsingDataRemoverCompletionObserver() {} | 14 ~BrowsingDataRemoverCompletionObserver() {} |
| 15 | 15 |
| 16 void BrowsingDataRemoverCompletionObserver::BlockUntilCompletion() { | 16 void BrowsingDataRemoverCompletionObserver::BlockUntilCompletion() { |
| 17 message_loop_runner_->Run(); | 17 message_loop_runner_->Run(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void BrowsingDataRemoverCompletionObserver::OnBrowsingDataRemoverDone() { | 20 void BrowsingDataRemoverCompletionObserver::OnBrowsingDataRemoverDone() { |
| 21 observer_.RemoveAll(); | 21 observer_.RemoveAll(); |
| 22 message_loop_runner_->Quit(); | 22 message_loop_runner_->Quit(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 BrowsingDataRemoverCompletionInhibitor::BrowsingDataRemoverCompletionInhibitor() | 25 BrowsingDataRemoverCompletionInhibitor::BrowsingDataRemoverCompletionInhibitor( |
| 26 : message_loop_runner_(new content::MessageLoopRunner) { | 26 BrowsingDataRemover* remover) |
| 27 BrowsingDataRemoverImpl::set_completion_inhibitor_for_testing(this); | 27 : remover_(remover), message_loop_runner_(new content::MessageLoopRunner) { |
| 28 remover_->SetCompletionInhibitorForTesting(this); |
| 28 } | 29 } |
| 29 | 30 |
| 30 BrowsingDataRemoverCompletionInhibitor:: | 31 BrowsingDataRemoverCompletionInhibitor:: |
| 31 ~BrowsingDataRemoverCompletionInhibitor() { | 32 ~BrowsingDataRemoverCompletionInhibitor() { |
| 32 BrowsingDataRemoverImpl::set_completion_inhibitor_for_testing(nullptr); | 33 remover_->SetCompletionInhibitorForTesting(nullptr); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void BrowsingDataRemoverCompletionInhibitor::BlockUntilNearCompletion() { | 36 void BrowsingDataRemoverCompletionInhibitor::BlockUntilNearCompletion() { |
| 36 message_loop_runner_->Run(); | 37 message_loop_runner_->Run(); |
| 37 message_loop_runner_ = new content::MessageLoopRunner; | 38 message_loop_runner_ = new content::MessageLoopRunner; |
| 38 } | 39 } |
| 39 | 40 |
| 40 void BrowsingDataRemoverCompletionInhibitor::ContinueToCompletion() { | 41 void BrowsingDataRemoverCompletionInhibitor::ContinueToCompletion() { |
| 41 DCHECK(!continue_to_completion_callback_.is_null()); | 42 DCHECK(!continue_to_completion_callback_.is_null()); |
| 42 continue_to_completion_callback_.Run(); | 43 continue_to_completion_callback_.Run(); |
| 43 continue_to_completion_callback_.Reset(); | 44 continue_to_completion_callback_.Reset(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void BrowsingDataRemoverCompletionInhibitor::OnBrowsingDataRemoverWouldComplete( | 47 void BrowsingDataRemoverCompletionInhibitor::OnBrowsingDataRemoverWouldComplete( |
| 47 BrowsingDataRemoverImpl* remover, | 48 BrowsingDataRemover* remover, |
| 48 const base::Closure& continue_to_completion) { | 49 const base::Closure& continue_to_completion) { |
| 49 DCHECK(continue_to_completion_callback_.is_null()); | 50 DCHECK(continue_to_completion_callback_.is_null()); |
| 50 continue_to_completion_callback_ = continue_to_completion; | 51 continue_to_completion_callback_ = continue_to_completion; |
| 51 message_loop_runner_->Quit(); | 52 message_loop_runner_->Quit(); |
| 52 } | 53 } |
| OLD | NEW |