OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/webdata/autocomplete_syncable_service.h" | 5 #include "chrome/browser/webdata/autocomplete_syncable_service.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 AutocompleteSyncableService::~AutocompleteSyncableService() { | 101 AutocompleteSyncableService::~AutocompleteSyncableService() { |
102 DCHECK(CalledOnValidThread()); | 102 DCHECK(CalledOnValidThread()); |
103 } | 103 } |
104 | 104 |
105 AutocompleteSyncableService::AutocompleteSyncableService() | 105 AutocompleteSyncableService::AutocompleteSyncableService() |
106 : web_data_service_(NULL) { | 106 : web_data_service_(NULL) { |
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
108 } | 108 } |
109 | 109 |
110 SyncError AutocompleteSyncableService::MergeDataAndStartSyncing( | 110 csync::SyncError AutocompleteSyncableService::MergeDataAndStartSyncing( |
111 syncable::ModelType type, | 111 syncable::ModelType type, |
112 const SyncDataList& initial_sync_data, | 112 const csync::SyncDataList& initial_sync_data, |
113 scoped_ptr<SyncChangeProcessor> sync_processor, | 113 scoped_ptr<csync::SyncChangeProcessor> sync_processor, |
114 scoped_ptr<SyncErrorFactory> error_handler) { | 114 scoped_ptr<csync::SyncErrorFactory> error_handler) { |
115 DCHECK(CalledOnValidThread()); | 115 DCHECK(CalledOnValidThread()); |
116 DCHECK(!sync_processor_.get()); | 116 DCHECK(!sync_processor_.get()); |
117 DCHECK(sync_processor.get()); | 117 DCHECK(sync_processor.get()); |
118 DCHECK(error_handler.get()); | 118 DCHECK(error_handler.get()); |
119 VLOG(1) << "Associating Autocomplete: MergeDataAndStartSyncing"; | 119 VLOG(1) << "Associating Autocomplete: MergeDataAndStartSyncing"; |
120 | 120 |
121 error_handler_ = error_handler.Pass(); | 121 error_handler_ = error_handler.Pass(); |
122 std::vector<AutofillEntry> entries; | 122 std::vector<AutofillEntry> entries; |
123 if (!LoadAutofillData(&entries)) { | 123 if (!LoadAutofillData(&entries)) { |
124 return error_handler_->CreateAndUploadError( | 124 return error_handler_->CreateAndUploadError( |
125 FROM_HERE, | 125 FROM_HERE, |
126 "Could not get the autocomplete data from WebDatabase."); | 126 "Could not get the autocomplete data from WebDatabase."); |
127 } | 127 } |
128 | 128 |
129 AutocompleteEntryMap new_db_entries; | 129 AutocompleteEntryMap new_db_entries; |
130 for (std::vector<AutofillEntry>::iterator it = entries.begin(); | 130 for (std::vector<AutofillEntry>::iterator it = entries.begin(); |
131 it != entries.end(); ++it) { | 131 it != entries.end(); ++it) { |
132 new_db_entries[it->key()] = std::make_pair(SyncChange::ACTION_ADD, it); | 132 new_db_entries[it->key()] = |
| 133 std::make_pair(csync::SyncChange::ACTION_ADD, it); |
133 } | 134 } |
134 | 135 |
135 sync_processor_ = sync_processor.Pass(); | 136 sync_processor_ = sync_processor.Pass(); |
136 | 137 |
137 std::vector<AutofillEntry> new_synced_entries; | 138 std::vector<AutofillEntry> new_synced_entries; |
138 // Go through and check for all the entries that sync already knows about. | 139 // Go through and check for all the entries that sync already knows about. |
139 // CreateOrUpdateEntry() will remove entries that are same with the synced | 140 // CreateOrUpdateEntry() will remove entries that are same with the synced |
140 // ones from |new_db_entries|. | 141 // ones from |new_db_entries|. |
141 for (SyncDataList::const_iterator sync_iter = initial_sync_data.begin(); | 142 for (csync::SyncDataList::const_iterator sync_iter = |
| 143 initial_sync_data.begin(); |
142 sync_iter != initial_sync_data.end(); ++sync_iter) { | 144 sync_iter != initial_sync_data.end(); ++sync_iter) { |
143 CreateOrUpdateEntry(*sync_iter, &new_db_entries, &new_synced_entries); | 145 CreateOrUpdateEntry(*sync_iter, &new_db_entries, &new_synced_entries); |
144 } | 146 } |
145 | 147 |
146 if (!SaveChangesToWebData(new_synced_entries)) { | 148 if (!SaveChangesToWebData(new_synced_entries)) { |
147 return error_handler_->CreateAndUploadError( | 149 return error_handler_->CreateAndUploadError( |
148 FROM_HERE, | 150 FROM_HERE, |
149 "Failed to update webdata."); | 151 "Failed to update webdata."); |
150 } | 152 } |
151 | 153 |
152 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_); | 154 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_); |
153 | 155 |
154 SyncChangeList new_changes; | 156 csync::SyncChangeList new_changes; |
155 for (AutocompleteEntryMap::iterator i = new_db_entries.begin(); | 157 for (AutocompleteEntryMap::iterator i = new_db_entries.begin(); |
156 i != new_db_entries.end(); ++i) { | 158 i != new_db_entries.end(); ++i) { |
157 new_changes.push_back( | 159 new_changes.push_back( |
158 SyncChange(i->second.first, CreateSyncData(*(i->second.second)))); | 160 csync::SyncChange( |
| 161 i->second.first, CreateSyncData(*(i->second.second)))); |
159 } | 162 } |
160 | 163 |
161 if (ShouldCullSyncedData()) { | 164 if (ShouldCullSyncedData()) { |
162 // This will schedule a deletion operation on the DB thread, which will | 165 // This will schedule a deletion operation on the DB thread, which will |
163 // trigger a notification to propagate the deletion to Sync. | 166 // trigger a notification to propagate the deletion to Sync. |
164 web_data_service_->RemoveExpiredFormElements(); | 167 web_data_service_->RemoveExpiredFormElements(); |
165 } | 168 } |
166 | 169 |
167 SyncError error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); | 170 csync::SyncError error = |
| 171 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); |
168 | 172 |
169 return error; | 173 return error; |
170 } | 174 } |
171 | 175 |
172 void AutocompleteSyncableService::StopSyncing(syncable::ModelType type) { | 176 void AutocompleteSyncableService::StopSyncing(syncable::ModelType type) { |
173 DCHECK(CalledOnValidThread()); | 177 DCHECK(CalledOnValidThread()); |
174 DCHECK_EQ(syncable::AUTOFILL, type); | 178 DCHECK_EQ(syncable::AUTOFILL, type); |
175 | 179 |
176 sync_processor_.reset(NULL); | 180 sync_processor_.reset(NULL); |
177 error_handler_.reset(); | 181 error_handler_.reset(); |
178 } | 182 } |
179 | 183 |
180 SyncDataList AutocompleteSyncableService::GetAllSyncData( | 184 csync::SyncDataList AutocompleteSyncableService::GetAllSyncData( |
181 syncable::ModelType type) const { | 185 syncable::ModelType type) const { |
182 DCHECK(CalledOnValidThread()); | 186 DCHECK(CalledOnValidThread()); |
183 DCHECK(sync_processor_.get()); | 187 DCHECK(sync_processor_.get()); |
184 DCHECK_EQ(type, syncable::AUTOFILL); | 188 DCHECK_EQ(type, syncable::AUTOFILL); |
185 | 189 |
186 SyncDataList current_data; | 190 csync::SyncDataList current_data; |
187 | 191 |
188 std::vector<AutofillEntry> entries; | 192 std::vector<AutofillEntry> entries; |
189 if (!LoadAutofillData(&entries)) | 193 if (!LoadAutofillData(&entries)) |
190 return current_data; | 194 return current_data; |
191 | 195 |
192 for (std::vector<AutofillEntry>::iterator it = entries.begin(); | 196 for (std::vector<AutofillEntry>::iterator it = entries.begin(); |
193 it != entries.end(); ++it) { | 197 it != entries.end(); ++it) { |
194 current_data.push_back(CreateSyncData(*it)); | 198 current_data.push_back(CreateSyncData(*it)); |
195 } | 199 } |
196 | 200 |
197 return current_data; | 201 return current_data; |
198 } | 202 } |
199 | 203 |
200 SyncError AutocompleteSyncableService::ProcessSyncChanges( | 204 csync::SyncError AutocompleteSyncableService::ProcessSyncChanges( |
201 const tracked_objects::Location& from_here, | 205 const tracked_objects::Location& from_here, |
202 const SyncChangeList& change_list) { | 206 const csync::SyncChangeList& change_list) { |
203 DCHECK(CalledOnValidThread()); | 207 DCHECK(CalledOnValidThread()); |
204 DCHECK(sync_processor_.get()); | 208 DCHECK(sync_processor_.get()); |
205 | 209 |
206 if (!sync_processor_.get()) { | 210 if (!sync_processor_.get()) { |
207 SyncError error(FROM_HERE, "Models not yet associated.", | 211 csync::SyncError error(FROM_HERE, "Models not yet associated.", |
208 syncable::AUTOFILL); | 212 syncable::AUTOFILL); |
209 return error; | 213 return error; |
210 } | 214 } |
211 | 215 |
212 // Data is loaded only if we get new ADD/UPDATE change. | 216 // Data is loaded only if we get new ADD/UPDATE change. |
213 std::vector<AutofillEntry> entries; | 217 std::vector<AutofillEntry> entries; |
214 scoped_ptr<AutocompleteEntryMap> db_entries; | 218 scoped_ptr<AutocompleteEntryMap> db_entries; |
215 std::vector<AutofillEntry> new_entries; | 219 std::vector<AutofillEntry> new_entries; |
216 | 220 |
217 SyncError list_processing_error; | 221 csync::SyncError list_processing_error; |
218 | 222 |
219 for (SyncChangeList::const_iterator i = change_list.begin(); | 223 for (csync::SyncChangeList::const_iterator i = change_list.begin(); |
220 i != change_list.end() && !list_processing_error.IsSet(); ++i) { | 224 i != change_list.end() && !list_processing_error.IsSet(); ++i) { |
221 DCHECK(i->IsValid()); | 225 DCHECK(i->IsValid()); |
222 switch (i->change_type()) { | 226 switch (i->change_type()) { |
223 case SyncChange::ACTION_ADD: | 227 case csync::SyncChange::ACTION_ADD: |
224 case SyncChange::ACTION_UPDATE: | 228 case csync::SyncChange::ACTION_UPDATE: |
225 if (!db_entries.get()) { | 229 if (!db_entries.get()) { |
226 if (!LoadAutofillData(&entries)) { | 230 if (!LoadAutofillData(&entries)) { |
227 return error_handler_->CreateAndUploadError( | 231 return error_handler_->CreateAndUploadError( |
228 FROM_HERE, | 232 FROM_HERE, |
229 "Could not get the autocomplete data from WebDatabase."); | 233 "Could not get the autocomplete data from WebDatabase."); |
230 } | 234 } |
231 db_entries.reset(new AutocompleteEntryMap); | 235 db_entries.reset(new AutocompleteEntryMap); |
232 for (std::vector<AutofillEntry>::iterator it = entries.begin(); | 236 for (std::vector<AutofillEntry>::iterator it = entries.begin(); |
233 it != entries.end(); ++it) { | 237 it != entries.end(); ++it) { |
234 (*db_entries)[it->key()] = | 238 (*db_entries)[it->key()] = |
235 std::make_pair(SyncChange::ACTION_ADD, it); | 239 std::make_pair(csync::SyncChange::ACTION_ADD, it); |
236 } | 240 } |
237 } | 241 } |
238 CreateOrUpdateEntry(i->sync_data(), db_entries.get(), &new_entries); | 242 CreateOrUpdateEntry(i->sync_data(), db_entries.get(), &new_entries); |
239 break; | 243 break; |
240 case SyncChange::ACTION_DELETE: { | 244 case csync::SyncChange::ACTION_DELETE: { |
241 DCHECK(i->sync_data().GetSpecifics().has_autofill()) | 245 DCHECK(i->sync_data().GetSpecifics().has_autofill()) |
242 << "Autofill specifics data not present on delete!"; | 246 << "Autofill specifics data not present on delete!"; |
243 const sync_pb::AutofillSpecifics& autofill = | 247 const sync_pb::AutofillSpecifics& autofill = |
244 i->sync_data().GetSpecifics().autofill(); | 248 i->sync_data().GetSpecifics().autofill(); |
245 if (autofill.has_value()) { | 249 if (autofill.has_value()) { |
246 list_processing_error = AutofillEntryDelete(autofill); | 250 list_processing_error = AutofillEntryDelete(autofill); |
247 } else { | 251 } else { |
248 DLOG(WARNING) | 252 DLOG(WARNING) |
249 << "Delete for old-style autofill profile being dropped!"; | 253 << "Delete for old-style autofill profile being dropped!"; |
250 } | 254 } |
251 } break; | 255 } break; |
252 default: | 256 default: |
253 NOTREACHED() << "Unexpected sync change state."; | 257 NOTREACHED() << "Unexpected sync change state."; |
254 return error_handler_->CreateAndUploadError( | 258 return error_handler_->CreateAndUploadError( |
255 FROM_HERE, | 259 FROM_HERE, |
256 "ProcessSyncChanges failed on ChangeType " + | 260 "ProcessSyncChanges failed on ChangeType " + |
257 SyncChange::ChangeTypeToString(i->change_type())); | 261 csync::SyncChange::ChangeTypeToString(i->change_type())); |
258 } | 262 } |
259 } | 263 } |
260 | 264 |
261 if (!SaveChangesToWebData(new_entries)) { | 265 if (!SaveChangesToWebData(new_entries)) { |
262 return error_handler_->CreateAndUploadError( | 266 return error_handler_->CreateAndUploadError( |
263 FROM_HERE, | 267 FROM_HERE, |
264 "Failed to update webdata."); | 268 "Failed to update webdata."); |
265 } | 269 } |
266 | 270 |
267 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_); | 271 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 if (!new_entries.empty() && | 312 if (!new_entries.empty() && |
309 !web_data_service_->GetDatabase()-> | 313 !web_data_service_->GetDatabase()-> |
310 GetAutofillTable()->UpdateAutofillEntries(new_entries)) { | 314 GetAutofillTable()->UpdateAutofillEntries(new_entries)) { |
311 return false; | 315 return false; |
312 } | 316 } |
313 return true; | 317 return true; |
314 } | 318 } |
315 | 319 |
316 // Creates or updates an autocomplete entry based on |data|. | 320 // Creates or updates an autocomplete entry based on |data|. |
317 void AutocompleteSyncableService::CreateOrUpdateEntry( | 321 void AutocompleteSyncableService::CreateOrUpdateEntry( |
318 const SyncData& data, | 322 const csync::SyncData& data, |
319 AutocompleteEntryMap* loaded_data, | 323 AutocompleteEntryMap* loaded_data, |
320 std::vector<AutofillEntry>* new_entries) { | 324 std::vector<AutofillEntry>* new_entries) { |
321 const sync_pb::EntitySpecifics& specifics = data.GetSpecifics(); | 325 const sync_pb::EntitySpecifics& specifics = data.GetSpecifics(); |
322 const sync_pb::AutofillSpecifics& autofill_specifics( | 326 const sync_pb::AutofillSpecifics& autofill_specifics( |
323 specifics.autofill()); | 327 specifics.autofill()); |
324 | 328 |
325 if (!autofill_specifics.has_value()) { | 329 if (!autofill_specifics.has_value()) { |
326 DLOG(WARNING) | 330 DLOG(WARNING) |
327 << "Add/Update for old-style autofill profile being dropped!"; | 331 << "Add/Update for old-style autofill profile being dropped!"; |
328 return; | 332 return; |
(...skipping 20 matching lines...) Expand all Loading... |
349 } else { | 353 } else { |
350 // Entry already present - merge if necessary. | 354 // Entry already present - merge if necessary. |
351 std::vector<base::Time> timestamps; | 355 std::vector<base::Time> timestamps; |
352 bool different = MergeTimestamps( | 356 bool different = MergeTimestamps( |
353 autofill_specifics, it->second.second->timestamps(), ×tamps); | 357 autofill_specifics, it->second.second->timestamps(), ×tamps); |
354 if (different) { | 358 if (different) { |
355 AutofillEntry new_entry(it->second.second->key(), timestamps); | 359 AutofillEntry new_entry(it->second.second->key(), timestamps); |
356 new_entries->push_back(new_entry); | 360 new_entries->push_back(new_entry); |
357 // Update the sync db if the list of timestamps have changed. | 361 // Update the sync db if the list of timestamps have changed. |
358 *(it->second.second) = new_entry; | 362 *(it->second.second) = new_entry; |
359 it->second.first = SyncChange::ACTION_UPDATE; | 363 it->second.first = csync::SyncChange::ACTION_UPDATE; |
360 } else { | 364 } else { |
361 loaded_data->erase(it); | 365 loaded_data->erase(it); |
362 } | 366 } |
363 } | 367 } |
364 } | 368 } |
365 | 369 |
366 // static | 370 // static |
367 void AutocompleteSyncableService::WriteAutofillEntry( | 371 void AutocompleteSyncableService::WriteAutofillEntry( |
368 const AutofillEntry& entry, sync_pb::EntitySpecifics* autofill_specifics) { | 372 const AutofillEntry& entry, sync_pb::EntitySpecifics* autofill_specifics) { |
369 sync_pb::AutofillSpecifics* autofill = | 373 sync_pb::AutofillSpecifics* autofill = |
370 autofill_specifics->mutable_autofill(); | 374 autofill_specifics->mutable_autofill(); |
371 autofill->set_name(UTF16ToUTF8(entry.key().name())); | 375 autofill->set_name(UTF16ToUTF8(entry.key().name())); |
372 autofill->set_value(UTF16ToUTF8(entry.key().value())); | 376 autofill->set_value(UTF16ToUTF8(entry.key().value())); |
373 const std::vector<base::Time>& ts(entry.timestamps()); | 377 const std::vector<base::Time>& ts(entry.timestamps()); |
374 for (std::vector<base::Time>::const_iterator timestamp = ts.begin(); | 378 for (std::vector<base::Time>::const_iterator timestamp = ts.begin(); |
375 timestamp != ts.end(); ++timestamp) { | 379 timestamp != ts.end(); ++timestamp) { |
376 autofill->add_usage_timestamp(timestamp->ToInternalValue()); | 380 autofill->add_usage_timestamp(timestamp->ToInternalValue()); |
377 } | 381 } |
378 } | 382 } |
379 | 383 |
380 SyncError AutocompleteSyncableService::AutofillEntryDelete( | 384 csync::SyncError AutocompleteSyncableService::AutofillEntryDelete( |
381 const sync_pb::AutofillSpecifics& autofill) { | 385 const sync_pb::AutofillSpecifics& autofill) { |
382 if (!web_data_service_->GetDatabase()->GetAutofillTable()->RemoveFormElement( | 386 if (!web_data_service_->GetDatabase()->GetAutofillTable()->RemoveFormElement( |
383 UTF8ToUTF16(autofill.name()), UTF8ToUTF16(autofill.value()))) { | 387 UTF8ToUTF16(autofill.name()), UTF8ToUTF16(autofill.value()))) { |
384 return error_handler_->CreateAndUploadError( | 388 return error_handler_->CreateAndUploadError( |
385 FROM_HERE, | 389 FROM_HERE, |
386 "Could not remove autocomplete entry from WebDatabase."); | 390 "Could not remove autocomplete entry from WebDatabase."); |
387 } | 391 } |
388 return SyncError(); | 392 return csync::SyncError(); |
389 } | 393 } |
390 | 394 |
391 void AutocompleteSyncableService::ActOnChanges( | 395 void AutocompleteSyncableService::ActOnChanges( |
392 const AutofillChangeList& changes) { | 396 const AutofillChangeList& changes) { |
393 DCHECK(sync_processor_.get()); | 397 DCHECK(sync_processor_.get()); |
394 SyncChangeList new_changes; | 398 csync::SyncChangeList new_changes; |
395 for (AutofillChangeList::const_iterator change = changes.begin(); | 399 for (AutofillChangeList::const_iterator change = changes.begin(); |
396 change != changes.end(); ++change) { | 400 change != changes.end(); ++change) { |
397 switch (change->type()) { | 401 switch (change->type()) { |
398 case AutofillChange::ADD: | 402 case AutofillChange::ADD: |
399 case AutofillChange::UPDATE: { | 403 case AutofillChange::UPDATE: { |
400 std::vector<base::Time> timestamps; | 404 std::vector<base::Time> timestamps; |
401 if (!web_data_service_->GetDatabase()-> | 405 if (!web_data_service_->GetDatabase()-> |
402 GetAutofillTable()->GetAutofillTimestamps( | 406 GetAutofillTable()->GetAutofillTimestamps( |
403 change->key().name(), | 407 change->key().name(), |
404 change->key().value(), | 408 change->key().value(), |
405 ×tamps)) { | 409 ×tamps)) { |
406 NOTREACHED(); | 410 NOTREACHED(); |
407 return; | 411 return; |
408 } | 412 } |
409 AutofillEntry entry(change->key(), timestamps); | 413 AutofillEntry entry(change->key(), timestamps); |
410 SyncChange::SyncChangeType change_type = | 414 csync::SyncChange::SyncChangeType change_type = |
411 (change->type() == AutofillChange::ADD) ? | 415 (change->type() == AutofillChange::ADD) ? |
412 SyncChange::ACTION_ADD : SyncChange::ACTION_UPDATE; | 416 csync::SyncChange::ACTION_ADD : csync::SyncChange::ACTION_UPDATE; |
413 new_changes.push_back(SyncChange(change_type, | 417 new_changes.push_back(csync::SyncChange(change_type, |
414 CreateSyncData(entry))); | 418 CreateSyncData(entry))); |
415 break; | 419 break; |
416 } | 420 } |
417 case AutofillChange::REMOVE: { | 421 case AutofillChange::REMOVE: { |
418 std::vector<base::Time> timestamps; | 422 std::vector<base::Time> timestamps; |
419 AutofillEntry entry(change->key(), timestamps); | 423 AutofillEntry entry(change->key(), timestamps); |
420 new_changes.push_back(SyncChange(SyncChange::ACTION_DELETE, | 424 new_changes.push_back( |
421 CreateSyncData(entry))); | 425 csync::SyncChange(csync::SyncChange::ACTION_DELETE, |
| 426 CreateSyncData(entry))); |
422 break; | 427 break; |
423 } | 428 } |
424 default: | 429 default: |
425 NOTREACHED(); | 430 NOTREACHED(); |
426 break; | 431 break; |
427 } | 432 } |
428 } | 433 } |
429 SyncError error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); | 434 csync::SyncError error = |
| 435 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); |
430 if (error.IsSet()) { | 436 if (error.IsSet()) { |
431 DLOG(WARNING) << "[AUTOCOMPLETE SYNC]" | 437 DLOG(WARNING) << "[AUTOCOMPLETE SYNC]" |
432 << " Failed processing change:" | 438 << " Failed processing change:" |
433 << " Error:" << error.message(); | 439 << " Error:" << error.message(); |
434 } | 440 } |
435 } | 441 } |
436 | 442 |
437 SyncData AutocompleteSyncableService::CreateSyncData( | 443 csync::SyncData AutocompleteSyncableService::CreateSyncData( |
438 const AutofillEntry& entry) const { | 444 const AutofillEntry& entry) const { |
439 sync_pb::EntitySpecifics autofill_specifics; | 445 sync_pb::EntitySpecifics autofill_specifics; |
440 WriteAutofillEntry(entry, &autofill_specifics); | 446 WriteAutofillEntry(entry, &autofill_specifics); |
441 std::string tag(KeyToTag(UTF16ToUTF8(entry.key().name()), | 447 std::string tag(KeyToTag(UTF16ToUTF8(entry.key().name()), |
442 UTF16ToUTF8(entry.key().value()))); | 448 UTF16ToUTF8(entry.key().value()))); |
443 return SyncData::CreateLocalData(tag, tag, autofill_specifics); | 449 return csync::SyncData::CreateLocalData(tag, tag, autofill_specifics); |
444 } | 450 } |
445 | 451 |
446 // static | 452 // static |
447 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, | 453 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, |
448 const std::string& value) { | 454 const std::string& value) { |
449 std::string ns(kAutofillEntryNamespaceTag); | 455 std::string ns(kAutofillEntryNamespaceTag); |
450 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); | 456 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); |
451 } | 457 } |
OLD | NEW |