| 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/core/internal_components_factory_impl.h" | 5 #include "components/sync/core/internal_components_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "components/sync/engine_impl/backoff_delay_provider.h" | 10 #include "components/sync/engine_impl/backoff_delay_provider.h" |
| 11 #include "components/sync/engine_impl/cycle/sync_cycle_context.h" |
| 11 #include "components/sync/engine_impl/sync_scheduler_impl.h" | 12 #include "components/sync/engine_impl/sync_scheduler_impl.h" |
| 12 #include "components/sync/engine_impl/syncer.h" | 13 #include "components/sync/engine_impl/syncer.h" |
| 13 #include "components/sync/sessions_impl/sync_session_context.h" | |
| 14 #include "components/sync/syncable/on_disk_directory_backing_store.h" | 14 #include "components/sync/syncable/on_disk_directory_backing_store.h" |
| 15 | 15 |
| 16 using base::TimeDelta; | 16 using base::TimeDelta; |
| 17 | 17 |
| 18 namespace syncer { | 18 namespace syncer { |
| 19 | 19 |
| 20 InternalComponentsFactoryImpl::InternalComponentsFactoryImpl( | 20 InternalComponentsFactoryImpl::InternalComponentsFactoryImpl( |
| 21 const Switches& switches) | 21 const Switches& switches) |
| 22 : switches_(switches) {} | 22 : switches_(switches) {} |
| 23 | 23 |
| 24 InternalComponentsFactoryImpl::~InternalComponentsFactoryImpl() {} | 24 InternalComponentsFactoryImpl::~InternalComponentsFactoryImpl() {} |
| 25 | 25 |
| 26 std::unique_ptr<SyncScheduler> InternalComponentsFactoryImpl::BuildScheduler( | 26 std::unique_ptr<SyncScheduler> InternalComponentsFactoryImpl::BuildScheduler( |
| 27 const std::string& name, | 27 const std::string& name, |
| 28 sessions::SyncSessionContext* context, | 28 SyncCycleContext* context, |
| 29 CancelationSignal* cancelation_signal) { | 29 CancelationSignal* cancelation_signal) { |
| 30 std::unique_ptr<BackoffDelayProvider> delay( | 30 std::unique_ptr<BackoffDelayProvider> delay( |
| 31 BackoffDelayProvider::FromDefaults()); | 31 BackoffDelayProvider::FromDefaults()); |
| 32 | 32 |
| 33 if (switches_.backoff_override == BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE) | 33 if (switches_.backoff_override == BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE) |
| 34 delay.reset(BackoffDelayProvider::WithShortInitialRetryOverride()); | 34 delay.reset(BackoffDelayProvider::WithShortInitialRetryOverride()); |
| 35 | 35 |
| 36 return std::unique_ptr<SyncScheduler>(new SyncSchedulerImpl( | 36 return std::unique_ptr<SyncScheduler>(new SyncSchedulerImpl( |
| 37 name, delay.release(), context, new Syncer(cancelation_signal))); | 37 name, delay.release(), context, new Syncer(cancelation_signal))); |
| 38 } | 38 } |
| 39 | 39 |
| 40 std::unique_ptr<sessions::SyncSessionContext> | 40 std::unique_ptr<SyncCycleContext> InternalComponentsFactoryImpl::BuildContext( |
| 41 InternalComponentsFactoryImpl::BuildContext( | |
| 42 ServerConnectionManager* connection_manager, | 41 ServerConnectionManager* connection_manager, |
| 43 syncable::Directory* directory, | 42 syncable::Directory* directory, |
| 44 ExtensionsActivity* extensions_activity, | 43 ExtensionsActivity* extensions_activity, |
| 45 const std::vector<SyncEngineEventListener*>& listeners, | 44 const std::vector<SyncEngineEventListener*>& listeners, |
| 46 sessions::DebugInfoGetter* debug_info_getter, | 45 DebugInfoGetter* debug_info_getter, |
| 47 ModelTypeRegistry* model_type_registry, | 46 ModelTypeRegistry* model_type_registry, |
| 48 const std::string& invalidation_client_id) { | 47 const std::string& invalidation_client_id) { |
| 49 return std::unique_ptr<sessions::SyncSessionContext>( | 48 return std::unique_ptr<SyncCycleContext>( |
| 50 new sessions::SyncSessionContext( | 49 new SyncCycleContext(connection_manager, directory, extensions_activity, |
| 51 connection_manager, directory, extensions_activity, listeners, | 50 listeners, debug_info_getter, model_type_registry, |
| 52 debug_info_getter, model_type_registry, | 51 switches_.encryption_method == ENCRYPTION_KEYSTORE, |
| 53 switches_.encryption_method == ENCRYPTION_KEYSTORE, | 52 switches_.pre_commit_updates_policy == |
| 54 switches_.pre_commit_updates_policy == | 53 FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE, |
| 55 FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE, | 54 invalidation_client_id)); |
| 56 invalidation_client_id)); | |
| 57 } | 55 } |
| 58 | 56 |
| 59 std::unique_ptr<syncable::DirectoryBackingStore> | 57 std::unique_ptr<syncable::DirectoryBackingStore> |
| 60 InternalComponentsFactoryImpl::BuildDirectoryBackingStore( | 58 InternalComponentsFactoryImpl::BuildDirectoryBackingStore( |
| 61 StorageOption storage, | 59 StorageOption storage, |
| 62 const std::string& dir_name, | 60 const std::string& dir_name, |
| 63 const base::FilePath& backing_filepath) { | 61 const base::FilePath& backing_filepath) { |
| 64 if (storage == STORAGE_ON_DISK) { | 62 if (storage == STORAGE_ON_DISK) { |
| 65 return std::unique_ptr<syncable::DirectoryBackingStore>( | 63 return std::unique_ptr<syncable::DirectoryBackingStore>( |
| 66 new syncable::OnDiskDirectoryBackingStore(dir_name, backing_filepath)); | 64 new syncable::OnDiskDirectoryBackingStore(dir_name, backing_filepath)); |
| 67 } else { | 65 } else { |
| 68 NOTREACHED(); | 66 NOTREACHED(); |
| 69 return std::unique_ptr<syncable::DirectoryBackingStore>(); | 67 return std::unique_ptr<syncable::DirectoryBackingStore>(); |
| 70 } | 68 } |
| 71 } | 69 } |
| 72 | 70 |
| 73 InternalComponentsFactory::Switches InternalComponentsFactoryImpl::GetSwitches() | 71 InternalComponentsFactory::Switches InternalComponentsFactoryImpl::GetSwitches() |
| 74 const { | 72 const { |
| 75 return switches_; | 73 return switches_; |
| 76 } | 74 } |
| 77 | 75 |
| 78 } // namespace syncer | 76 } // namespace syncer |
| OLD | NEW |