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_PUBLIC_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 class Encryptor; | 38 class Encryptor; |
39 struct Experiments; | 39 struct Experiments; |
40 class ExtensionsActivity; | 40 class ExtensionsActivity; |
41 class HttpPostProviderFactory; | 41 class HttpPostProviderFactory; |
42 class InternalComponentsFactory; | 42 class InternalComponentsFactory; |
43 class JsBackend; | 43 class JsBackend; |
44 class JsEventHandler; | 44 class JsEventHandler; |
45 class SyncEncryptionHandler; | 45 class SyncEncryptionHandler; |
46 class SyncScheduler; | 46 class SyncScheduler; |
47 struct UserShare; | 47 struct UserShare; |
| 48 class CancelationSignal; |
48 | 49 |
49 namespace sessions { | 50 namespace sessions { |
50 class SyncSessionSnapshot; | 51 class SyncSessionSnapshot; |
51 } // namespace sessions | 52 } // namespace sessions |
52 | 53 |
53 // Used by SyncManager::OnConnectionStatusChange(). | 54 // Used by SyncManager::OnConnectionStatusChange(). |
54 enum ConnectionStatus { | 55 enum ConnectionStatus { |
55 CONNECTION_OK, | 56 CONNECTION_OK, |
56 CONNECTION_AUTH_ERROR, | 57 CONNECTION_AUTH_ERROR, |
57 CONNECTION_SERVER_ERROR | 58 CONNECTION_SERVER_ERROR |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // |user_agent| is a 7-bit ASCII string suitable for use as the User-Agent | 293 // |user_agent| is a 7-bit ASCII string suitable for use as the User-Agent |
293 // HTTP header. Used internally when collecting stats to classify clients. | 294 // HTTP header. Used internally when collecting stats to classify clients. |
294 // |invalidator| is owned and used to listen for invalidations. | 295 // |invalidator| is owned and used to listen for invalidations. |
295 // |invalidator_client_id| is used to unqiuely identify this client to the | 296 // |invalidator_client_id| is used to unqiuely identify this client to the |
296 // invalidation notification server. | 297 // invalidation notification server. |
297 // |restored_key_for_bootstrapping| is the key used to boostrap the | 298 // |restored_key_for_bootstrapping| is the key used to boostrap the |
298 // cryptographer | 299 // cryptographer |
299 // |keystore_encryption_enabled| determines whether we enable the keystore | 300 // |keystore_encryption_enabled| determines whether we enable the keystore |
300 // encryption functionality in the cryptographer/nigori. | 301 // encryption functionality in the cryptographer/nigori. |
301 // |report_unrecoverable_error_function| may be NULL. | 302 // |report_unrecoverable_error_function| may be NULL. |
| 303 // |cancelation_signal| carries shutdown requests across threads. This one |
| 304 // will be used to cut short any network I/O and tell the syncer to exit |
| 305 // early. |
302 // | 306 // |
303 // TODO(akalin): Replace the |post_factory| parameter with a | 307 // TODO(akalin): Replace the |post_factory| parameter with a |
304 // URLFetcher parameter. | 308 // URLFetcher parameter. |
305 virtual void Init( | 309 virtual void Init( |
306 const base::FilePath& database_location, | 310 const base::FilePath& database_location, |
307 const WeakHandle<JsEventHandler>& event_handler, | 311 const WeakHandle<JsEventHandler>& event_handler, |
308 const std::string& sync_server_and_path, | 312 const std::string& sync_server_and_path, |
309 int sync_server_port, | 313 int sync_server_port, |
310 bool use_ssl, | 314 bool use_ssl, |
311 scoped_ptr<HttpPostProviderFactory> post_factory, | 315 scoped_ptr<HttpPostProviderFactory> post_factory, |
312 const std::vector<ModelSafeWorker*>& workers, | 316 const std::vector<ModelSafeWorker*>& workers, |
313 ExtensionsActivity* extensions_activity, | 317 ExtensionsActivity* extensions_activity, |
314 ChangeDelegate* change_delegate, | 318 ChangeDelegate* change_delegate, |
315 const SyncCredentials& credentials, | 319 const SyncCredentials& credentials, |
316 const std::string& invalidator_client_id, | 320 const std::string& invalidator_client_id, |
317 const std::string& restored_key_for_bootstrapping, | 321 const std::string& restored_key_for_bootstrapping, |
318 const std::string& restored_keystore_key_for_bootstrapping, | 322 const std::string& restored_keystore_key_for_bootstrapping, |
319 InternalComponentsFactory* internal_components_factory, | 323 InternalComponentsFactory* internal_components_factory, |
320 Encryptor* encryptor, | 324 Encryptor* encryptor, |
321 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | 325 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, |
322 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, | 326 ReportUnrecoverableErrorFunction report_unrecoverable_error_function, |
323 bool use_oauth2_token) = 0; | 327 bool use_oauth2_token, |
| 328 CancelationSignal* cancelation_signal) = 0; |
324 | 329 |
325 // Throw an unrecoverable error from a transaction (mostly used for | 330 // Throw an unrecoverable error from a transaction (mostly used for |
326 // testing). | 331 // testing). |
327 virtual void ThrowUnrecoverableError() = 0; | 332 virtual void ThrowUnrecoverableError() = 0; |
328 | 333 |
329 virtual ModelTypeSet InitialSyncEndedTypes() = 0; | 334 virtual ModelTypeSet InitialSyncEndedTypes() = 0; |
330 | 335 |
331 // Returns those types within |types| that have an empty progress marker | 336 // Returns those types within |types| that have an empty progress marker |
332 // token. | 337 // token. |
333 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 338 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 // potentially dereference garbage. | 390 // potentially dereference garbage. |
386 virtual void RemoveObserver(Observer* observer) = 0; | 391 virtual void RemoveObserver(Observer* observer) = 0; |
387 | 392 |
388 // Status-related getter. May be called on any thread. | 393 // Status-related getter. May be called on any thread. |
389 virtual SyncStatus GetDetailedStatus() const = 0; | 394 virtual SyncStatus GetDetailedStatus() const = 0; |
390 | 395 |
391 // Call periodically from a database-safe thread to persist recent changes | 396 // Call periodically from a database-safe thread to persist recent changes |
392 // to the syncapi model. | 397 // to the syncapi model. |
393 virtual void SaveChanges() = 0; | 398 virtual void SaveChanges() = 0; |
394 | 399 |
395 // Initiates shutdown of various components in the sync engine. Must be | |
396 // called from the main thread to allow preempting ongoing tasks on the sync | |
397 // loop (that may be blocked on I/O). The semantics of |callback| are the | |
398 // same as with StartConfigurationMode. If provided and a scheduler / sync | |
399 // loop exists, it will be invoked from the sync loop by the scheduler to | |
400 // notify that all work has been flushed + cancelled, and it is idle. | |
401 // If no scheduler exists, the callback is run immediately (from the loop | |
402 // this was created on, which is the sync loop), as sync is effectively | |
403 // stopped. | |
404 virtual void StopSyncingForShutdown() = 0; | |
405 | |
406 // Issue a final SaveChanges, and close sqlite handles. | 400 // Issue a final SaveChanges, and close sqlite handles. |
407 virtual void ShutdownOnSyncThread() = 0; | 401 virtual void ShutdownOnSyncThread() = 0; |
408 | 402 |
409 // May be called from any thread. | 403 // May be called from any thread. |
410 virtual UserShare* GetUserShare() = 0; | 404 virtual UserShare* GetUserShare() = 0; |
411 | 405 |
412 // Returns the cache_guid of the currently open database. | 406 // Returns the cache_guid of the currently open database. |
413 // Requires that the SyncManager be initialized. | 407 // Requires that the SyncManager be initialized. |
414 virtual const std::string cache_guid() = 0; | 408 virtual const std::string cache_guid() = 0; |
415 | 409 |
416 // Reads the nigori node to determine if any experimental features should | 410 // Reads the nigori node to determine if any experimental features should |
417 // be enabled. | 411 // be enabled. |
418 // Note: opens a transaction. May be called on any thread. | 412 // Note: opens a transaction. May be called on any thread. |
419 virtual bool ReceivedExperiment(Experiments* experiments) = 0; | 413 virtual bool ReceivedExperiment(Experiments* experiments) = 0; |
420 | 414 |
421 // Uses a read-only transaction to determine if the directory being synced has | 415 // Uses a read-only transaction to determine if the directory being synced has |
422 // any remaining unsynced items. May be called on any thread. | 416 // any remaining unsynced items. May be called on any thread. |
423 virtual bool HasUnsyncedItems() = 0; | 417 virtual bool HasUnsyncedItems() = 0; |
424 | 418 |
425 // Returns the SyncManager's encryption handler. | 419 // Returns the SyncManager's encryption handler. |
426 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0; | 420 virtual SyncEncryptionHandler* GetEncryptionHandler() = 0; |
427 | 421 |
428 // Ask the SyncManager to fetch updates for the given types. | 422 // Ask the SyncManager to fetch updates for the given types. |
429 virtual void RefreshTypes(ModelTypeSet types) = 0; | 423 virtual void RefreshTypes(ModelTypeSet types) = 0; |
430 }; | 424 }; |
431 | 425 |
432 } // namespace syncer | 426 } // namespace syncer |
433 | 427 |
434 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 428 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
OLD | NEW |