| Index: chrome/browser/sync/glue/autofill_change_processor.cc
|
| diff --git a/chrome/browser/sync/glue/autofill_change_processor.cc b/chrome/browser/sync/glue/autofill_change_processor.cc
|
| index d0e891c128dabcf19304f75135b4035135e2beb6..8fe62de6a6bfc1d164922554fba873714a8439bb 100644
|
| --- a/chrome/browser/sync/glue/autofill_change_processor.cc
|
| +++ b/chrome/browser/sync/glue/autofill_change_processor.cc
|
| @@ -14,6 +14,7 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/sync/glue/autofill_model_associator.h"
|
| #include "chrome/browser/sync/glue/do_optimistic_refresh_task.h"
|
| +#include "chrome/browser/sync/internal_api/change_record.h"
|
| #include "chrome/browser/sync/internal_api/read_node.h"
|
| #include "chrome/browser/sync/internal_api/write_node.h"
|
| #include "chrome/browser/sync/internal_api/write_transaction.h"
|
| @@ -29,10 +30,10 @@
|
| namespace browser_sync {
|
|
|
| struct AutofillChangeProcessor::AutofillChangeRecord {
|
| - sync_api::SyncManager::ChangeRecord::Action action_;
|
| + sync_api::ChangeRecord::Action action_;
|
| int64 id_;
|
| sync_pb::AutofillSpecifics autofill_;
|
| - AutofillChangeRecord(sync_api::SyncManager::ChangeRecord::Action action,
|
| + AutofillChangeRecord(sync_api::ChangeRecord::Action action,
|
| int64 id, const sync_pb::AutofillSpecifics& autofill)
|
| : action_(action),
|
| id_(id),
|
| @@ -196,8 +197,7 @@ void AutofillChangeProcessor::RemoveSyncNode(const std::string& tag,
|
|
|
| void AutofillChangeProcessor::ApplyChangesFromSyncModel(
|
| const sync_api::BaseTransaction* trans,
|
| - const sync_api::SyncManager::ChangeRecord* changes,
|
| - int change_count) {
|
| + const sync_api::ImmutableChangeRecordList& changes) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
|
| if (!running())
|
| return;
|
| @@ -210,16 +210,17 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
|
| return;
|
| }
|
|
|
| - for (int i = 0; i < change_count; ++i) {
|
| - sync_api::SyncManager::ChangeRecord::Action action(changes[i].action);
|
| - if (sync_api::SyncManager::ChangeRecord::ACTION_DELETE == action) {
|
| - DCHECK(changes[i].specifics.HasExtension(sync_pb::autofill))
|
| + for (sync_api::ChangeRecordList::const_iterator it =
|
| + changes.Get().begin(); it != changes.Get().end(); ++it) {
|
| + sync_api::ChangeRecord::Action action(it->action);
|
| + if (sync_api::ChangeRecord::ACTION_DELETE == action) {
|
| + DCHECK(it->specifics.HasExtension(sync_pb::autofill))
|
| << "Autofill specifics data not present on delete!";
|
| const sync_pb::AutofillSpecifics& autofill =
|
| - changes[i].specifics.GetExtension(sync_pb::autofill);
|
| + it->specifics.GetExtension(sync_pb::autofill);
|
| if (autofill.has_value()) {
|
| - autofill_changes_.push_back(AutofillChangeRecord(changes[i].action,
|
| - changes[i].id,
|
| + autofill_changes_.push_back(AutofillChangeRecord(it->action,
|
| + it->id,
|
| autofill));
|
| } else if (autofill.has_profile()) {
|
| LOG(WARNING) << "Change for old-style autofill profile being dropped!";
|
| @@ -231,7 +232,7 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
|
|
|
| // Handle an update or add.
|
| sync_api::ReadNode sync_node(trans);
|
| - if (!sync_node.InitByIdLookup(changes[i].id)) {
|
| + if (!sync_node.InitByIdLookup(it->id)) {
|
| error_handler()->OnUnrecoverableError(FROM_HERE,
|
| "Autofill node lookup failed.");
|
| return;
|
| @@ -245,7 +246,7 @@ void AutofillChangeProcessor::ApplyChangesFromSyncModel(
|
| sync_node.GetAutofillSpecifics());
|
| int64 sync_id = sync_node.GetId();
|
| if (autofill.has_value()) {
|
| - autofill_changes_.push_back(AutofillChangeRecord(changes[i].action,
|
| + autofill_changes_.push_back(AutofillChangeRecord(it->action,
|
| sync_id, autofill));
|
| } else if (autofill.has_profile()) {
|
| LOG(WARNING) << "Change for old-style autofill profile being dropped!";
|
| @@ -266,7 +267,7 @@ void AutofillChangeProcessor::CommitChangesFromSyncModel() {
|
| std::vector<AutofillEntry> new_entries;
|
| for (unsigned int i = 0; i < autofill_changes_.size(); i++) {
|
| // Handle deletions.
|
| - if (sync_api::SyncManager::ChangeRecord::ACTION_DELETE ==
|
| + if (sync_api::ChangeRecord::ACTION_DELETE ==
|
| autofill_changes_[i].action_) {
|
| if (autofill_changes_[i].autofill_.has_value()) {
|
| ApplySyncAutofillEntryDelete(autofill_changes_[i].autofill_);
|
| @@ -317,11 +318,11 @@ void AutofillChangeProcessor::ApplySyncAutofillEntryDelete(
|
| }
|
|
|
| void AutofillChangeProcessor::ApplySyncAutofillEntryChange(
|
| - sync_api::SyncManager::ChangeRecord::Action action,
|
| + sync_api::ChangeRecord::Action action,
|
| const sync_pb::AutofillSpecifics& autofill,
|
| std::vector<AutofillEntry>* new_entries,
|
| int64 sync_id) {
|
| - DCHECK_NE(sync_api::SyncManager::ChangeRecord::ACTION_DELETE, action);
|
| + DCHECK_NE(sync_api::ChangeRecord::ACTION_DELETE, action);
|
|
|
| std::vector<base::Time> timestamps;
|
| size_t timestamps_size = autofill.usage_timestamp_size();
|
| @@ -334,18 +335,18 @@ void AutofillChangeProcessor::ApplySyncAutofillEntryChange(
|
|
|
| new_entries->push_back(new_entry);
|
| std::string tag(AutofillModelAssociator::KeyToTag(k.name(), k.value()));
|
| - if (action == sync_api::SyncManager::ChangeRecord::ACTION_ADD)
|
| + if (action == sync_api::ChangeRecord::ACTION_ADD)
|
| model_associator_->Associate(&tag, sync_id);
|
| }
|
|
|
| void AutofillChangeProcessor::ApplySyncAutofillProfileChange(
|
| - sync_api::SyncManager::ChangeRecord::Action action,
|
| + sync_api::ChangeRecord::Action action,
|
| const sync_pb::AutofillProfileSpecifics& profile,
|
| int64 sync_id) {
|
| - DCHECK_NE(sync_api::SyncManager::ChangeRecord::ACTION_DELETE, action);
|
| + DCHECK_NE(sync_api::ChangeRecord::ACTION_DELETE, action);
|
|
|
| switch (action) {
|
| - case sync_api::SyncManager::ChangeRecord::ACTION_ADD: {
|
| + case sync_api::ChangeRecord::ACTION_ADD: {
|
| std::string guid(guid::GenerateGUID());
|
| if (guid::IsValidGUID(guid) == false) {
|
| DCHECK(false) << "Guid generated is invalid " << guid;
|
| @@ -362,7 +363,7 @@ void AutofillChangeProcessor::ApplySyncAutofillProfileChange(
|
| model_associator_->Associate(&guid, sync_id);
|
| break;
|
| }
|
| - case sync_api::SyncManager::ChangeRecord::ACTION_UPDATE: {
|
| + case sync_api::ChangeRecord::ACTION_UPDATE: {
|
| const std::string* guid = model_associator_->GetChromeNodeFromSyncId(
|
| sync_id);
|
| if (guid == NULL) {
|
|
|