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. 4 5 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" 6 7 BrowsingDataRemoverCompletionObserver::BrowsingDataRemoverCompletionObserver( 8 BrowsingDataRemover* remover) 9 : message_loop_runner_(new content::MessageLoopRunner) { 10 remover->AddObserver(this); 11 } 12 13 BrowsingDataRemoverCompletionObserver:: 14 ~BrowsingDataRemoverCompletionObserver() {} 15 16 void BrowsingDataRemoverCompletionObserver::BlockUntilCompletion() { 17 message_loop_runner_->Run(); 18 } 19 20 void BrowsingDataRemoverCompletionObserver::OnBrowsingDataRemoverDone() { 21 message_loop_runner_->Quit(); 22 } 23 24 BrowsingDataRemoverCompletionInhibitor::BrowsingDataRemoverCompletionInhibitor() 25 : message_loop_runner_(new content::MessageLoopRunner) { 26 BrowsingDataRemover::set_completion_inhibitor_for_testing(this); 27 } 28 29 BrowsingDataRemoverCompletionInhibitor:: 30 ~BrowsingDataRemoverCompletionInhibitor() { 31 BrowsingDataRemover::set_completion_inhibitor_for_testing(NULL); 32 } 33 34 void BrowsingDataRemoverCompletionInhibitor::BlockUntilNearCompletion() { 35 message_loop_runner_->Run(); 36 message_loop_runner_ = new content::MessageLoopRunner; 37 } 38 39 void BrowsingDataRemoverCompletionInhibitor::ContinueToCompletion() { 40 DCHECK(!continue_to_completion_callback_.is_null()); 41 continue_to_completion_callback_.Run(); 42 continue_to_completion_callback_.Reset(); 43 } 44 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(); 51 } 52