Chromium Code Reviews| Index: chrome/browser/sync/engine/syncapi.cc |
| diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc |
| index bc34982435d25682fefa023756c8c80f380fc0dd..9744eb7dbc6c20604c106c58069371cc82bd1d69 100644 |
| --- a/chrome/browser/sync/engine/syncapi.cc |
| +++ b/chrome/browser/sync/engine/syncapi.cc |
| @@ -33,6 +33,8 @@ |
| #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h" |
| #include "chrome/browser/sync/engine/syncer.h" |
| #include "chrome/browser/sync/engine/syncer_thread.h" |
| +#include "chrome/browser/sync/glue/autofill_model_associator.h" |
| +#include "chrome/browser/sync/glue/autofill_profile_model_associator.h" |
|
tim (not reviewing)
2010/12/10 22:16:02
this is also strictly not allowed. glue is code ch
lipalani
2010/12/11 00:12:36
Done.
|
| #include "chrome/browser/sync/notifier/server_notifier_thread.h" |
| #include "chrome/browser/sync/notifier/state_writer.h" |
| #include "chrome/browser/sync/protocol/app_specifics.pb.h" |
| @@ -380,6 +382,20 @@ void WriteNode::PutAutofillSpecificsAndMarkForSyncing( |
| PutSpecificsAndMarkForSyncing(entity_specifics); |
| } |
| +void WriteNode::SetAutofillProfileSpecifics( |
| + const sync_pb::AutofillProfileSpecifics& new_value) { |
| + DCHECK_EQ(GetModelType(), syncable::AUTOFILL_PROFILE); |
| + PutAutofillProfileSpecificsAndMarkForSyncing(new_value); |
| +} |
| + |
| +void WriteNode::PutAutofillProfileSpecificsAndMarkForSyncing( |
| + const sync_pb::AutofillProfileSpecifics& new_value) { |
| + sync_pb::EntitySpecifics entity_specifics; |
| + entity_specifics.MutableExtension(sync_pb::autofill_profile)->CopyFrom( |
| + new_value); |
| + PutSpecificsAndMarkForSyncing(entity_specifics); |
| +} |
| + |
| void WriteNode::SetBookmarkSpecifics( |
| const sync_pb::BookmarkSpecifics& new_value) { |
| DCHECK(GetModelType() == syncable::BOOKMARKS); |
| @@ -1099,6 +1115,52 @@ class SyncManager::SyncInternal |
| return true; |
| } |
| + syncable::Directory::PersistedKernelInfo::AutofillMigrationState |
| + GetAutofillMigrationState() { |
| + syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| + if (!lookup.good()) { |
| + DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| + return |
| + syncable::Directory::PersistedKernelInfo::NOT_MIGRATED; |
| + } |
| + |
| + return lookup->get_autofill_migration_state(); |
| + } |
| + |
| + void SetAutofillMigrationState( |
| + syncable::Directory::PersistedKernelInfo::AutofillMigrationState state) { |
| + syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| + if (!lookup.good()) { |
| + DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| + return; |
| + } |
| + |
| + return lookup->set_autofill_migration_state(state); |
| + } |
| + |
| + void SetAutofillMigrationDebugInfo( |
| + syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| + const syncable::AutofillMigrationDebugInfo& info) { |
| + syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| + if (!lookup.good()) { |
| + DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| + return; |
| + } |
| + |
| + return lookup->set_autofill_migration_state_debug_info(property_to_set, info); |
|
lipalani
2010/12/09 19:45:25
change it to less than 80 characters.
lipalani
2010/12/11 00:12:36
Done.
|
| + } |
| + |
| + syncable::AutofillMigrationDebugInfo |
| + GetAutofillMigrationDebugInfo() { |
| + syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| + if (!lookup.good()) { |
| + DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| + syncable::AutofillMigrationDebugInfo null_value = {0}; |
| + return null_value; |
| + } |
| + return lookup->get_autofill_migration_debug_info(); |
| + } |
| + |
| // SyncEngineEventListener implementation. |
| virtual void OnSyncEngineEvent(const SyncEngineEvent& event); |
| private: |
| @@ -1316,10 +1378,72 @@ bool SyncManager::InitialSyncEndedForAllEnabledTypes() { |
| return data_->InitialSyncEndedForAllEnabledTypes(); |
| } |
| +void SyncManager::ConfigureAutofillMigration() { |
| + if (GetAutofillMigrationState() |
| + == syncable::Directory::PersistedKernelInfo::NOT_DETERMINED) { |
| + ReadTransaction trans(GetUserShare()); |
| + ReadNode autofil_root_node(&trans); |
| + |
| + // Check for the presence of autofill node. |
| + if (!autofil_root_node.InitByTagLookup(browser_sync::kAutofillTag)) { |
| + SetAutofillMigrationState( |
| + syncable::Directory::PersistedKernelInfo::INSUFFICIENT_INFO_TO_DETERMINE); |
| + return; |
| + } |
| + |
| + // Check for children under autofill node. |
| + if (autofil_root_node.GetFirstChildId() == static_cast<int64>(0)) { |
| + SetAutofillMigrationState( |
|
lipalani
2010/12/09 19:45:25
fix 80 characters
lipalani
2010/12/11 00:12:36
Done.
|
| + syncable::Directory::PersistedKernelInfo::INSUFFICIENT_INFO_TO_DETERMINE); |
| + return; |
| + } |
| + |
| + ReadNode autofill_profile_root_node(&trans); |
| + |
| + // Check for the presence of autofill profile root node. |
| + if (!autofill_profile_root_node.InitByTagLookup( |
| + browser_sync::kAutofillProfileTag)) { |
| + SetAutofillMigrationState( |
| + syncable::Directory::PersistedKernelInfo::NOT_MIGRATED); |
| + return; |
| + } |
| + |
| + // If our state is not determined then we should not have the autofill |
| + // profile node. |
| + DCHECK(false); |
| + |
| + // just set it as not migrated. |
| + SetAutofillMigrationState( |
| + syncable::Directory::PersistedKernelInfo::NOT_MIGRATED); |
| + return; |
| + } |
| +} |
| + |
| void SyncManager::StartSyncing() { |
| data_->StartSyncing(); |
| } |
| +syncable::Directory::PersistedKernelInfo::AutofillMigrationState |
| + SyncManager::GetAutofillMigrationState() { |
| + return data_->GetAutofillMigrationState(); |
| +} |
| + |
| +void SyncManager::SetAutofillMigrationState( |
| + syncable::Directory::PersistedKernelInfo::AutofillMigrationState state) { |
| + return data_->SetAutofillMigrationState(state); |
| +} |
| + |
| +syncable::AutofillMigrationDebugInfo |
| + SyncManager::GetAutofillMigrationDebugInfo() { |
| + return data_->GetAutofillMigrationDebugInfo(); |
| +} |
| + |
| +void SyncManager::SetAutofillMigrationDebugInfo( |
| + syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| + const syncable::AutofillMigrationDebugInfo& info) { |
| + return data_->SetAutofillMigrationDebugInfo(property_to_set, info); |
| +} |
| + |
| void SyncManager::SetPassphrase(const std::string& passphrase, |
| bool is_explicit) { |
| data_->SetPassphrase(passphrase, is_explicit); |
| @@ -2177,7 +2301,7 @@ void SyncManager::SyncInternal::OnIncomingNotification( |
| if (!syncable::ModelTypeBitSetFromString( |
| notification_data.service_specific_data, |
| &model_types)) { |
| - LOG(DFATAL) << "Could not extract model types from server data."; |
| + // LOG(DFATAL) << "Could not extract model types from server data."; |
| model_types.set(); |
| } |
| } else if (notification_data.service_url.empty() || |