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

Unified Diff: chrome/browser/webdata/autofill_profile_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: 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/autofill_profile_syncable_service.cc
diff --git a/chrome/browser/webdata/autofill_profile_syncable_service.cc b/chrome/browser/webdata/autofill_profile_syncable_service.cc
index 980ca80777024864aac2a495c4c06dd88a39bff7..ab89e213140a66b84bfef0f454012b7a1c46279a 100644
--- a/chrome/browser/webdata/autofill_profile_syncable_service.cc
+++ b/chrome/browser/webdata/autofill_profile_syncable_service.cc
@@ -33,6 +33,27 @@ std::string LimitData(const std::string& data) {
return sanitized_value;
}
+class DataObject : public base::SupportsUserData::Data {
+ public:
+ explicit DataObject(scoped_ptr<AutofillProfileSyncableService> service)
+ : service_(service.Pass()) {
+ }
+
+ AutofillProfileSyncableService* service() {
+ return service_.get();
+ }
+
+ private:
+ scoped_ptr<AutofillProfileSyncableService> service_;
+
+ DISALLOW_COPY_AND_ASSIGN(DataObject);
+};
+
+void* DataKey() {
+ return reinterpret_cast<void*>(
+ &AutofillProfileSyncableService::AttachToWebData);
+}
+
} // namespace
const char kAutofillProfileTag[] = "google_chrome_autofill_profiles";
@@ -52,6 +73,21 @@ AutofillProfileSyncableService::~AutofillProfileSyncableService() {
DCHECK(CalledOnValidThread());
}
+// static
+AutofillProfileSyncableService* AutofillProfileSyncableService::FromWebData(
+ WebDataServiceBase* service) {
+ return static_cast<DataObject*>(
+ service->GetDBUserData()->GetUserData(DataKey()))->service();
+}
+
+// static
+void AutofillProfileSyncableService::AttachToWebData(
+ scoped_ptr<AutofillProfileSyncableService> service,
+ WebDataServiceBase* web_data) {
+ web_data->GetDBUserData()->SetUserData(DataKey(),
+ new DataObject(service.Pass()));
+}
+
AutofillProfileSyncableService::AutofillProfileSyncableService()
: web_data_service_(NULL) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));

Powered by Google App Engine
This is Rietveld 408576698