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