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