Chromium Code Reviews| Index: chrome/browser/profiles/profile_manager_browsertest.cc |
| diff --git a/chrome/browser/profiles/profile_manager_browsertest.cc b/chrome/browser/profiles/profile_manager_browsertest.cc |
| index 2d2fea24f8035d024cb4c3c2c5bf61401f366f59..516978a461e0580eeb83e06523bf812c600072b7 100644 |
| --- a/chrome/browser/profiles/profile_manager_browsertest.cc |
| +++ b/chrome/browser/profiles/profile_manager_browsertest.cc |
| @@ -3,15 +3,19 @@ |
| // found in the LICENSE file. |
| #include <stddef.h> |
| +#include <list> |
| #include "base/bind.h" |
| +#include "base/callback.h" |
| #include "base/command_line.h" |
| #include "base/macros.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/stl_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "build/build_config.h" |
| -#include "chrome/browser/browsing_data/browsing_data_remover_impl.h" |
| +#include "chrome/browser/browsing_data/browsing_data_remover.h" |
| +#include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| +#include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| #include "chrome/browser/lifetime/keep_alive_types.h" |
| #include "chrome/browser/lifetime/scoped_keep_alive.h" |
| #include "chrome/browser/password_manager/password_store_factory.h" |
| @@ -68,23 +72,31 @@ void ProfileCreationComplete(Profile* profile, Profile::CreateStatus status) { |
| // deleted. It also create ScopedKeepAlive object to prevent browser shutdown |
| // started in case browser has become windowless. |
| class MultipleProfileDeletionObserver |
| - : public BrowsingDataRemoverImpl::CompletionInhibitor, |
| - public ProfileAttributesStorage::Observer { |
| + : public ProfileAttributesStorage::Observer { |
| public: |
| explicit MultipleProfileDeletionObserver(size_t expected_count) |
| : expected_count_(expected_count), |
| profiles_created_count_(0), |
| profiles_data_removed_count_(0) { |
| EXPECT_GT(expected_count_, 0u); |
| - g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| - AddObserver(this); |
| - BrowsingDataRemoverImpl::set_completion_inhibitor_for_testing(this); |
| + ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| + profile_manager->GetProfileAttributesStorage().AddObserver(this); |
| + |
| + for (Profile* profile : profile_manager->GetLoadedProfiles()) { |
|
msramek
2017/04/10 13:20:08
I rewrote this test to use BrowsingDataRemoverComp
|
| + inhibitors_.emplace_back( |
| + BrowsingDataRemoverFactory::GetForBrowserContext(profile), |
| + base::Bind(&MultipleProfileDeletionObserver:: |
|
Bernhard Bauer
2017/04/10 23:29:37
Hm, this callback is always identical, right? Coul
msramek
2017/04/11 13:13:03
Done.
Yes, that's a good idea. I partially revert
|
| + HandleBrowsingDataRemoverWouldComplete, |
| + base::Unretained(this))); |
| + } |
| } |
| + |
| ~MultipleProfileDeletionObserver() override { |
| g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| RemoveObserver(this); |
| - BrowsingDataRemoverImpl::set_completion_inhibitor_for_testing(nullptr); |
| + inhibitors_.clear(); |
| } |
| + |
| void Wait() { |
| keep_alive_ = base::MakeUnique<ScopedKeepAlive>( |
| KeepAliveOrigin::PROFILE_HELPER, KeepAliveRestartOption::DISABLED); |
| @@ -92,17 +104,36 @@ class MultipleProfileDeletionObserver |
| } |
| private: |
| - void OnProfileWillBeRemoved(const base::FilePath& profile_path) override { |
| - profiles_created_count_++; |
| + // TODO(https://crbug.com/704601): remove this code when bug is fixed. |
| + class CompletionInhibitor : public BrowsingDataRemoverCompletionInhibitor { |
| + public: |
| + CompletionInhibitor(BrowsingDataRemover* remover, |
| + const base::Closure& callback) |
| + : BrowsingDataRemoverCompletionInhibitor(remover), |
| + callback_(callback) {} |
| + ~CompletionInhibitor() override {} |
| + |
| + // BrowsingDataRemoverCompletionInhibitor: |
| + void OnBrowsingDataRemoverWouldComplete( |
| + const base::Closure& continue_to_completion) override { |
| + BrowsingDataRemoverCompletionInhibitor:: |
| + OnBrowsingDataRemoverWouldComplete(continue_to_completion); |
| + callback_.Run(); |
| + } |
| + |
| + private: |
| + base::Closure callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CompletionInhibitor); |
| + }; |
| + |
| + void HandleBrowsingDataRemoverWouldComplete() { |
| + profiles_data_removed_count_++; |
| MaybeQuit(); |
| } |
| - // TODO(https://crbug.com/704601): remove this code when bug is fixed. |
| - void OnBrowsingDataRemoverWouldComplete( |
| - BrowsingDataRemoverImpl* remover, |
| - const base::Closure& continue_to_completion) override { |
| - continue_to_completion.Run(); |
| - profiles_data_removed_count_++; |
| + void OnProfileWillBeRemoved(const base::FilePath& profile_path) override { |
| + profiles_created_count_++; |
| MaybeQuit(); |
| } |
| @@ -123,6 +154,8 @@ class MultipleProfileDeletionObserver |
| loop_.Quit(); |
| } |
| + std::list<CompletionInhibitor> inhibitors_; |
| + |
| base::RunLoop loop_; |
| std::unique_ptr<ScopedKeepAlive> keep_alive_; |
| size_t expected_count_; |