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, | 83 report_unrecoverable_error_function, |
86 bool use_oauth2_token) OVERRIDE; | 84 bool use_oauth2_token) OVERRIDE; |
87 virtual void ThrowUnrecoverableError() OVERRIDE; | 85 virtual void ThrowUnrecoverableError() OVERRIDE; |
88 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | 86 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; |
89 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 87 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
90 ModelTypeSet types) OVERRIDE; | 88 ModelTypeSet types) OVERRIDE; |
91 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | 89 virtual bool PurgePartiallySyncedTypes() OVERRIDE; |
92 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | 90 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; | |
104 virtual void StartSyncingNormally( | 91 virtual void StartSyncingNormally( |
105 const ModelSafeRoutingInfo& routing_info) OVERRIDE; | 92 const ModelSafeRoutingInfo& routing_info) OVERRIDE; |
106 virtual void ConfigureSyncer( | 93 virtual void ConfigureSyncer( |
107 ConfigureReason reason, | 94 ConfigureReason reason, |
108 ModelTypeSet to_download, | 95 ModelTypeSet to_download, |
109 ModelTypeSet to_journal, | 96 ModelTypeSet to_journal, |
110 ModelTypeSet to_unapply, | 97 ModelTypeSet to_unapply, |
111 ModelTypeSet to_ignore, | 98 ModelTypeSet to_ignore, |
112 const ModelSafeRoutingInfo& new_routing_info, | 99 const ModelSafeRoutingInfo& new_routing_info, |
113 const base::Closure& ready_task, | 100 const base::Closure& ready_task, |
114 const base::Closure& retry_task) OVERRIDE; | 101 const base::Closure& retry_task) OVERRIDE; |
102 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | |
103 virtual void OnIncomingInvalidation( | |
104 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | |
115 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE; | 105 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE; |
116 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE; | 106 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE; |
117 virtual SyncStatus GetDetailedStatus() const OVERRIDE; | 107 virtual SyncStatus GetDetailedStatus() const OVERRIDE; |
118 virtual void SaveChanges() OVERRIDE; | 108 virtual void SaveChanges() OVERRIDE; |
119 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; | 109 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; |
120 virtual void ShutdownOnSyncThread() OVERRIDE; | 110 virtual void ShutdownOnSyncThread() OVERRIDE; |
121 virtual UserShare* GetUserShare() OVERRIDE; | 111 virtual UserShare* GetUserShare() OVERRIDE; |
122 virtual const std::string cache_guid() OVERRIDE; | 112 virtual const std::string cache_guid() OVERRIDE; |
123 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; | 113 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; |
124 virtual bool HasUnsyncedItems() OVERRIDE; | 114 virtual bool HasUnsyncedItems() OVERRIDE; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 syncable::BaseTransaction* trans) OVERRIDE; | 160 syncable::BaseTransaction* trans) OVERRIDE; |
171 virtual void HandleCalculateChangesChangeEventFromSyncApi( | 161 virtual void HandleCalculateChangesChangeEventFromSyncApi( |
172 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 162 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
173 syncable::BaseTransaction* trans, | 163 syncable::BaseTransaction* trans, |
174 std::vector<int64>* entries_changed) OVERRIDE; | 164 std::vector<int64>* entries_changed) OVERRIDE; |
175 virtual void HandleCalculateChangesChangeEventFromSyncer( | 165 virtual void HandleCalculateChangesChangeEventFromSyncer( |
176 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | 166 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, |
177 syncable::BaseTransaction* trans, | 167 syncable::BaseTransaction* trans, |
178 std::vector<int64>* entries_changed) OVERRIDE; | 168 std::vector<int64>* entries_changed) OVERRIDE; |
179 | 169 |
180 // InvalidationHandler implementation. | |
181 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | |
182 virtual void OnIncomingInvalidation( | |
183 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | |
184 | |
185 // Handle explicit requests to fetch updates for the given types. | 170 // Handle explicit requests to fetch updates for the given types. |
186 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; | 171 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; |
187 | 172 |
188 // These OnYYYChanged() methods are only called by our NetworkChangeNotifier. | 173 // These OnYYYChanged() methods are only called by our NetworkChangeNotifier. |
189 // Called when IP address of primary interface changes. | 174 // Called when IP address of primary interface changes. |
190 virtual void OnIPAddressChanged() OVERRIDE; | 175 virtual void OnIPAddressChanged() OVERRIDE; |
191 // Called when the connection type of the system has changed. | 176 // Called when the connection type of the system has changed. |
192 virtual void OnConnectionTypeChanged( | 177 virtual void OnConnectionTypeChanged( |
193 net::NetworkChangeNotifier::ConnectionType) OVERRIDE; | 178 net::NetworkChangeNotifier::ConnectionType) OVERRIDE; |
194 | 179 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; | 316 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; |
332 | 317 |
333 // A container of various bits of information used by the SyncScheduler to | 318 // A container of various bits of information used by the SyncScheduler to |
334 // create SyncSessions. Must outlive the SyncScheduler. | 319 // create SyncSessions. Must outlive the SyncScheduler. |
335 scoped_ptr<sessions::SyncSessionContext> session_context_; | 320 scoped_ptr<sessions::SyncSessionContext> session_context_; |
336 | 321 |
337 // The scheduler that runs the Syncer. Needs to be explicitly | 322 // The scheduler that runs the Syncer. Needs to be explicitly |
338 // Start()ed. | 323 // Start()ed. |
339 scoped_ptr<SyncScheduler> scheduler_; | 324 scoped_ptr<SyncScheduler> scheduler_; |
340 | 325 |
341 // The Invalidator which notifies us when updates need to be downloaded. | |
342 scoped_ptr<Invalidator> invalidator_; | |
pavely
2013/06/18 23:00:39
You are tearing out invalidator from SyncManagerIm
| |
343 | |
344 // A multi-purpose status watch object that aggregates stats from various | 326 // A multi-purpose status watch object that aggregates stats from various |
345 // sync components. | 327 // sync components. |
346 AllStatus allstatus_; | 328 AllStatus allstatus_; |
347 | 329 |
348 // Each element of this map is a store of change records produced by | 330 // Each element of this map is a store of change records produced by |
349 // HandleChangeEventFromSyncer during the CALCULATE_CHANGES step. The changes | 331 // HandleChangeEventFromSyncer during the CALCULATE_CHANGES step. The changes |
350 // are grouped by model type, and are stored here in tree order to be | 332 // are grouped by model type, and are stored here in tree order to be |
351 // forwarded to the observer slightly later, at the TRANSACTION_ENDING step | 333 // forwarded to the observer slightly later, at the TRANSACTION_ENDING step |
352 // by HandleTransactionEndingChangeEvent. The list is cleared after observer | 334 // by HandleTransactionEndingChangeEvent. The list is cleared after observer |
353 // finishes processing. | 335 // finishes processing. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 // changing passphrases, and in general handles sync-specific interactions | 371 // changing passphrases, and in general handles sync-specific interactions |
390 // with the cryptographer. | 372 // with the cryptographer. |
391 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_; | 373 scoped_ptr<SyncEncryptionHandlerImpl> sync_encryption_handler_; |
392 | 374 |
393 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); | 375 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); |
394 }; | 376 }; |
395 | 377 |
396 } // namespace syncer | 378 } // namespace syncer |
397 | 379 |
398 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 380 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
OLD | NEW |