Chromium Code Reviews| Index: chrome/browser/sync/glue/autofill_model_associator.cc |
| diff --git a/chrome/browser/sync/glue/autofill_model_associator.cc b/chrome/browser/sync/glue/autofill_model_associator.cc |
| index c4800c0518db48a730ed2dc1550bffa143b8025b..2a7966446440791e8eee49318df50fd0e0fc6093 100644 |
| --- a/chrome/browser/sync/glue/autofill_model_associator.cc |
| +++ b/chrome/browser/sync/glue/autofill_model_associator.cc |
| @@ -13,12 +13,16 @@ |
| #include "chrome/browser/autofill/autofill_profile.h" |
| #include "chrome/browser/browser_thread.h" |
| #include "chrome/browser/guid.h" |
| +#include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/browser/profile.h" |
| #include "chrome/browser/sync/engine/syncapi.h" |
| #include "chrome/browser/sync/glue/autofill_change_processor.h" |
| +#include "chrome/browser/sync/glue/autofill_profile_model_associator.h" |
| +#include "chrome/browser/sync/glue/do_optimistic_refresh_Task.h" |
| #include "chrome/browser/sync/profile_sync_service.h" |
| #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
| #include "chrome/browser/webdata/web_database.h" |
| +#include "chrome/common/pref_names.h" |
| #include "net/base/escape.h" |
| using base::TimeTicks; |
| @@ -37,16 +41,6 @@ struct AutofillModelAssociator::DataBundle { |
| ~DataBundle() { STLDeleteElements(&new_profiles); } |
| }; |
| -AutofillModelAssociator::DoOptimisticRefreshTask::DoOptimisticRefreshTask( |
| - PersonalDataManager* pdm) : pdm_(pdm) {} |
| - |
| -AutofillModelAssociator::DoOptimisticRefreshTask::~DoOptimisticRefreshTask() {} |
| - |
| -void AutofillModelAssociator::DoOptimisticRefreshTask::Run() { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - pdm_->Refresh(); |
| -} |
| - |
| AutofillModelAssociator::AutofillModelAssociator( |
| ProfileSyncService* sync_service, |
| WebDatabase* web_database, |
| @@ -121,21 +115,6 @@ bool AutofillModelAssociator::TraverseAndAssociateChromeAutofillEntries( |
| return true; |
| } |
| -bool AutofillModelAssociator::MakeNewAutofillProfileSyncNode( |
| - sync_api::WriteTransaction* trans, const sync_api::BaseNode& autofill_root, |
| - const std::string& tag, const AutoFillProfile& profile, int64* sync_id) { |
| - sync_api::WriteNode node(trans); |
| - if (!node.InitUniqueByCreation(syncable::AUTOFILL, autofill_root, tag)) { |
| - LOG(ERROR) << "Failed to create autofill sync node."; |
| - return false; |
| - } |
| - node.SetTitle(UTF8ToWide(tag)); |
| - AutofillChangeProcessor::WriteAutofillProfile(profile, &node); |
| - *sync_id = node.GetId(); |
| - return true; |
| -} |
| - |
| - |
| bool AutofillModelAssociator::LoadAutofillData( |
| std::vector<AutofillEntry>* entries, |
| std::vector<AutoFillProfile*>* profiles) { |
| @@ -257,7 +236,7 @@ bool AutofillModelAssociator::TraverseAndAssociateAllSyncNodes( |
| if (autofill.has_value()) |
| AddNativeEntryIfNeeded(autofill, bundle, sync_child); |
| // Ignore autofill profiles if we are not upgrading. |
| - else if (autofill.has_profile() && IsUpgrading()) { |
| + else if (autofill.has_profile() && IsUpgrading(write_trans)) { |
| AddNativeProfileIfNeeded( |
| autofill.profile(), |
| bundle, |
| @@ -343,10 +322,10 @@ void AutofillModelAssociator::AddNativeProfileIfNeeded( |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| - scoped_ptr<AutoFillProfile> profile_in_web_db(FindCorrespondingNodeFromWebDB( |
| - profile, all_profiles_from_db)); |
| + AutoFillProfile* profile_in_web_db = FindCorrespondingNodeFromWebDB( |
| + profile, all_profiles_from_db); |
| - if (profile_in_web_db.get() != NULL) { |
| + if (profile_in_web_db != NULL) { |
| int64 sync_id = node.GetId(); |
| Associate(&(profile_in_web_db->guid()), sync_id); |
| return; |
| @@ -520,9 +499,12 @@ bool AutofillModelAssociator::OverwriteProfileWithServerData( |
| return diff; |
| } |
| -bool AutofillModelAssociator::IsUpgrading() |
| -{ |
| - return true; |
| +bool AutofillModelAssociator::IsUpgrading(sync_api::WriteTransaction* trans) { |
| + |
|
lipalani
2010/12/08 21:37:46
call the fn in model associator.
|
| + sync_api::ReadNode node(trans); |
| + |
| + return !node.InitByClientTagLookup(syncable::AUTOFILL_PROFILE, |
| + kAutofillProfileTag); |
| } |
| } // namespace browser_sync |