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