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