| Index: chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
|
| diff --git a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
|
| index 502fabba28f5066d4a0329c2505ef3e7a381d517..e02900e238d0529df61667eef8fc04c6c66dbced 100644
|
| --- a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
|
| +++ b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
|
| @@ -2,6 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/bind.h"
|
| #include "base/callback.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/memory/ref_counted.h"
|
| @@ -61,34 +62,30 @@ class FakeWebDataService : public WebDataService {
|
| return is_database_loaded_;
|
| }
|
|
|
| - virtual AutocompleteSyncableService*
|
| - GetAutocompleteSyncableService() const OVERRIDE {
|
| - return autocomplete_syncable_service_;
|
| - }
|
| -
|
| - void StartSyncableService() {
|
| - // The |autofill_profile_syncable_service_| must be constructed on the DB
|
| + virtual void ShutdownOnUIThread() OVERRIDE {
|
| + // The storage for syncable services must be destructed on the DB
|
| // thread.
|
| base::RunLoop run_loop;
|
| BrowserThread::PostTaskAndReply(BrowserThread::DB, FROM_HERE,
|
| - base::Bind(&FakeWebDataService::CreateSyncableService,
|
| + base::Bind(&FakeWebDataService::ShutdownOnDBThread,
|
| base::Unretained(this)), run_loop.QuitClosure());
|
| run_loop.Run();
|
| }
|
|
|
| - void ShutdownSyncableService() {
|
| - // The |autofill_profile_syncable_service_| must be destructed on the DB
|
| + void StartSyncableService() {
|
| + // The |autofill_profile_syncable_service_| must be constructed on the DB
|
| // thread.
|
| base::RunLoop run_loop;
|
| BrowserThread::PostTaskAndReply(BrowserThread::DB, FROM_HERE,
|
| - base::Bind(&FakeWebDataService::DestroySyncableService,
|
| + base::Bind(&FakeWebDataService::CreateSyncableService,
|
| base::Unretained(this)), run_loop.QuitClosure());
|
| run_loop.Run();
|
| }
|
|
|
| void GetAutofillCullingValue(bool* result) {
|
| ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
| - *result = autocomplete_syncable_service_->cull_expired_entries();
|
| + *result = AutocompleteSyncableService::FromWebDataService(
|
| + this)->cull_expired_entries();
|
| }
|
|
|
| bool CheckAutofillCullingValue() {
|
| @@ -103,25 +100,14 @@ class FakeWebDataService : public WebDataService {
|
|
|
| private:
|
| virtual ~FakeWebDataService() {
|
| - DCHECK(!autocomplete_syncable_service_);
|
| }
|
|
|
| void CreateSyncableService() {
|
| ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
| // These services are deleted in DestroySyncableService().
|
| - autocomplete_syncable_service_ = new AutocompleteSyncableService(this);
|
| - }
|
| -
|
| - void DestroySyncableService() {
|
| - ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
| - delete autocomplete_syncable_service_;
|
| - autocomplete_syncable_service_ = NULL;
|
| + AutocompleteSyncableService::CreateForWebDataService(this);
|
| }
|
|
|
| - // We own the syncable services, but don't use a |scoped_ptr| because the
|
| - // lifetime must be managed on the DB thread.
|
| - AutocompleteSyncableService* autocomplete_syncable_service_;
|
| -
|
| bool is_database_loaded_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(FakeWebDataService);
|
| @@ -139,7 +125,7 @@ class MockWebDataServiceWrapperSyncable : public MockWebDataServiceWrapper {
|
|
|
| void Shutdown() OVERRIDE {
|
| static_cast<FakeWebDataService*>(
|
| - fake_web_data_service_.get())->ShutdownSyncableService();
|
| + fake_web_data_service_.get())->ShutdownOnUIThread();
|
| }
|
|
|
| private:
|
|
|