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

Unified Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 12494020: Remove knowledge of Chrome-specific SyncableService classes from WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECK. 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/webdata/web_data_service_factory.cc
diff --git a/chrome/browser/webdata/web_data_service_factory.cc b/chrome/browser/webdata/web_data_service_factory.cc
index 80be749151d61eaa050474e9cb91420248b72fa0..56e7dbae3040ae2c3085396a1aeb84be6a184544 100644
--- a/chrome/browser/webdata/web_data_service_factory.cc
+++ b/chrome/browser/webdata/web_data_service_factory.cc
@@ -8,11 +8,16 @@
#include "base/files/file_path.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/ui/profile_error_dialog.h"
+#include "chrome/browser/webdata/autocomplete_syncable_service.h"
+#include "chrome/browser/webdata/autofill_profile_syncable_service.h"
#include "chrome/browser/webdata/autofill_web_data_service_impl.h"
#include "chrome/common/chrome_constants.h"
+#include "content/public/browser/browser_thread.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
+using content::BrowserThread;
+
namespace {
// Callback to show error dialog on profile load error.
@@ -22,13 +27,26 @@ void ProfileErrorCallback(sql::InitStatus status) {
IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR);
}
+void InitSyncableServicesOnDBThread(scoped_refptr<WebDataService> web_data) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+
+ // Currently only Autocomplete and Autofill profiles use the new Sync API, but
+ // all the database data should migrate to this API over time.
+ AutocompleteSyncableService::CreateForWebDataService(web_data);
+ AutofillProfileSyncableService::CreateForWebDataService(web_data);
+}
+
} // namespace
-WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile){
+WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
base::FilePath path = profile->GetPath();
path = path.Append(chrome::kWebDataFilename);
web_data_service_ = new WebDataService(base::Bind(&ProfileErrorCallback));
web_data_service_->Init(path);
+
+ BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
+ base::Bind(&InitSyncableServicesOnDBThread,
+ web_data_service_));
}
// For testing.
@@ -48,8 +66,8 @@ scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
}
// static
-scoped_refptr<AutofillWebDataService> AutofillWebDataService::FromBrowserContext(
- content::BrowserContext* context) {
+scoped_refptr<AutofillWebDataService>
+AutofillWebDataService::FromBrowserContext(content::BrowserContext* context) {
// For this service, the implicit/explicit distinction doesn't
// really matter; it's just used for a DCHECK. So we currently
// cheat and always say EXPLICIT_ACCESS.

Powered by Google App Engine
This is Rietveld 408576698