Index: sync/internal_api/sync_manager.cc |
diff --git a/sync/internal_api/sync_manager.cc b/sync/internal_api/sync_manager.cc |
index 08033b1b4be1771154ca10e660f48c6a921c8438..eb28918c864e6f485d07e8f5e799725ddc0c917f 100644 |
--- a/sync/internal_api/sync_manager.cc |
+++ b/sync/internal_api/sync_manager.cc |
@@ -58,6 +58,7 @@ |
using base::TimeDelta; |
using browser_sync::AllStatus; |
+using browser_sync::ConfigureParams; |
using browser_sync::Cryptographer; |
using browser_sync::Encryptor; |
using browser_sync::JsArgList; |
@@ -842,46 +843,49 @@ bool SyncManager::IsUsingExplicitPassphrase() { |
return data_ && data_->IsUsingExplicitPassphrase(); |
} |
-void SyncManager::RequestCleanupDisabledTypes( |
- const browser_sync::ModelSafeRoutingInfo& routing_info) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
- if (data_->scheduler()) { |
- data_->session_context()->set_routing_info(routing_info); |
- data_->scheduler()->CleanupDisabledTypes(); |
- } |
-} |
- |
void SyncManager::RequestClearServerData() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
if (data_->scheduler()) |
data_->scheduler()->ClearUserData(); |
} |
-void SyncManager::RequestConfig( |
- const browser_sync::ModelSafeRoutingInfo& routing_info, |
- const ModelTypeSet& types, ConfigureReason reason) { |
+void SyncManager::ConfigureSyncer( |
+ ConfigureReason reason, |
+ const syncable::ModelTypeSet& types_to_config, |
+ const browser_sync::ModelSafeRoutingInfo& new_routing_info, |
+ const base::Closure& ready_task, |
+ const base::Closure& retry_task) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- if (!data_->scheduler()) { |
- LOG(INFO) |
- << "SyncManager::RequestConfig: bailing out because scheduler is " |
- << "null"; |
- return; |
- } |
- StartConfigurationMode(base::Closure()); |
- data_->session_context()->set_routing_info(routing_info); |
- data_->scheduler()->Configure(types, GetSourceFromReason(reason)); |
+ DCHECK(!ready_task.is_null()); |
+ DCHECK(!retry_task.is_null()); |
+ |
+ // TODO(zea): set this based on whether cryptographer has keystore |
+ // encryption key or not (requires opening a transaction). |
+ bool need_encryption_key = false; |
+ |
+ ConfigureParams params(GetSourceFromReason(reason), |
+ types_to_config, |
+ new_routing_info, |
+ need_encryption_key, |
+ ready_task); |
+ |
+ // Returns false if a retry has been scheduled. Either way, will invoke the |
+ // ready task when the configure job completes. |
+ if (!DoConfigureSyncer(params)) |
+ retry_task.Run(); |
} |
-void SyncManager::StartConfigurationMode(const base::Closure& callback) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+bool SyncManager::DoConfigureSyncer(const ConfigureParams& params) { |
if (!data_->scheduler()) { |
LOG(INFO) |
- << "SyncManager::StartConfigurationMode: could not start " |
- << "configuration mode because because scheduler is null"; |
- return; |
+ << "SyncManager::DoConfigureSyncer: could not configure because " |
+ << "scheduler is null"; |
+ params.ready_task.Run(); |
+ return true; |
} |
- data_->scheduler()->Start( |
- browser_sync::SyncScheduler::CONFIGURATION_MODE, callback); |
+ |
+ data_->scheduler()->Start(SyncScheduler::CONFIGURATION_MODE); |
+ return data_->scheduler()->Configure(params); |
} |
bool SyncManager::SyncInternal::Init( |
@@ -966,8 +970,7 @@ bool SyncManager::SyncInternal::Init( |
if (signed_in) { |
if (scheduler()) { |
- scheduler()->Start( |
- browser_sync::SyncScheduler::CONFIGURATION_MODE, base::Closure()); |
+ scheduler()->Start(SyncScheduler::CONFIGURATION_MODE); |
} |
initialized_ = true; |
@@ -1141,9 +1144,10 @@ void SyncManager::SyncInternal::NotifyCryptographerState( |
void SyncManager::SyncInternal::StartSyncingNormally( |
const browser_sync::ModelSafeRoutingInfo& routing_info) { |
// Start the sync scheduler. |
- if (scheduler()) { // NULL during certain unittests. |
+ if (scheduler()) { // NULL during certain unittests. |
+ // TODO(sync): pass this into the scheduler somehow. |
rlarocque
2012/06/12 17:45:13
What is 'this' referring to?
Nicolas Zea
2012/06/12 20:44:44
This comment has been updated in the newer patch.
|
session_context()->set_routing_info(routing_info); |
- scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure()); |
+ scheduler()->Start(SyncScheduler::NORMAL_MODE); |
} |
} |