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

Side by Side Diff: chrome/browser/webdata/autocomplete_syncable_service.cc

Issue 12543034: Move creation of the various WebDatabaseTable types out of WebDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows release builds (COMDAT folding combined static functions being used for keys. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 DCHECK_EQ(web_data_service_, wds); 293 DCHECK_EQ(web_data_service_, wds);
294 294
295 AutofillChangeList* changes = 295 AutofillChangeList* changes =
296 content::Details<AutofillChangeList>(details).ptr(); 296 content::Details<AutofillChangeList>(details).ptr();
297 ActOnChanges(*changes); 297 ActOnChanges(*changes);
298 } 298 }
299 299
300 bool AutocompleteSyncableService::LoadAutofillData( 300 bool AutocompleteSyncableService::LoadAutofillData(
301 std::vector<AutofillEntry>* entries) const { 301 std::vector<AutofillEntry>* entries) const {
302 return web_data_service_->GetDatabase()-> 302 return AutofillTable::FromWebDatabase(
303 GetAutofillTable()->GetAllAutofillEntries(entries); 303 web_data_service_->GetDatabase())->GetAllAutofillEntries(entries);
304 } 304 }
305 305
306 bool AutocompleteSyncableService::SaveChangesToWebData( 306 bool AutocompleteSyncableService::SaveChangesToWebData(
307 const std::vector<AutofillEntry>& new_entries) { 307 const std::vector<AutofillEntry>& new_entries) {
308 DCHECK(CalledOnValidThread()); 308 DCHECK(CalledOnValidThread());
309 309
310 if (!new_entries.empty() && 310 if (!new_entries.empty() &&
311 !web_data_service_->GetDatabase()-> 311 !AutofillTable::FromWebDatabase(
312 GetAutofillTable()->UpdateAutofillEntries(new_entries)) { 312 web_data_service_->GetDatabase())->UpdateAutofillEntries(
313 new_entries)) {
313 return false; 314 return false;
314 } 315 }
315 return true; 316 return true;
316 } 317 }
317 318
318 // Creates or updates an autocomplete entry based on |data|. 319 // Creates or updates an autocomplete entry based on |data|.
319 void AutocompleteSyncableService::CreateOrUpdateEntry( 320 void AutocompleteSyncableService::CreateOrUpdateEntry(
320 const syncer::SyncData& data, 321 const syncer::SyncData& data,
321 AutocompleteEntryMap* loaded_data, 322 AutocompleteEntryMap* loaded_data,
322 std::vector<AutofillEntry>* new_entries) { 323 std::vector<AutofillEntry>* new_entries) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 autofill->set_value(UTF16ToUTF8(entry.key().value())); 375 autofill->set_value(UTF16ToUTF8(entry.key().value()));
375 const std::vector<base::Time>& ts(entry.timestamps()); 376 const std::vector<base::Time>& ts(entry.timestamps());
376 for (std::vector<base::Time>::const_iterator timestamp = ts.begin(); 377 for (std::vector<base::Time>::const_iterator timestamp = ts.begin();
377 timestamp != ts.end(); ++timestamp) { 378 timestamp != ts.end(); ++timestamp) {
378 autofill->add_usage_timestamp(timestamp->ToInternalValue()); 379 autofill->add_usage_timestamp(timestamp->ToInternalValue());
379 } 380 }
380 } 381 }
381 382
382 syncer::SyncError AutocompleteSyncableService::AutofillEntryDelete( 383 syncer::SyncError AutocompleteSyncableService::AutofillEntryDelete(
383 const sync_pb::AutofillSpecifics& autofill) { 384 const sync_pb::AutofillSpecifics& autofill) {
384 if (!web_data_service_->GetDatabase()->GetAutofillTable()->RemoveFormElement( 385 if (!AutofillTable::FromWebDatabase(
385 UTF8ToUTF16(autofill.name()), UTF8ToUTF16(autofill.value()))) { 386 web_data_service_->GetDatabase())->RemoveFormElement(
387 UTF8ToUTF16(autofill.name()), UTF8ToUTF16(autofill.value()))) {
386 return error_handler_->CreateAndUploadError( 388 return error_handler_->CreateAndUploadError(
387 FROM_HERE, 389 FROM_HERE,
388 "Could not remove autocomplete entry from WebDatabase."); 390 "Could not remove autocomplete entry from WebDatabase.");
389 } 391 }
390 return syncer::SyncError(); 392 return syncer::SyncError();
391 } 393 }
392 394
393 void AutocompleteSyncableService::ActOnChanges( 395 void AutocompleteSyncableService::ActOnChanges(
394 const AutofillChangeList& changes) { 396 const AutofillChangeList& changes) {
395 DCHECK(sync_processor_.get()); 397 DCHECK(sync_processor_.get());
396 syncer::SyncChangeList new_changes; 398 syncer::SyncChangeList new_changes;
397 for (AutofillChangeList::const_iterator change = changes.begin(); 399 for (AutofillChangeList::const_iterator change = changes.begin();
398 change != changes.end(); ++change) { 400 change != changes.end(); ++change) {
399 switch (change->type()) { 401 switch (change->type()) {
400 case AutofillChange::ADD: 402 case AutofillChange::ADD:
401 case AutofillChange::UPDATE: { 403 case AutofillChange::UPDATE: {
402 std::vector<base::Time> timestamps; 404 std::vector<base::Time> timestamps;
403 if (!web_data_service_->GetDatabase()-> 405 if (!AutofillTable::FromWebDatabase(
404 GetAutofillTable()->GetAutofillTimestamps( 406 web_data_service_->GetDatabase())->GetAutofillTimestamps(
405 change->key().name(), 407 change->key().name(),
406 change->key().value(), 408 change->key().value(),
407 &timestamps)) { 409 &timestamps)) {
408 NOTREACHED(); 410 NOTREACHED();
409 return; 411 return;
410 } 412 }
411 AutofillEntry entry(change->key(), timestamps); 413 AutofillEntry entry(change->key(), timestamps);
412 syncer::SyncChange::SyncChangeType change_type = 414 syncer::SyncChange::SyncChangeType change_type =
413 (change->type() == AutofillChange::ADD) ? 415 (change->type() == AutofillChange::ADD) ?
414 syncer::SyncChange::ACTION_ADD : 416 syncer::SyncChange::ACTION_ADD :
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 UTF16ToUTF8(entry.key().value()))); 457 UTF16ToUTF8(entry.key().value())));
456 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics); 458 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics);
457 } 459 }
458 460
459 // static 461 // static
460 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, 462 std::string AutocompleteSyncableService::KeyToTag(const std::string& name,
461 const std::string& value) { 463 const std::string& value) {
462 std::string ns(kAutofillEntryNamespaceTag); 464 std::string ns(kAutofillEntryNamespaceTag);
463 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); 465 return ns + net::EscapePath(name) + "|" + net::EscapePath(value);
464 } 466 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/autofill_helper.cc ('k') | chrome/browser/webdata/autofill_profile_syncable_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698