| OLD | NEW |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 WebDataServiceWrapper::WebDataServiceWrapper() {} | 66 WebDataServiceWrapper::WebDataServiceWrapper() {} |
| 67 | 67 |
| 68 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { | 68 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { |
| 69 base::FilePath profile_path = profile->GetPath(); | 69 base::FilePath profile_path = profile->GetPath(); |
| 70 base::FilePath path = profile_path.Append(kWebDataFilename); | 70 base::FilePath path = profile_path.Append(kWebDataFilename); |
| 71 | 71 |
| 72 web_database_ = new WebDatabaseService(path, | 72 scoped_refptr<base::MessageLoopProxy> ui_thread = |
| 73 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 73 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| 74 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); | 74 scoped_refptr<base::MessageLoopProxy> db_thread = |
| 75 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB); |
| 76 web_database_ = new WebDatabaseService(path, ui_thread, db_thread); |
| 75 | 77 |
| 76 // All tables objects that participate in managing the database must | 78 // All tables objects that participate in managing the database must |
| 77 // be added here. | 79 // be added here. |
| 78 web_database_->AddTable( | 80 web_database_->AddTable( |
| 79 scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( | 81 scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( |
| 80 g_browser_process->GetApplicationLocale()))); | 82 g_browser_process->GetApplicationLocale()))); |
| 81 web_database_->AddTable( | 83 web_database_->AddTable( |
| 82 scoped_ptr<WebDatabaseTable>(new KeywordTable())); | 84 scoped_ptr<WebDatabaseTable>(new KeywordTable())); |
| 83 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password | 85 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password |
| 84 // access, but for now, we still create it on all platforms since it deletes | 86 // access, but for now, we still create it on all platforms since it deletes |
| 85 // the old logins table. We can remove this after a while, e.g. in M22 or so. | 87 // the old logins table. We can remove this after a while, e.g. in M22 or so. |
| 86 web_database_->AddTable( | 88 web_database_->AddTable( |
| 87 scoped_ptr<WebDatabaseTable>(new LoginsTable())); | 89 scoped_ptr<WebDatabaseTable>(new LoginsTable())); |
| 88 web_database_->AddTable( | 90 web_database_->AddTable( |
| 89 scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); | 91 scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); |
| 90 web_database_->AddTable( | 92 web_database_->AddTable( |
| 91 scoped_ptr<WebDatabaseTable>(new WebAppsTable())); | 93 scoped_ptr<WebDatabaseTable>(new WebAppsTable())); |
| 92 // TODO(thakis): Add a migration to delete the SQL table used by | 94 // TODO(thakis): Add a migration to delete the SQL table used by |
| 93 // WebIntentsTable, then remove this. | 95 // WebIntentsTable, then remove this. |
| 94 web_database_->AddTable( | 96 web_database_->AddTable( |
| 95 scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); | 97 scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); |
| 96 | 98 |
| 97 web_database_->LoadDatabase(); | 99 web_database_->LoadDatabase(); |
| 98 | 100 |
| 99 autofill_web_data_ = new AutofillWebDataService( | 101 autofill_web_data_ = new AutofillWebDataService( |
| 100 web_database_, base::Bind(&ProfileErrorCallback)); | 102 web_database_, ui_thread, db_thread, base::Bind(&ProfileErrorCallback)); |
| 101 autofill_web_data_->Init(); | 103 autofill_web_data_->Init(); |
| 102 | 104 |
| 103 token_web_data_ = new TokenWebData( | 105 token_web_data_ = new TokenWebData( |
| 104 web_database_, base::Bind(&ProfileErrorCallback)); | 106 web_database_, base::Bind(&ProfileErrorCallback)); |
| 105 token_web_data_->Init(); | 107 token_web_data_->Init(); |
| 106 | 108 |
| 107 web_data_ = new WebDataService( | 109 web_data_ = new WebDataService( |
| 108 web_database_, base::Bind(&ProfileErrorCallback)); | 110 web_database_, base::Bind(&ProfileErrorCallback)); |
| 109 web_data_->Init(); | 111 web_data_->Init(); |
| 110 | 112 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 227 } |
| 226 | 228 |
| 227 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( | 229 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( |
| 228 content::BrowserContext* profile) const { | 230 content::BrowserContext* profile) const { |
| 229 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); | 231 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); |
| 230 } | 232 } |
| 231 | 233 |
| 232 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { | 234 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { |
| 233 return true; | 235 return true; |
| 234 } | 236 } |
| OLD | NEW |