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
3 // found in the LICENSE file.
5 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h"
7 BrowsingDataRemoverCompletionObserver::BrowsingDataRemoverCompletionObserver(
8 BrowsingDataRemover
* remover
)
9 : message_loop_runner_(new content::MessageLoopRunner
) {
10 remover
->AddObserver(this);
13 BrowsingDataRemoverCompletionObserver::
14 ~BrowsingDataRemoverCompletionObserver() {}
16 void BrowsingDataRemoverCompletionObserver::BlockUntilCompletion() {
17 message_loop_runner_
->Run();
20 void BrowsingDataRemoverCompletionObserver::OnBrowsingDataRemoverDone() {
21 message_loop_runner_
->Quit();
24 BrowsingDataRemoverCompletionInhibitor::BrowsingDataRemoverCompletionInhibitor()
25 : message_loop_runner_(new content::MessageLoopRunner
) {
26 BrowsingDataRemover::set_completion_inhibitor_for_testing(this);
29 BrowsingDataRemoverCompletionInhibitor::
30 ~BrowsingDataRemoverCompletionInhibitor() {
31 BrowsingDataRemover::set_completion_inhibitor_for_testing(nullptr);
34 void BrowsingDataRemoverCompletionInhibitor::BlockUntilNearCompletion() {
35 message_loop_runner_
->Run();
36 message_loop_runner_
= new content::MessageLoopRunner
;
39 void BrowsingDataRemoverCompletionInhibitor::ContinueToCompletion() {
40 DCHECK(!continue_to_completion_callback_
.is_null());
41 continue_to_completion_callback_
.Run();
42 continue_to_completion_callback_
.Reset();
45 void BrowsingDataRemoverCompletionInhibitor::OnBrowsingDataRemoverWouldComplete(
46 BrowsingDataRemover
* remover
,
47 const base::Closure
& continue_to_completion
) {
48 DCHECK(continue_to_completion_callback_
.is_null());
49 continue_to_completion_callback_
= continue_to_completion
;
50 message_loop_runner_
->Quit();