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