Chromium Code Reviews| Index: chrome/browser/sync/glue/sync_backend_host.cc |
| diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc |
| index 00786e046f5279afbded123d41d4214896829ba1..5f4b24edc1e5b46a78aa328eb1d488c1780e4095 100644 |
| --- a/chrome/browser/sync/glue/sync_backend_host.cc |
| +++ b/chrome/browser/sync/glue/sync_backend_host.cc |
| @@ -23,9 +23,11 @@ |
| #include "chrome/browser/sync/glue/change_processor.h" |
| #include "chrome/browser/sync/glue/http_bridge.h" |
| #include "chrome/browser/sync/internal_api/base_transaction.h" |
| +#include "chrome/browser/sync/internal_api/read_transaction.h" |
| #include "chrome/browser/sync/internal_api/sync_manager.h" |
| #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
| #include "chrome/browser/sync/notifier/sync_notifier.h" |
| +#include "chrome/browser/sync/protocol/sync.pb.h" |
| #include "chrome/browser/sync/sessions/session_state.h" |
| // TODO(tim): Remove this! We should have a syncapi pass-thru instead. |
| #include "chrome/browser/sync/syncable/directory_manager.h" // Cryptographer. |
| @@ -57,6 +59,7 @@ SyncBackendHost::SyncBackendHost(Profile* profile) |
| sync_thread_("Chrome_SyncThread"), |
| frontend_loop_(MessageLoop::current()), |
| profile_(profile), |
| + name_(profile_->GetDebugName()), |
| sync_notifier_factory_(webkit_glue::GetUserAgent(GURL()), |
| profile_->GetRequestContext(), |
| *CommandLine::ForCurrentProcess()), |
| @@ -279,27 +282,14 @@ void SyncBackendHost::ConfigureDataTypes( |
| types_to_remove_with_nigori); |
| pending_config_mode_state_->reason = reason; |
| - // Cleanup disabled types before starting configuration so that |
| - // callers can assume that the data types are cleaned up once |
| - // configuration is done. |
| - if (!types_to_remove.empty()) { |
| - sync_thread_.message_loop()->PostTask( |
| - FROM_HERE, |
| - NewRunnableMethod( |
| - core_.get(), |
| - &SyncBackendHost::Core::DoRequestCleanupDisabledTypes)); |
| - } |
| - |
| - StartConfiguration(NewCallback(core_.get(), |
| - &SyncBackendHost::Core::FinishConfigureDataTypes)); |
| + StartConfiguration(!types_to_remove_with_nigori.empty()); |
| } |
| -void SyncBackendHost::StartConfiguration(Callback0::Type* callback) { |
| - // Put syncer in the config mode. DTM will put us in normal mode once it is |
| - // done. This is to ensure we dont do a normal sync when we are doing model |
| - // association. |
| - sync_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| - core_.get(), &SyncBackendHost::Core::DoStartConfiguration, callback)); |
| +void SyncBackendHost::StartConfiguration(bool cleanup_disabled_types) { |
|
tim (not reviewing)
2011/08/26 12:41:40
I'll point out the bools vs enum style guide at ht
|
| + sync_thread_.message_loop()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&SyncBackendHost::Core::DoStartConfiguration, core_.get(), |
| + cleanup_disabled_types)); |
| } |
| void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { |
| @@ -315,7 +305,7 @@ void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { |
| // complete, the configure_state_.ready_task_ is run via an |
| // OnInitializationComplete notification. |
| - VLOG(1) << "Syncer in config mode. SBH executing" |
| + VLOG(1) << "Syncer in config mode. SBH executing " |
| << "FinishConfigureDataTypesOnFrontendLoop"; |
| if (pending_config_mode_state_->added_types.empty() && |
| @@ -333,8 +323,7 @@ void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { |
| // If we've added types, we always want to request a nudge/config (even if |
| // the initial sync is ended), in case we could not decrypt the data. |
| if (pending_config_mode_state_->added_types.empty()) { |
| - VLOG(1) << "SyncBackendHost(" << this << "): No new types added. " |
| - << "Calling ready_task directly"; |
| + VLOG(1) << name_ << ": No new types added; calling ready_task directly"; |
| // No new types - just notify the caller that the types are available. |
| pending_config_mode_state_->ready_task.Run(true); |
| } else { |
| @@ -346,8 +335,8 @@ void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { |
| if (IsNigoriEnabled()) { |
| types_to_config.insert(syncable::NIGORI); |
| } |
| - VLOG(1) << "SyncBackendHost(" << this << "):New Types added. " |
| - << "Calling DoRequestConfig"; |
| + VLOG(1) << name_ << ": types " << ModelTypeSetToString(types_to_config) |
| + << "added; calling DoRequestConfig"; |
| sync_thread_.message_loop()->PostTask(FROM_HERE, |
| NewRunnableMethod(core_.get(), |
| &SyncBackendHost::Core::DoRequestConfig, |
| @@ -376,6 +365,22 @@ syncable::ModelTypeSet SyncBackendHost::GetEncryptedDataTypes() const { |
| return core_->sync_manager()->GetEncryptedDataTypes(); |
| } |
| +syncable::ModelTypeSet SyncBackendHost::GetPurgedDataTypes() const { |
| + DCHECK_GT(initialization_state_, NOT_INITIALIZED); |
| + sync_api::ReadTransaction trans(FROM_HERE, GetUserShare()); |
| + syncable::ModelTypeSet purged_data_types; |
| + for (int i = syncable::FIRST_REAL_MODEL_TYPE; |
| + i < syncable::MODEL_TYPE_COUNT; ++i) { |
| + syncable::ModelType type = syncable::ModelTypeFromInt(i); |
| + sync_pb::DataTypeProgressMarker progress_marker; |
| + trans.GetLookup()->GetDownloadProgress(type, &progress_marker); |
|
tim (not reviewing)
2011/08/26 12:41:40
I like the GetDownloadProgress approach, but want
|
| + if (progress_marker.token().empty()) { |
| + purged_data_types.insert(type); |
| + } |
| + } |
| + return purged_data_types; |
| +} |
| + |
| void SyncBackendHost::ActivateDataType( |
| syncable::ModelType type, ModelSafeGroup group, |
| ChangeProcessor* change_processor) { |
| @@ -638,8 +643,15 @@ void SyncBackendHost::Core::DoRequestConfig( |
| sync_manager_->RequestConfig(types_to_config, reason); |
| } |
| -void SyncBackendHost::Core::DoStartConfiguration(Callback0::Type* callback) { |
| - sync_manager_->StartConfigurationMode(callback); |
| +void SyncBackendHost::Core::DoStartConfiguration(bool cleanup_disabled_types) { |
| + base::Closure done_callback = |
| + base::Bind(&SyncBackendHost::Core::FinishConfigureDataTypes,this); |
| + base::Closure on_config_done_callback = |
| + cleanup_disabled_types ? |
| + base::Bind(&SyncBackendHost::Core::DoRequestCleanupDisabledTypes, |
| + this, done_callback) : |
| + done_callback; |
| + sync_manager_->StartConfigurationMode(on_config_done_callback); |
| } |
| void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { |
| @@ -727,6 +739,11 @@ void SyncBackendHost::Core::HandleSyncCycleCompletedOnFrontendLoop( |
| DCHECK( |
| std::includes(state->types_to_add.begin(), state->types_to_add.end(), |
| state->added_types.begin(), state->added_types.end())); |
| + VLOG(1) |
| + << "Added types: " |
| + << syncable::ModelTypeSetToString(state->added_types) |
| + << ", configured types: " |
| + << syncable::ModelTypeBitSetToString(snapshot->initial_sync_ended); |
| syncable::ModelTypeBitSet added_types = |
| syncable::ModelTypeBitSetFromSet(state->added_types); |
| bool found_all_added = |
| @@ -887,8 +904,9 @@ void SyncBackendHost::Core::DoRequestClearServerData() { |
| sync_manager_->RequestClearServerData(); |
| } |
| -void SyncBackendHost::Core::DoRequestCleanupDisabledTypes() { |
| - sync_manager_->RequestCleanupDisabledTypes(); |
| +void SyncBackendHost::Core::DoRequestCleanupDisabledTypes( |
| + const base::Closure& callback) { |
| + sync_manager_->RequestCleanupDisabledTypes(callback); |
| } |
| void SyncBackendHost::Core::SaveChanges() { |