| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync/engine_impl/sync_manager_impl.h" | 5 #include "components/sync/engine_impl/sync_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 if (marker.token().empty()) | 176 if (marker.token().empty()) |
| 177 result.Put(i.Get()); | 177 result.Put(i.Get()); |
| 178 } | 178 } |
| 179 return result; | 179 return result; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void SyncManagerImpl::ConfigureSyncer( | 182 void SyncManagerImpl::ConfigureSyncer( |
| 183 ConfigureReason reason, | 183 ConfigureReason reason, |
| 184 ModelTypeSet to_download, | 184 ModelTypeSet to_download, |
| 185 const ModelSafeRoutingInfo& new_routing_info, | |
| 186 const base::Closure& ready_task, | 185 const base::Closure& ready_task, |
| 187 const base::Closure& retry_task) { | 186 const base::Closure& retry_task) { |
| 188 DCHECK(thread_checker_.CalledOnValidThread()); | 187 DCHECK(thread_checker_.CalledOnValidThread()); |
| 189 DCHECK(!ready_task.is_null()); | 188 DCHECK(!ready_task.is_null()); |
| 190 DCHECK(initialized_); | 189 DCHECK(initialized_); |
| 191 | 190 |
| 192 // Don't download non-blocking types that have already completed initial sync. | 191 // Don't download non-blocking types that have already completed initial sync. |
| 193 to_download.RemoveAll( | 192 to_download.RemoveAll( |
| 194 model_type_registry_->GetInitialSyncDoneNonBlockingTypes()); | 193 model_type_registry_->GetInitialSyncDoneNonBlockingTypes()); |
| 195 | 194 |
| 196 DVLOG(1) << "Configuring -" | 195 DVLOG(1) << "Configuring -" |
| 197 << "\n\t" | 196 << "\n\t" |
| 198 << "current types: " | |
| 199 << ModelTypeSetToString(GetRoutingInfoTypes(new_routing_info)) | |
| 200 << "\n\t" | |
| 201 << "types to download: " << ModelTypeSetToString(to_download); | 197 << "types to download: " << ModelTypeSetToString(to_download); |
| 202 ConfigurationParams params(GetSourceFromReason(reason), to_download, | 198 ConfigurationParams params(GetSourceFromReason(reason), to_download, |
| 203 new_routing_info, ready_task, retry_task); | 199 ready_task, retry_task); |
| 204 | 200 |
| 205 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); | 201 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
| 206 scheduler_->ScheduleConfiguration(params); | 202 scheduler_->ScheduleConfiguration(params); |
| 207 } | 203 } |
| 208 | 204 |
| 209 void SyncManagerImpl::Init(InitArgs* args) { | 205 void SyncManagerImpl::Init(InitArgs* args) { |
| 210 CHECK(!initialized_); | 206 CHECK(!initialized_); |
| 211 DCHECK(thread_checker_.CalledOnValidThread()); | 207 DCHECK(thread_checker_.CalledOnValidThread()); |
| 212 DCHECK(args->post_factory.get()); | 208 DCHECK(args->post_factory.get()); |
| 213 if (!args->enable_local_sync_backend) { | 209 if (!args->enable_local_sync_backend) { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 base::Time explicit_passphrase_time) { | 385 base::Time explicit_passphrase_time) { |
| 390 allstatus_.SetPassphraseType(type); | 386 allstatus_.SetPassphraseType(type); |
| 391 allstatus_.SetKeystoreMigrationTime( | 387 allstatus_.SetKeystoreMigrationTime( |
| 392 sync_encryption_handler_->migration_time()); | 388 sync_encryption_handler_->migration_time()); |
| 393 } | 389 } |
| 394 | 390 |
| 395 void SyncManagerImpl::OnLocalSetPassphraseEncryption( | 391 void SyncManagerImpl::OnLocalSetPassphraseEncryption( |
| 396 const SyncEncryptionHandler::NigoriState& nigori_state) {} | 392 const SyncEncryptionHandler::NigoriState& nigori_state) {} |
| 397 | 393 |
| 398 void SyncManagerImpl::StartSyncingNormally( | 394 void SyncManagerImpl::StartSyncingNormally( |
| 399 const ModelSafeRoutingInfo& routing_info, | |
| 400 base::Time last_poll_time) { | 395 base::Time last_poll_time) { |
| 401 // Start the sync scheduler. | 396 // Start the sync scheduler. |
| 402 // TODO(sync): We always want the newest set of routes when we switch back | |
| 403 // to normal mode. Figure out how to enforce set_routing_info is always | |
| 404 // appropriately set and that it's only modified when switching to normal | |
| 405 // mode. | |
| 406 DCHECK(thread_checker_.CalledOnValidThread()); | 397 DCHECK(thread_checker_.CalledOnValidThread()); |
| 407 cycle_context_->SetRoutingInfo(routing_info); | |
| 408 scheduler_->Start(SyncScheduler::NORMAL_MODE, last_poll_time); | 398 scheduler_->Start(SyncScheduler::NORMAL_MODE, last_poll_time); |
| 409 } | 399 } |
| 410 | 400 |
| 401 void SyncManagerImpl::StartConfiguration() { |
| 402 DCHECK(thread_checker_.CalledOnValidThread()); |
| 403 scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); |
| 404 } |
| 405 |
| 411 syncable::Directory* SyncManagerImpl::directory() { | 406 syncable::Directory* SyncManagerImpl::directory() { |
| 412 return share_.directory.get(); | 407 return share_.directory.get(); |
| 413 } | 408 } |
| 414 | 409 |
| 415 const SyncScheduler* SyncManagerImpl::scheduler() const { | 410 const SyncScheduler* SyncManagerImpl::scheduler() const { |
| 416 return scheduler_.get(); | 411 return scheduler_.get(); |
| 417 } | 412 } |
| 418 | 413 |
| 419 bool SyncManagerImpl::GetHasInvalidAuthTokenForTest() const { | 414 bool SyncManagerImpl::GetHasInvalidAuthTokenForTest() const { |
| 420 return connection_manager_->HasInvalidAuthToken(); | 415 return connection_manager_->HasInvalidAuthToken(); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 | 894 |
| 900 void SyncManagerImpl::SaveChanges() { | 895 void SyncManagerImpl::SaveChanges() { |
| 901 directory()->SaveChanges(); | 896 directory()->SaveChanges(); |
| 902 } | 897 } |
| 903 | 898 |
| 904 UserShare* SyncManagerImpl::GetUserShare() { | 899 UserShare* SyncManagerImpl::GetUserShare() { |
| 905 DCHECK(initialized_); | 900 DCHECK(initialized_); |
| 906 return &share_; | 901 return &share_; |
| 907 } | 902 } |
| 908 | 903 |
| 904 ModelTypeConnector* SyncManagerImpl::GetModelTypeConnector() { |
| 905 DCHECK(thread_checker_.CalledOnValidThread()); |
| 906 return model_type_registry_.get(); |
| 907 } |
| 908 |
| 909 std::unique_ptr<ModelTypeConnector> | 909 std::unique_ptr<ModelTypeConnector> |
| 910 SyncManagerImpl::GetModelTypeConnectorProxy() { | 910 SyncManagerImpl::GetModelTypeConnectorProxy() { |
| 911 DCHECK(initialized_); | 911 DCHECK(initialized_); |
| 912 return base::MakeUnique<ModelTypeConnectorProxy>( | 912 return base::MakeUnique<ModelTypeConnectorProxy>( |
| 913 base::ThreadTaskRunnerHandle::Get(), model_type_registry_->AsWeakPtr()); | 913 base::ThreadTaskRunnerHandle::Get(), model_type_registry_->AsWeakPtr()); |
| 914 } | 914 } |
| 915 | 915 |
| 916 const std::string SyncManagerImpl::cache_guid() { | 916 const std::string SyncManagerImpl::cache_guid() { |
| 917 DCHECK(initialized_); | 917 DCHECK(initialized_); |
| 918 return directory()->cache_guid(); | 918 return directory()->cache_guid(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 DCHECK(thread_checker_.CalledOnValidThread()); | 1007 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1008 cycle_context_->set_cookie_jar_mismatch(account_mismatch); | 1008 cycle_context_->set_cookie_jar_mismatch(account_mismatch); |
| 1009 cycle_context_->set_cookie_jar_empty(empty_jar); | 1009 cycle_context_->set_cookie_jar_empty(empty_jar); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 void SyncManagerImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { | 1012 void SyncManagerImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { |
| 1013 directory()->OnMemoryDump(pmd); | 1013 directory()->OnMemoryDump(pmd); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 } // namespace syncer | 1016 } // namespace syncer |
| OLD | NEW |