| 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 "components/sync/core/test/test_internal_components_factory.h" | |
| 6 | |
| 7 #include "components/sync/engine_impl/cycle/sync_cycle_context.h" | |
| 8 #include "components/sync/syncable/in_memory_directory_backing_store.h" | |
| 9 #include "components/sync/syncable/invalid_directory_backing_store.h" | |
| 10 #include "components/sync/syncable/on_disk_directory_backing_store.h" | |
| 11 #include "components/sync/test/engine/fake_sync_scheduler.h" | |
| 12 | |
| 13 namespace syncer { | |
| 14 | |
| 15 TestInternalComponentsFactory::TestInternalComponentsFactory( | |
| 16 const Switches& switches, | |
| 17 StorageOption option, | |
| 18 StorageOption* storage_used) | |
| 19 : switches_(switches), | |
| 20 storage_override_(option), | |
| 21 storage_used_(storage_used) {} | |
| 22 | |
| 23 TestInternalComponentsFactory::~TestInternalComponentsFactory() {} | |
| 24 | |
| 25 std::unique_ptr<SyncScheduler> TestInternalComponentsFactory::BuildScheduler( | |
| 26 const std::string& name, | |
| 27 SyncCycleContext* context, | |
| 28 CancelationSignal* cancelation_signal) { | |
| 29 return std::unique_ptr<SyncScheduler>(new FakeSyncScheduler()); | |
| 30 } | |
| 31 | |
| 32 std::unique_ptr<SyncCycleContext> TestInternalComponentsFactory::BuildContext( | |
| 33 ServerConnectionManager* connection_manager, | |
| 34 syncable::Directory* directory, | |
| 35 ExtensionsActivity* monitor, | |
| 36 const std::vector<SyncEngineEventListener*>& listeners, | |
| 37 DebugInfoGetter* debug_info_getter, | |
| 38 ModelTypeRegistry* model_type_registry, | |
| 39 const std::string& invalidator_client_id) { | |
| 40 // Tests don't wire up listeners. | |
| 41 std::vector<SyncEngineEventListener*> empty_listeners; | |
| 42 return std::unique_ptr<SyncCycleContext>(new SyncCycleContext( | |
| 43 connection_manager, directory, monitor, empty_listeners, | |
| 44 debug_info_getter, model_type_registry, | |
| 45 switches_.encryption_method == ENCRYPTION_KEYSTORE, | |
| 46 switches_.pre_commit_updates_policy == | |
| 47 FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE, | |
| 48 invalidator_client_id)); | |
| 49 } | |
| 50 | |
| 51 std::unique_ptr<syncable::DirectoryBackingStore> | |
| 52 TestInternalComponentsFactory::BuildDirectoryBackingStore( | |
| 53 StorageOption storage, | |
| 54 const std::string& dir_name, | |
| 55 const base::FilePath& backing_filepath) { | |
| 56 if (storage_used_) | |
| 57 *storage_used_ = storage; | |
| 58 | |
| 59 switch (storage_override_) { | |
| 60 case STORAGE_IN_MEMORY: | |
| 61 return std::unique_ptr<syncable::DirectoryBackingStore>( | |
| 62 new syncable::InMemoryDirectoryBackingStore(dir_name)); | |
| 63 case STORAGE_ON_DISK: | |
| 64 return std::unique_ptr<syncable::DirectoryBackingStore>( | |
| 65 new syncable::OnDiskDirectoryBackingStore(dir_name, | |
| 66 backing_filepath)); | |
| 67 case STORAGE_INVALID: | |
| 68 return std::unique_ptr<syncable::DirectoryBackingStore>( | |
| 69 new syncable::InvalidDirectoryBackingStore()); | |
| 70 } | |
| 71 NOTREACHED(); | |
| 72 return std::unique_ptr<syncable::DirectoryBackingStore>(); | |
| 73 } | |
| 74 | |
| 75 InternalComponentsFactory::Switches TestInternalComponentsFactory::GetSwitches() | |
| 76 const { | |
| 77 return switches_; | |
| 78 } | |
| 79 | |
| 80 } // namespace syncer | |
| OLD | NEW |