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

Unified Diff: chrome/browser/webdata/autocomplete_syncable_service.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/webdata/autocomplete_syncable_service.cc
diff --git a/chrome/browser/webdata/autocomplete_syncable_service.cc b/chrome/browser/webdata/autocomplete_syncable_service.cc
index f039075cf83f2cfd69efb5373f1a1c92794ad1c5..ee607273172e9be067fcf18c65c2b061b9ac03dd 100644
--- a/chrome/browser/webdata/autocomplete_syncable_service.cc
+++ b/chrome/browser/webdata/autocomplete_syncable_service.cc
@@ -79,6 +79,15 @@ bool MergeTimestamps(const sync_pb::AutofillSpecifics& autofill,
}
}
+// See |UserDataKey| below.
+int user_data_key = 0;
dhollowa 2013/03/20 21:47:37 nit: this could be pulled into the body of UserDat
Jói 2013/03/20 22:03:16 Done. I've also added it to my TODO list to update
+
+void* UserDataKey() {
+ // Use the address of a static that COMDAT folding won't ever fold
+ // with something else.
+ return reinterpret_cast<void*>(&user_data_key);
+}
+
} // namespace
AutocompleteSyncableService::AutocompleteSyncableService(
@@ -96,6 +105,20 @@ AutocompleteSyncableService::~AutocompleteSyncableService() {
DCHECK(CalledOnValidThread());
}
+// static
+void AutocompleteSyncableService::CreateForWebDataService(
+ WebDataService* web_data) {
+ web_data->GetDBUserData()->SetUserData(
+ UserDataKey(), new AutocompleteSyncableService(web_data));
+}
+
+// static
+AutocompleteSyncableService* AutocompleteSyncableService::FromWebDataService(
+ WebDataService* web_data) {
+ return static_cast<AutocompleteSyncableService*>(
+ web_data->GetDBUserData()->GetUserData(UserDataKey()));
+}
+
AutocompleteSyncableService::AutocompleteSyncableService()
: web_data_service_(NULL),
cull_expired_entries_(false) {

Powered by Google App Engine
This is Rietveld 408576698