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 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // local sync repository (i.e. the same sqlite database), they should share a | 44 // local sync repository (i.e. the same sqlite database), they should share a |
45 // single SyncManager instance. The caller should typically create one | 45 // single SyncManager instance. The caller should typically create one |
46 // SyncManager for the lifetime of a user session. | 46 // SyncManager for the lifetime of a user session. |
47 // | 47 // |
48 // Unless stated otherwise, all methods of SyncManager should be called on the | 48 // Unless stated otherwise, all methods of SyncManager should be called on the |
49 // same thread. | 49 // same thread. |
50 class SYNC_EXPORT_PRIVATE SyncManagerImpl : | 50 class SYNC_EXPORT_PRIVATE SyncManagerImpl : |
51 public SyncManager, | 51 public SyncManager, |
52 public net::NetworkChangeNotifier::IPAddressObserver, | 52 public net::NetworkChangeNotifier::IPAddressObserver, |
53 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 53 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
54 public InvalidationHandler, | |
55 public JsBackend, | 54 public JsBackend, |
56 public SyncEngineEventListener, | 55 public SyncEngineEventListener, |
57 public ServerConnectionEventListener, | 56 public ServerConnectionEventListener, |
58 public syncable::DirectoryChangeDelegate, | 57 public syncable::DirectoryChangeDelegate, |
59 public SyncEncryptionHandler::Observer { | 58 public SyncEncryptionHandler::Observer { |
60 public: | 59 public: |
61 // Create an uninitialized SyncManager. Callers must Init() before using. | 60 // Create an uninitialized SyncManager. Callers must Init() before using. |
62 explicit SyncManagerImpl(const std::string& name); | 61 explicit SyncManagerImpl(const std::string& name); |
63 virtual ~SyncManagerImpl(); | 62 virtual ~SyncManagerImpl(); |
64 | 63 |
65 // SyncManager implementation. | 64 // SyncManager implementation. |
66 virtual void Init( | 65 virtual void Init( |
67 const base::FilePath& database_location, | 66 const base::FilePath& database_location, |
68 const WeakHandle<JsEventHandler>& event_handler, | 67 const WeakHandle<JsEventHandler>& event_handler, |
69 const std::string& sync_server_and_path, | 68 const std::string& sync_server_and_path, |
70 int sync_server_port, | 69 int sync_server_port, |
71 bool use_ssl, | 70 bool use_ssl, |
72 scoped_ptr<HttpPostProviderFactory> post_factory, | 71 scoped_ptr<HttpPostProviderFactory> post_factory, |
73 const std::vector<ModelSafeWorker*>& workers, | 72 const std::vector<ModelSafeWorker*>& workers, |
74 ExtensionsActivityMonitor* extensions_activity_monitor, | 73 ExtensionsActivityMonitor* extensions_activity_monitor, |
75 SyncManager::ChangeDelegate* change_delegate, | 74 SyncManager::ChangeDelegate* change_delegate, |
76 const SyncCredentials& credentials, | 75 const SyncCredentials& credentials, |
77 scoped_ptr<Invalidator> invalidator, | |
78 const std::string& invalidator_client_id, | 76 const std::string& invalidator_client_id, |
79 const std::string& restored_key_for_bootstrapping, | 77 const std::string& restored_key_for_bootstrapping, |
80 const std::string& restored_keystore_key_for_bootstrapping, | 78 const std::string& restored_keystore_key_for_bootstrapping, |
81 scoped_ptr<InternalComponentsFactory> internal_components_factory, | 79 scoped_ptr<InternalComponentsFactory> internal_components_factory, |
82 Encryptor* encryptor, | 80 Encryptor* encryptor, |
83 UnrecoverableErrorHandler* unrecoverable_error_handler, | 81 UnrecoverableErrorHandler* unrecoverable_error_handler, |
84 ReportUnrecoverableErrorFunction | 82 ReportUnrecoverableErrorFunction |
85 report_unrecoverable_error_function) OVERRIDE; | 83 report_unrecoverable_error_function) OVERRIDE; |
86 virtual void ThrowUnrecoverableError() OVERRIDE; | 84 virtual void ThrowUnrecoverableError() OVERRIDE; |
87 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | 85 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; |
88 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 86 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
89 ModelTypeSet types) OVERRIDE; | 87 ModelTypeSet types) OVERRIDE; |
90 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | 88 virtual bool PurgePartiallySyncedTypes() OVERRIDE; |
91 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | 89 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; |
92 virtual void UpdateEnabledTypes(ModelTypeSet enabled_types) OVERRIDE; | |
93 virtual void RegisterInvalidationHandler( | |
94 InvalidationHandler* handler) OVERRIDE; | |
95 virtual void UpdateRegisteredInvalidationIds( | |
96 InvalidationHandler* handler, | |
97 const ObjectIdSet& ids) OVERRIDE; | |
98 virtual void UnregisterInvalidationHandler( | |
99 InvalidationHandler* handler) OVERRIDE; | |
100 virtual void AcknowledgeInvalidation( | |
101 const invalidation::ObjectId& id, | |
102 const syncer::AckHandle& ack_handle) OVERRIDE; | |
103 virtual void StartSyncingNormally( | 90 virtual void StartSyncingNormally( |
104 const ModelSafeRoutingInfo& routing_info) OVERRIDE; | 91 const ModelSafeRoutingInfo& routing_info) OVERRIDE; |
105 virtual void ConfigureSyncer( | 92 virtual void ConfigureSyncer( |
106 ConfigureReason reason, | 93 ConfigureReason reason, |
107 ModelTypeSet types_to_config, | 94 ModelTypeSet types_to_config, |
108 ModelTypeSet failed_types, | 95 ModelTypeSet failed_types, |
109 const ModelSafeRoutingInfo& new_routing_info, | 96 const ModelSafeRoutingInfo& new_routing_info, |
110 const base::Closure& ready_task, | 97 const base::Closure& ready_task, |
111 const base::Closure& retry_task) OVERRIDE; | 98 const base::Closure& retry_task) OVERRIDE; |
| 99 virtual void UpdateInvalidatorState(InvalidatorState state) OVERRIDE; |
| 100 virtual void Invalidate( |
| 101 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
112 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE; | 102 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE; |
113 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE; | 103 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE; |
114 virtual SyncStatus GetDetailedStatus() const OVERRIDE; | 104 virtual SyncStatus GetDetailedStatus() const OVERRIDE; |
115 virtual void SaveChanges() OVERRIDE; | 105 virtual void SaveChanges() OVERRIDE; |
116 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; | 106 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; |
117 virtual void ShutdownOnSyncThread() OVERRIDE; | 107 virtual void ShutdownOnSyncThread() OVERRIDE; |
118 virtual UserShare* GetUserShare() OVERRIDE; | 108 virtual UserShare* GetUserShare() OVERRIDE; |
119 virtual const std::string cache_guid() OVERRIDE; | 109 virtual const std::string cache_guid() OVERRIDE; |
120 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; | 110 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; |
121 virtual bool HasUnsyncedItems() OVERRIDE; | 111 virtual bool HasUnsyncedItems() OVERRIDE; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 syncable::BaseTransaction* trans) OVERRIDE; | 157 syncable::BaseTransaction* trans) OVERRIDE; |
168 virtual void HandleCalculateChangesChangeEventFromSyncApi( | 158 virtual void HandleCalculateChangesChangeEventFromSyncApi( |
169 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 159 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
170 syncable::BaseTransaction* trans, | 160 syncable::BaseTransaction* trans, |
171 std::vector<int64>* entries_changed) OVERRIDE; | 161 std::vector<int64>* entries_changed) OVERRIDE; |
172 virtual void HandleCalculateChangesChangeEventFromSyncer( | 162 virtual void HandleCalculateChangesChangeEventFromSyncer( |
173 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 163 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
174 syncable::BaseTransaction* trans, | 164 syncable::BaseTransaction* trans, |
175 std::vector<int64>* entries_changed) OVERRIDE; | 165 std::vector<int64>* entries_changed) OVERRIDE; |
176 | 166 |
177 // InvalidationHandler implementation. | |
178 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | |
179 virtual void OnIncomingInvalidation( | |
180 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | |
181 | |
182 // Handle explicit requests to fetch updates for the given types. | 167 // Handle explicit requests to fetch updates for the given types. |
183 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; | 168 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; |
184 | 169 |
185 // These OnYYYChanged() methods are only called by our NetworkChangeNotifier. | 170 // These OnYYYChanged() methods are only called by our NetworkChangeNotifier. |
186 // Called when IP address of primary interface changes. | 171 // Called when IP address of primary interface changes. |
187 virtual void OnIPAddressChanged() OVERRIDE; | 172 virtual void OnIPAddressChanged() OVERRIDE; |
188 // Called when the connection type of the system has changed. | 173 // Called when the connection type of the system has changed. |
189 virtual void OnConnectionTypeChanged( | 174 virtual void OnConnectionTypeChanged( |
190 net::NetworkChangeNotifier::ConnectionType) OVERRIDE; | 175 net::NetworkChangeNotifier::ConnectionType) OVERRIDE; |
191 | 176 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; | 308 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; |
324 | 309 |
325 // A container of various bits of information used by the SyncScheduler to | 310 // A container of various bits of information used by the SyncScheduler to |
326 // create SyncSessions. Must outlive the SyncScheduler. | 311 // create SyncSessions. Must outlive the SyncScheduler. |
327 scoped_ptr<sessions::SyncSessionContext> session_context_; | 312 scoped_ptr<sessions::SyncSessionContext> session_context_; |
328 | 313 |
329 // The scheduler that runs the Syncer. Needs to be explicitly | 314 // The scheduler that runs the Syncer. Needs to be explicitly |
330 // Start()ed. | 315 // Start()ed. |
331 scoped_ptr<SyncScheduler> scheduler_; | 316 scoped_ptr<SyncScheduler> scheduler_; |
332 | 317 |
333 // The Invalidator which notifies us when updates need to be downloaded. | |
334 scoped_ptr<Invalidator> invalidator_; | |
335 | |
336 // A multi-purpose status watch object that aggregates stats from various | 318 // A multi-purpose status watch object that aggregates stats from various |
337 // sync components. | 319 // sync components. |
338 AllStatus allstatus_; | 320 AllStatus allstatus_; |
339 | 321 |
340 // Each element of this map is a store of change records produced by | 322 // Each element of this map is a store of change records produced by |
341 // HandleChangeEventFromSyncer during the CALCULATE_CHANGES step. The changes | 323 // HandleChangeEventFromSyncer during the CALCULATE_CHANGES step. The changes |
342 // are grouped by model type, and are stored here in tree order to be | 324 // are grouped by model type, and are stored here in tree order to be |
343 // forwarded to the observer slightly later, at the TRANSACTION_ENDING step | 325 // forwarded to the observer slightly later, at the TRANSACTION_ENDING step |
344 // by HandleTransactionEndingChangeEvent. The list is cleared after observer | 326 // by HandleTransactionEndingChangeEvent. The list is cleared after observer |
345 // finishes processing. | 327 // finishes processing. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 // changing passphrases, and in general handles sync-specific interactions | 363 // changing passphrases, and in general handles sync-specific interactions |
382 // with the cryptographer. | 364 // with the cryptographer. |
383 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_; | 365 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_; |
384 | 366 |
385 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); | 367 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); |
386 }; | 368 }; |
387 | 369 |
388 } // namespace syncer | 370 } // namespace syncer |
389 | 371 |
390 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 372 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
OLD | NEW |