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