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

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

Issue 12494020: Remove knowledge of Chrome-specific SyncableService classes from WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix a unit test bug, use safer keys for SupportsUserData. 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 502fabba28f5066d4a0329c2505ef3e7a381d517..6e868cbfbf329e85e5f9b84d5a0abdf21db1f108 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,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);
@@ -139,7 +126,7 @@ class MockWebDataServiceWrapperSyncable : public MockWebDataServiceWrapper {
void Shutdown() OVERRIDE {
static_cast<FakeWebDataService*>(
- fake_web_data_service_.get())->ShutdownSyncableService();
+ fake_web_data_service_.get())->ShutdownOnUIThread();
}
private:

Powered by Google App Engine
This is Rietveld 408576698