| 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 "sync/internal_api/public/test/test_internal_components_factory.h" | 5 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 6 | 6 |
| 7 #include "sync/sessions/sync_session_context.h" | 7 #include "sync/sessions/sync_session_context.h" |
| 8 #include "sync/syncable/deferred_on_disk_directory_backing_store.h" | |
| 9 #include "sync/syncable/in_memory_directory_backing_store.h" | 8 #include "sync/syncable/in_memory_directory_backing_store.h" |
| 10 #include "sync/syncable/on_disk_directory_backing_store.h" | 9 #include "sync/syncable/on_disk_directory_backing_store.h" |
| 11 #include "sync/syncable/invalid_directory_backing_store.h" | 10 #include "sync/syncable/invalid_directory_backing_store.h" |
| 12 #include "sync/test/engine/fake_sync_scheduler.h" | 11 #include "sync/test/engine/fake_sync_scheduler.h" |
| 13 | 12 |
| 14 namespace syncer { | 13 namespace syncer { |
| 15 | 14 |
| 16 TestInternalComponentsFactory::TestInternalComponentsFactory( | 15 TestInternalComponentsFactory::TestInternalComponentsFactory( |
| 17 const Switches& switches, | 16 const Switches& switches, |
| 18 StorageOption option, | 17 StorageOption option) |
| 19 StorageOption* storage_used) | |
| 20 : switches_(switches), | 18 : switches_(switches), |
| 21 storage_override_(option), | 19 storage_option_(option) { |
| 22 storage_used_(storage_used) { | |
| 23 } | 20 } |
| 24 | 21 |
| 25 TestInternalComponentsFactory::~TestInternalComponentsFactory() { } | 22 TestInternalComponentsFactory::~TestInternalComponentsFactory() { } |
| 26 | 23 |
| 27 scoped_ptr<SyncScheduler> TestInternalComponentsFactory::BuildScheduler( | 24 scoped_ptr<SyncScheduler> TestInternalComponentsFactory::BuildScheduler( |
| 28 const std::string& name, | 25 const std::string& name, |
| 29 sessions::SyncSessionContext* context, | 26 sessions::SyncSessionContext* context, |
| 30 syncer::CancelationSignal* cancelation_signal) { | 27 syncer::CancelationSignal* cancelation_signal) { |
| 31 return scoped_ptr<SyncScheduler>(new FakeSyncScheduler()); | 28 return scoped_ptr<SyncScheduler>(new FakeSyncScheduler()); |
| 32 } | 29 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 50 model_type_registry, | 47 model_type_registry, |
| 51 switches_.encryption_method == ENCRYPTION_KEYSTORE, | 48 switches_.encryption_method == ENCRYPTION_KEYSTORE, |
| 52 switches_.pre_commit_updates_policy == | 49 switches_.pre_commit_updates_policy == |
| 53 FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE, | 50 FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE, |
| 54 invalidator_client_id)); | 51 invalidator_client_id)); |
| 55 | 52 |
| 56 } | 53 } |
| 57 | 54 |
| 58 scoped_ptr<syncable::DirectoryBackingStore> | 55 scoped_ptr<syncable::DirectoryBackingStore> |
| 59 TestInternalComponentsFactory::BuildDirectoryBackingStore( | 56 TestInternalComponentsFactory::BuildDirectoryBackingStore( |
| 60 StorageOption storage, const std::string& dir_name, | 57 const std::string& dir_name, const base::FilePath& backing_filepath) { |
| 61 const base::FilePath& backing_filepath) { | 58 switch (storage_option_) { |
| 62 if (storage_used_) | |
| 63 *storage_used_ = storage; | |
| 64 | |
| 65 switch (storage_override_) { | |
| 66 case STORAGE_IN_MEMORY: | 59 case STORAGE_IN_MEMORY: |
| 67 return scoped_ptr<syncable::DirectoryBackingStore>( | 60 return scoped_ptr<syncable::DirectoryBackingStore>( |
| 68 new syncable::InMemoryDirectoryBackingStore(dir_name)); | 61 new syncable::InMemoryDirectoryBackingStore(dir_name)); |
| 69 case STORAGE_ON_DISK: | 62 case STORAGE_ON_DISK: |
| 70 return scoped_ptr<syncable::DirectoryBackingStore>( | 63 return scoped_ptr<syncable::DirectoryBackingStore>( |
| 71 new syncable::OnDiskDirectoryBackingStore(dir_name, | 64 new syncable::OnDiskDirectoryBackingStore(dir_name, |
| 72 backing_filepath)); | 65 backing_filepath)); |
| 73 case STORAGE_ON_DISK_DEFERRED: | |
| 74 return scoped_ptr<syncable::DirectoryBackingStore>( | |
| 75 new syncable::DeferredOnDiskDirectoryBackingStore(dir_name, | |
| 76 backing_filepath)); | |
| 77 case STORAGE_INVALID: | 66 case STORAGE_INVALID: |
| 78 return scoped_ptr<syncable::DirectoryBackingStore>( | 67 return scoped_ptr<syncable::DirectoryBackingStore>( |
| 79 new syncable::InvalidDirectoryBackingStore()); | 68 new syncable::InvalidDirectoryBackingStore()); |
| 80 } | 69 } |
| 81 NOTREACHED(); | 70 NOTREACHED(); |
| 82 return scoped_ptr<syncable::DirectoryBackingStore>(); | 71 return scoped_ptr<syncable::DirectoryBackingStore>(); |
| 83 } | 72 } |
| 84 | 73 |
| 85 InternalComponentsFactory::Switches | 74 InternalComponentsFactory::Switches |
| 86 TestInternalComponentsFactory::GetSwitches() const { | 75 TestInternalComponentsFactory::GetSwitches() const { |
| 87 return switches_; | 76 return switches_; |
| 88 } | 77 } |
| 89 | 78 |
| 90 } // namespace syncer | 79 } // namespace syncer |
| OLD | NEW |