Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Unified Diff: chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc

Issue 12695015: Split Autofill webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 f922938875318ec466e28faafb89c9a76d8e9eab..fee66d8b860377be49046bfd80b322998933401a 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"
@@ -40,7 +41,8 @@ using testing::Return;
// loading.
class FakeWebDataService : public WebDataService {
public:
- FakeWebDataService() : is_database_loaded_(false) {}
+ FakeWebDataService()
+ : is_database_loaded_(false) {}
// Mark the database as loaded and send out the appropriate
// notification.
@@ -59,34 +61,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() {
@@ -101,25 +99,15 @@ class FakeWebDataService : public WebDataService {
private:
virtual ~FakeWebDataService() {
- DCHECK(!autocomplete_syncable_service_);
+ DCHECK(!AutocompleteSyncableService::FromWebDataService(this));
}
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);
@@ -136,7 +124,7 @@ class MockWebDataServiceWrapper : public WebDataServiceWrapper {
}
void Shutdown() OVERRIDE {
- fake_web_data_service_->ShutdownSyncableService();
+ fake_web_data_service_->ShutdownOnUIThread();
}
scoped_refptr<WebDataService> GetWebData() OVERRIDE {

Powered by Google App Engine
This is Rietveld 408576698