| 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 f635e60c0a67eca042c5f954956c91017967f2b5..e3499c2946a91e0638157f55653357f434727364 100644
|
| --- a/chrome/browser/webdata/autocomplete_syncable_service.cc
|
| +++ b/chrome/browser/webdata/autocomplete_syncable_service.cc
|
| @@ -79,6 +79,13 @@ bool MergeTimestamps(const sync_pb::AutofillSpecifics& autofill,
|
| }
|
| }
|
|
|
| +void* UserDataKey() {
|
| + // Use the address of a static that COMDAT folding won't ever fold
|
| + // with something else.
|
| + static int user_data_key = 0;
|
| + return reinterpret_cast<void*>(&user_data_key);
|
| +}
|
| +
|
| } // namespace
|
|
|
| AutocompleteSyncableService::AutocompleteSyncableService(
|
| @@ -96,6 +103,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) {
|
| @@ -299,8 +320,8 @@ void AutocompleteSyncableService::Observe(int type,
|
|
|
| bool AutocompleteSyncableService::LoadAutofillData(
|
| std::vector<AutofillEntry>* entries) const {
|
| - return web_data_service_->GetDatabase()->
|
| - GetAutofillTable()->GetAllAutofillEntries(entries);
|
| + return AutofillTable::FromWebDatabase(
|
| + web_data_service_->GetDatabase())->GetAllAutofillEntries(entries);
|
| }
|
|
|
| bool AutocompleteSyncableService::SaveChangesToWebData(
|
| @@ -308,8 +329,9 @@ bool AutocompleteSyncableService::SaveChangesToWebData(
|
| DCHECK(CalledOnValidThread());
|
|
|
| if (!new_entries.empty() &&
|
| - !web_data_service_->GetDatabase()->
|
| - GetAutofillTable()->UpdateAutofillEntries(new_entries)) {
|
| + !AutofillTable::FromWebDatabase(
|
| + web_data_service_->GetDatabase())->UpdateAutofillEntries(
|
| + new_entries)) {
|
| return false;
|
| }
|
| return true;
|
| @@ -381,8 +403,9 @@ void AutocompleteSyncableService::WriteAutofillEntry(
|
|
|
| syncer::SyncError AutocompleteSyncableService::AutofillEntryDelete(
|
| const sync_pb::AutofillSpecifics& autofill) {
|
| - if (!web_data_service_->GetDatabase()->GetAutofillTable()->RemoveFormElement(
|
| - UTF8ToUTF16(autofill.name()), UTF8ToUTF16(autofill.value()))) {
|
| + if (!AutofillTable::FromWebDatabase(
|
| + web_data_service_->GetDatabase())->RemoveFormElement(
|
| + UTF8ToUTF16(autofill.name()), UTF8ToUTF16(autofill.value()))) {
|
| return error_handler_->CreateAndUploadError(
|
| FROM_HERE,
|
| "Could not remove autocomplete entry from WebDatabase.");
|
| @@ -400,8 +423,8 @@ void AutocompleteSyncableService::ActOnChanges(
|
| case AutofillChange::ADD:
|
| case AutofillChange::UPDATE: {
|
| std::vector<base::Time> timestamps;
|
| - if (!web_data_service_->GetDatabase()->
|
| - GetAutofillTable()->GetAutofillTimestamps(
|
| + if (!AutofillTable::FromWebDatabase(
|
| + web_data_service_->GetDatabase())->GetAutofillTimestamps(
|
| change->key().name(),
|
| change->key().value(),
|
| ×tamps)) {
|
|
|