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

Side by Side Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 14081043: Hook up Autofill Backend interface to SyncableServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webdata/web_data_service_factory.h" 5 #include "chrome/browser/webdata/web_data_service_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/incognito_helpers.h"
(...skipping 24 matching lines...) Expand all
35 // Callback to show error dialog on profile load error. 35 // Callback to show error dialog on profile load error.
36 void ProfileErrorCallback(sql::InitStatus status) { 36 void ProfileErrorCallback(sql::InitStatus status) {
37 ShowProfileErrorDialog( 37 ShowProfileErrorDialog(
38 (status == sql::INIT_FAILURE) ? 38 (status == sql::INIT_FAILURE) ?
39 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); 39 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR);
40 } 40 }
41 41
42 void InitSyncableServicesOnDBThread( 42 void InitSyncableServicesOnDBThread(
43 scoped_refptr<AutofillWebDataService> autofill_web_data, 43 scoped_refptr<AutofillWebDataService> autofill_web_data,
44 const base::FilePath& profile_path, 44 const base::FilePath& profile_path,
45 const std::string& app_locale) { 45 const std::string& app_locale,
46 autofill::AutofillWebDataBackend* autofill_backend) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
47 48
48 // Currently only Autocomplete and Autofill profiles use the new Sync API, but 49 // Currently only Autocomplete and Autofill profiles use the new Sync API, but
49 // all the database data should migrate to this API over time. 50 // all the database data should migrate to this API over time.
50 AutocompleteSyncableService::CreateForWebDataService(autofill_web_data); 51 AutocompleteSyncableService::CreateForWebDataServiceAndBackend(
52 autofill_web_data, autofill_backend);
51 AutocompleteSyncableService::FromWebDataService( 53 AutocompleteSyncableService::FromWebDataService(
52 autofill_web_data)->InjectStartSyncFlare( 54 autofill_web_data)->InjectStartSyncFlare(
53 sync_start_util::GetFlareForSyncableService(profile_path)); 55 sync_start_util::GetFlareForSyncableService(profile_path));
54 AutofillProfileSyncableService::CreateForWebDataService( 56 AutofillProfileSyncableService::CreateForWebDataServiceAndBackend(
55 autofill_web_data, app_locale); 57 autofill_web_data, autofill_backend, app_locale);
56 AutofillProfileSyncableService::FromWebDataService( 58 AutofillProfileSyncableService::FromWebDataService(
57 autofill_web_data)->InjectStartSyncFlare( 59 autofill_web_data)->InjectStartSyncFlare(
58 sync_start_util::GetFlareForSyncableService(profile_path)); 60 sync_start_util::GetFlareForSyncableService(profile_path));
59 } 61 }
60 62
61 } // namespace 63 } // namespace
62 64
63 WebDataServiceWrapper::WebDataServiceWrapper() {} 65 WebDataServiceWrapper::WebDataServiceWrapper() {}
64 66
65 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { 67 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
(...skipping 26 matching lines...) Expand all
92 web_database_->LoadDatabase(); 94 web_database_->LoadDatabase();
93 95
94 autofill_web_data_ = new AutofillWebDataService( 96 autofill_web_data_ = new AutofillWebDataService(
95 web_database_, base::Bind(&ProfileErrorCallback)); 97 web_database_, base::Bind(&ProfileErrorCallback));
96 autofill_web_data_->Init(); 98 autofill_web_data_->Init();
97 99
98 web_data_ = new WebDataService( 100 web_data_ = new WebDataService(
99 web_database_, base::Bind(&ProfileErrorCallback)); 101 web_database_, base::Bind(&ProfileErrorCallback));
100 web_data_->Init(); 102 web_data_->Init();
101 103
102 BrowserThread::PostTask( 104 autofill_web_data_->GetAutofillBackend(
103 BrowserThread::DB, FROM_HERE, 105 base::Bind(&InitSyncableServicesOnDBThread,
104 base::Bind(&InitSyncableServicesOnDBThread, 106 autofill_web_data_,
105 autofill_web_data_, 107 profile_path,
106 profile_path, 108 g_browser_process->GetApplicationLocale()));
107 g_browser_process->GetApplicationLocale()));
108 } 109 }
109 110
110 WebDataServiceWrapper::~WebDataServiceWrapper() { 111 WebDataServiceWrapper::~WebDataServiceWrapper() {
111 } 112 }
112 113
113 void WebDataServiceWrapper::Shutdown() { 114 void WebDataServiceWrapper::Shutdown() {
114 autofill_web_data_->ShutdownOnUIThread(); 115 autofill_web_data_->ShutdownOnUIThread();
115 web_data_->ShutdownOnUIThread(); 116 web_data_->ShutdownOnUIThread();
116 web_database_->ShutdownDatabase(); 117 web_database_->ShutdownDatabase();
117 } 118 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 198 }
198 199
199 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( 200 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor(
200 content::BrowserContext* profile) const { 201 content::BrowserContext* profile) const {
201 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 202 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
202 } 203 }
203 204
204 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 205 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
205 return true; 206 return true;
206 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_profile_syncable_service.cc ('k') | components/autofill/browser/webdata/autofill_webdata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698