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

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

Issue 8184001: The AutofillProfileSyncableService's lifetime should be managed by the WebDataService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 2 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.cc
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index 80fae6321842d23633af8abdc194a50135b32568..f9c49d6299c44c89e0e142e9d78be163b331619e 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/ui/profile_error_dialog.h"
#include "chrome/browser/webdata/autofill_change.h"
#include "chrome/browser/webdata/autofill_entry.h"
+#include "chrome/browser/webdata/autofill_profile_syncable_service.h"
#include "chrome/browser/webdata/autofill_table.h"
#include "chrome/browser/webdata/keyword_table.h"
#include "chrome/browser/webdata/logins_table.h"
@@ -74,6 +75,7 @@ WDKeywordsResult::~WDKeywordsResult() {}
WebDataService::WebDataService()
: is_running_(false),
db_(NULL),
+ autofill_profile_syncable_service_(NULL),
failed_init_(false),
should_commit_(false),
next_request_handle_(1),
@@ -101,6 +103,7 @@ bool WebDataService::Init(const FilePath& profile_path) {
}
void WebDataService::Shutdown() {
+ ScheduleTask(Bind(&WebDataService::ShutdownSyncableServices, this));
UnloadDatabase();
}
@@ -538,6 +541,7 @@ bool WebDataService::InitWithPath(const FilePath& path) {
path_ = path;
is_running_ = true;
ScheduleTask(Bind(&WebDataService::InitializeDatabaseIfNecessary, this));
+ ScheduleTask(Bind(&WebDataService::InitializeSyncableServices, this));
return true;
}
@@ -628,6 +632,11 @@ void WebDataService::InitializeDatabaseIfNecessary() {
db_->BeginTransaction();
}
+void WebDataService::InitializeSyncableServices() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ autofill_profile_syncable_service_ = new AutofillProfileSyncableService(this);
+}
+
void WebDataService::NotifyDatabaseLoadedOnUIThread() {
// Notify that the database has been initialized.
NotificationService::current()->Notify(
@@ -645,6 +654,14 @@ void WebDataService::ShutdownDatabase() {
}
}
+void WebDataService::ShutdownSyncableServices() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ if (autofill_profile_syncable_service_) {
akalin 2011/10/11 21:24:38 delete NULL works, so no need for if guard
Ilya Sherman 2011/10/11 22:17:34 Done.
+ delete autofill_profile_syncable_service_;
+ autofill_profile_syncable_service_ = NULL;
+ }
+}
+
void WebDataService::Commit() {
if (should_commit_) {
should_commit_ = false;
@@ -1360,6 +1377,11 @@ void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl(
request->RequestComplete();
}
+AutofillProfileSyncableService*
+ WebDataService::GetAutofillProfileSyncableService() const {
+ return autofill_profile_syncable_service_;
akalin 2011/10/11 21:24:38 Will this be called only on the DB thread? If so,
Ilya Sherman 2011/10/11 22:17:34 Done.
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// WebDataRequest implementation.

Powered by Google App Engine
This is Rietveld 408576698