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)); |