| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // | |
| 5 // InternalComponentsFactory exists so that tests can override creation of | |
| 6 // components used by the SyncManager that are not exposed across the sync | |
| 7 // API boundary. | |
| 8 | 4 |
| 9 #ifndef COMPONENTS_SYNC_CORE_INTERNAL_COMPONENTS_FACTORY_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_ENGINE_COMPONENTS_FACTORY_H_ |
| 10 #define COMPONENTS_SYNC_CORE_INTERNAL_COMPONENTS_FACTORY_H_ | 6 #define COMPONENTS_SYNC_ENGINE_ENGINE_COMPONENTS_FACTORY_H_ |
| 11 | 7 |
| 12 #include <memory> | 8 #include <memory> |
| 13 #include <string> | 9 #include <string> |
| 14 #include <vector> | 10 #include <vector> |
| 15 | 11 |
| 16 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 17 #include "components/sync/engine/model_safe_worker.h" | 13 #include "components/sync/engine/model_safe_worker.h" |
| 18 | 14 |
| 19 namespace syncer { | 15 namespace syncer { |
| 20 | 16 |
| 21 class CancelationSignal; | 17 class CancelationSignal; |
| 22 class DebugInfoGetter; | 18 class DebugInfoGetter; |
| 23 class ExtensionsActivity; | 19 class ExtensionsActivity; |
| 24 class ModelTypeRegistry; | 20 class ModelTypeRegistry; |
| 25 class ServerConnectionManager; | 21 class ServerConnectionManager; |
| 26 class SyncCycleContext; | 22 class SyncCycleContext; |
| 27 class SyncEngineEventListener; | 23 class SyncEngineEventListener; |
| 28 class SyncScheduler; | 24 class SyncScheduler; |
| 29 | 25 |
| 30 namespace syncable { | 26 namespace syncable { |
| 31 class Directory; | 27 class Directory; |
| 32 class DirectoryBackingStore; | 28 class DirectoryBackingStore; |
| 33 } | 29 } |
| 34 | 30 |
| 35 class InternalComponentsFactory { | 31 // EngineComponentsFactory exists so that tests can override creation of |
| 32 // components used by the SyncManager and other things inside engine/. |
| 33 class EngineComponentsFactory { |
| 36 public: | 34 public: |
| 37 enum EncryptionMethod { | 35 enum EncryptionMethod { |
| 38 ENCRYPTION_LEGACY, | 36 ENCRYPTION_LEGACY, |
| 39 // Option to enable support for keystore key based encryption. | 37 // Option to enable support for keystore key based encryption. |
| 40 ENCRYPTION_KEYSTORE | 38 ENCRYPTION_KEYSTORE |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 enum BackoffOverride { | 41 enum BackoffOverride { |
| 44 BACKOFF_NORMAL, | 42 BACKOFF_NORMAL, |
| 45 // Use this value for integration testing to avoid long delays / | 43 // Use this value for integration testing to avoid long delays / |
| 46 // timing out tests. Uses kInitialBackoffShortRetrySeconds (see | 44 // timing out tests. Uses kInitialBackoffShortRetrySeconds (see |
| 47 // polling_constants.h) for all initial retries. | 45 // polling_constants.h) for all initial retries. |
| 48 BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE | 46 BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE |
| 49 }; | 47 }; |
| 50 | 48 |
| 51 enum PreCommitUpdatesPolicy { | 49 enum PreCommitUpdatesPolicy { |
| 52 // By default, the server will enable or disable this experiment through the | 50 // By default, the server will enable or disable this experiment through the |
| 53 // sync protocol's experiments data type. | 51 // sync protocol's experiments data type. |
| 54 SERVER_CONTROLLED_PRE_COMMIT_UPDATE_AVOIANCE, | 52 SERVER_CONTROLLED_PRE_COMMIT_UPDATE_AVOIANCE, |
| 55 | 53 |
| 56 // This flag overrides the server's decision and enables the pre-commit | 54 // This flag overrides the server's decision and enables the pre-commit |
| 57 // update avoidance experiment. | 55 // update avoidance experiment. |
| 58 FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE, | 56 FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE, |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 // Configuration options for internal components. This struct is expected | 59 // Configuration options for internal components. This struct is expected |
| 62 // to grow and shrink over time with transient features / experiments, | 60 // to grow and shrink over time with transient features / experiments, |
| 63 // roughly following command line flags in chrome. Implementations of | 61 // roughly following command line flags in chrome. Implementations of |
| 64 // InternalComponentsFactory can use this information to build components | 62 // EngineComponentsFactory can use this information to build components |
| 65 // with appropriate bells and whistles. | 63 // with appropriate bells and whistles. |
| 66 struct Switches { | 64 struct Switches { |
| 67 EncryptionMethod encryption_method; | 65 EncryptionMethod encryption_method; |
| 68 BackoffOverride backoff_override; | 66 BackoffOverride backoff_override; |
| 69 PreCommitUpdatesPolicy pre_commit_updates_policy; | 67 PreCommitUpdatesPolicy pre_commit_updates_policy; |
| 70 }; | 68 }; |
| 71 | 69 |
| 72 // For selecting the types of storage to use to persist sync data when | 70 // For selecting the types of storage to use to persist sync data when |
| 73 // BuildDirectoryBackingStore() is called. | 71 // BuildDirectoryBackingStore() is called. |
| 74 enum StorageOption { | 72 enum StorageOption { |
| 75 // BuildDirectoryBackingStore should not use persistent on-disk storage. | 73 // BuildDirectoryBackingStore should not use persistent on-disk storage. |
| 76 STORAGE_IN_MEMORY, | 74 STORAGE_IN_MEMORY, |
| 77 // Use this if you want BuildDirectoryBackingStore to create/use a real | 75 // Use this if you want BuildDirectoryBackingStore to create/use a real |
| 78 // on disk store. | 76 // on disk store. |
| 79 STORAGE_ON_DISK, | 77 STORAGE_ON_DISK, |
| 80 // Use this to test the case where a directory fails to load. | 78 // Use this to test the case where a directory fails to load. |
| 81 STORAGE_INVALID | 79 STORAGE_INVALID |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 virtual ~InternalComponentsFactory() {} | 82 virtual ~EngineComponentsFactory() {} |
| 85 | 83 |
| 86 virtual std::unique_ptr<SyncScheduler> BuildScheduler( | 84 virtual std::unique_ptr<SyncScheduler> BuildScheduler( |
| 87 const std::string& name, | 85 const std::string& name, |
| 88 SyncCycleContext* context, | 86 SyncCycleContext* context, |
| 89 CancelationSignal* cancelation_signal) = 0; | 87 CancelationSignal* cancelation_signal) = 0; |
| 90 | 88 |
| 91 virtual std::unique_ptr<SyncCycleContext> BuildContext( | 89 virtual std::unique_ptr<SyncCycleContext> BuildContext( |
| 92 ServerConnectionManager* connection_manager, | 90 ServerConnectionManager* connection_manager, |
| 93 syncable::Directory* directory, | 91 syncable::Directory* directory, |
| 94 ExtensionsActivity* extensions_activity, | 92 ExtensionsActivity* extensions_activity, |
| 95 const std::vector<SyncEngineEventListener*>& listeners, | 93 const std::vector<SyncEngineEventListener*>& listeners, |
| 96 DebugInfoGetter* debug_info_getter, | 94 DebugInfoGetter* debug_info_getter, |
| 97 ModelTypeRegistry* model_type_registry, | 95 ModelTypeRegistry* model_type_registry, |
| 98 const std::string& invalidator_client_id) = 0; | 96 const std::string& invalidator_client_id) = 0; |
| 99 | 97 |
| 100 virtual std::unique_ptr<syncable::DirectoryBackingStore> | 98 virtual std::unique_ptr<syncable::DirectoryBackingStore> |
| 101 BuildDirectoryBackingStore(StorageOption storage, | 99 BuildDirectoryBackingStore(StorageOption storage, |
| 102 const std::string& dir_name, | 100 const std::string& dir_name, |
| 103 const base::FilePath& backing_filepath) = 0; | 101 const base::FilePath& backing_filepath) = 0; |
| 104 | 102 |
| 105 // Returns the Switches struct that this object is using as configuration, if | 103 // Returns the Switches struct that this object is using as configuration, if |
| 106 // the implementation is making use of one. | 104 // the implementation is making use of one. |
| 107 virtual Switches GetSwitches() const = 0; | 105 virtual Switches GetSwitches() const = 0; |
| 108 }; | 106 }; |
| 109 | 107 |
| 110 } // namespace syncer | 108 } // namespace syncer |
| 111 | 109 |
| 112 #endif // COMPONENTS_SYNC_CORE_INTERNAL_COMPONENTS_FACTORY_H_ | 110 #endif // COMPONENTS_SYNC_ENGINE_ENGINE_COMPONENTS_FACTORY_H_ |
| OLD | NEW |