| 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/in_memory_directory_backing_store.h" | 8 #include "sync/syncable/in_memory_directory_backing_store.h" |
| 9 #include "sync/syncable/on_disk_directory_backing_store.h" | 9 #include "sync/syncable/on_disk_directory_backing_store.h" |
| 10 #include "sync/syncable/invalid_directory_backing_store.h" | 10 #include "sync/syncable/invalid_directory_backing_store.h" |
| 11 #include "sync/test/engine/fake_sync_scheduler.h" | 11 #include "sync/test/engine/fake_sync_scheduler.h" |
| 12 | 12 |
| 13 namespace syncer { | 13 namespace syncer { |
| 14 | 14 |
| 15 TestInternalComponentsFactory::TestInternalComponentsFactory( | 15 TestInternalComponentsFactory::TestInternalComponentsFactory( |
| 16 const Switches& switches, |
| 16 StorageOption option) | 17 StorageOption option) |
| 17 : storage_option_(option) { | 18 : switches_(switches), |
| 19 storage_option_(option) { |
| 18 } | 20 } |
| 19 | 21 |
| 20 TestInternalComponentsFactory::~TestInternalComponentsFactory() { } | 22 TestInternalComponentsFactory::~TestInternalComponentsFactory() { } |
| 21 | 23 |
| 22 scoped_ptr<SyncScheduler> TestInternalComponentsFactory::BuildScheduler( | 24 scoped_ptr<SyncScheduler> TestInternalComponentsFactory::BuildScheduler( |
| 23 const std::string& name, sessions::SyncSessionContext* context) { | 25 const std::string& name, sessions::SyncSessionContext* context) { |
| 24 return scoped_ptr<SyncScheduler>(new FakeSyncScheduler()); | 26 return scoped_ptr<SyncScheduler>(new FakeSyncScheduler()); |
| 25 } | 27 } |
| 26 | 28 |
| 27 scoped_ptr<sessions::SyncSessionContext> | 29 scoped_ptr<sessions::SyncSessionContext> |
| 28 TestInternalComponentsFactory::BuildContext( | 30 TestInternalComponentsFactory::BuildContext( |
| 29 ServerConnectionManager* connection_manager, | 31 ServerConnectionManager* connection_manager, |
| 30 syncable::Directory* directory, | 32 syncable::Directory* directory, |
| 31 const std::vector<ModelSafeWorker*> workers, | 33 const std::vector<ModelSafeWorker*> workers, |
| 32 ExtensionsActivityMonitor* monitor, | 34 ExtensionsActivityMonitor* monitor, |
| 33 ThrottledDataTypeTracker* throttled_data_type_tracker, | 35 ThrottledDataTypeTracker* throttled_data_type_tracker, |
| 34 const std::vector<SyncEngineEventListener*>& listeners, | 36 const std::vector<SyncEngineEventListener*>& listeners, |
| 35 sessions::DebugInfoGetter* debug_info_getter, | 37 sessions::DebugInfoGetter* debug_info_getter, |
| 36 TrafficRecorder* traffic_recorder, | 38 TrafficRecorder* traffic_recorder) { |
| 37 bool keystore_encryption_enabled) { | |
| 38 | 39 |
| 39 // Tests don't wire up listeners. | 40 // Tests don't wire up listeners. |
| 40 std::vector<SyncEngineEventListener*> empty_listeners; | 41 std::vector<SyncEngineEventListener*> empty_listeners; |
| 41 return scoped_ptr<sessions::SyncSessionContext>( | 42 return scoped_ptr<sessions::SyncSessionContext>( |
| 42 new sessions::SyncSessionContext( | 43 new sessions::SyncSessionContext( |
| 43 connection_manager, directory, workers, monitor, | 44 connection_manager, directory, workers, monitor, |
| 44 throttled_data_type_tracker, empty_listeners, debug_info_getter, | 45 throttled_data_type_tracker, empty_listeners, debug_info_getter, |
| 45 traffic_recorder, | 46 traffic_recorder, |
| 46 keystore_encryption_enabled)); | 47 switches_.encryption_method == ENCRYPTION_KEYSTORE)); |
| 47 | 48 |
| 48 } | 49 } |
| 49 | 50 |
| 50 scoped_ptr<syncable::DirectoryBackingStore> | 51 scoped_ptr<syncable::DirectoryBackingStore> |
| 51 TestInternalComponentsFactory::BuildDirectoryBackingStore( | 52 TestInternalComponentsFactory::BuildDirectoryBackingStore( |
| 52 const std::string& dir_name, const FilePath& backing_filepath) { | 53 const std::string& dir_name, const FilePath& backing_filepath) { |
| 53 switch (storage_option_) { | 54 switch (storage_option_) { |
| 54 case STORAGE_IN_MEMORY: | 55 case STORAGE_IN_MEMORY: |
| 55 return scoped_ptr<syncable::DirectoryBackingStore>( | 56 return scoped_ptr<syncable::DirectoryBackingStore>( |
| 56 new syncable::InMemoryDirectoryBackingStore(dir_name)); | 57 new syncable::InMemoryDirectoryBackingStore(dir_name)); |
| 57 case STORAGE_ON_DISK: | 58 case STORAGE_ON_DISK: |
| 58 return scoped_ptr<syncable::DirectoryBackingStore>( | 59 return scoped_ptr<syncable::DirectoryBackingStore>( |
| 59 new syncable::OnDiskDirectoryBackingStore(dir_name, | 60 new syncable::OnDiskDirectoryBackingStore(dir_name, |
| 60 backing_filepath)); | 61 backing_filepath)); |
| 61 case STORAGE_INVALID: | 62 case STORAGE_INVALID: |
| 62 return scoped_ptr<syncable::DirectoryBackingStore>( | 63 return scoped_ptr<syncable::DirectoryBackingStore>( |
| 63 new syncable::InvalidDirectoryBackingStore()); | 64 new syncable::InvalidDirectoryBackingStore()); |
| 64 } | 65 } |
| 65 NOTREACHED(); | 66 NOTREACHED(); |
| 66 return scoped_ptr<syncable::DirectoryBackingStore>(); | 67 return scoped_ptr<syncable::DirectoryBackingStore>(); |
| 67 } | 68 } |
| 68 | 69 |
| 70 InternalComponentsFactory::Switches |
| 71 TestInternalComponentsFactory::GetSwitches() const { |
| 72 return switches_; |
| 73 } |
| 74 |
| 69 } // namespace syncer | 75 } // namespace syncer |
| OLD | NEW |