| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 13 matching lines...) Expand all Loading... |
| 24 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 24 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 25 #include "sync/internal_api/public/util/weak_handle.h" | 25 #include "sync/internal_api/public/util/weak_handle.h" |
| 26 #include "sync/protocol/sync_protocol_error.h" | 26 #include "sync/protocol/sync_protocol_error.h" |
| 27 | 27 |
| 28 namespace syncer { | 28 namespace syncer { |
| 29 class Encryptor; | 29 class Encryptor; |
| 30 struct Experiments; | 30 struct Experiments; |
| 31 class ExtensionsActivityMonitor; | 31 class ExtensionsActivityMonitor; |
| 32 class JsBackend; | 32 class JsBackend; |
| 33 class JsEventHandler; | 33 class JsEventHandler; |
| 34 class SyncScheduler; | |
| 35 | 34 |
| 36 namespace sessions { | 35 namespace sessions { |
| 37 class SyncSessionSnapshot; | 36 class SyncSessionSnapshot; |
| 38 } // namespace sessions | 37 } // namespace sessions |
| 39 } // namespace syncer | 38 } // namespace syncer |
| 40 | 39 |
| 41 namespace syncer { | 40 namespace syncer { |
| 42 class SyncNotifier; | 41 class SyncNotifier; |
| 43 } // namespace syncer | 42 } // namespace syncer |
| 44 | 43 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 syncer::ReportUnrecoverableErrorFunction | 394 syncer::ReportUnrecoverableErrorFunction |
| 396 report_unrecoverable_error_function); | 395 report_unrecoverable_error_function); |
| 397 | 396 |
| 398 // Throw an unrecoverable error from a transaction (mostly used for | 397 // Throw an unrecoverable error from a transaction (mostly used for |
| 399 // testing). | 398 // testing). |
| 400 void ThrowUnrecoverableError(); | 399 void ThrowUnrecoverableError(); |
| 401 | 400 |
| 402 // Returns the set of types for which we have stored some sync data. | 401 // Returns the set of types for which we have stored some sync data. |
| 403 syncer::ModelTypeSet InitialSyncEndedTypes(); | 402 syncer::ModelTypeSet InitialSyncEndedTypes(); |
| 404 | 403 |
| 405 // Returns those types within |types| that have an empty progress marker | |
| 406 // token. | |
| 407 syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | |
| 408 syncer::ModelTypeSet types); | |
| 409 | |
| 410 // Purge from the directory those types with non-empty progress markers | |
| 411 // but without initial synced ended set. | |
| 412 // Returns false if an error occurred, true otherwise. | |
| 413 bool PurgePartiallySyncedTypes(); | |
| 414 | |
| 415 // Update tokens that we're using in Sync. Email must stay the same. | 404 // Update tokens that we're using in Sync. Email must stay the same. |
| 416 void UpdateCredentials(const SyncCredentials& credentials); | 405 void UpdateCredentials(const SyncCredentials& credentials); |
| 417 | 406 |
| 418 // Called when the user disables or enables a sync type. | 407 // Called when the user disables or enables a sync type. |
| 419 void UpdateEnabledTypes(const syncer::ModelTypeSet& enabled_types); | 408 void UpdateEnabledTypes(const syncer::ModelTypeSet& enabled_types); |
| 420 | 409 |
| 421 // Put the syncer in normal mode ready to perform nudges and polls. | 410 // Put the syncer in normal mode ready to perform nudges and polls. |
| 422 void StartSyncingNormally( | 411 void StartSyncingNormally( |
| 423 const syncer::ModelSafeRoutingInfo& routing_info); | 412 const syncer::ModelSafeRoutingInfo& routing_info); |
| 424 | 413 |
| 425 // Attempts to re-encrypt encrypted data types using the passphrase provided. | 414 // Attempts to re-encrypt encrypted data types using the passphrase provided. |
| 426 // Notifies observers of the result of the operation via OnPassphraseAccepted | 415 // Notifies observers of the result of the operation via OnPassphraseAccepted |
| 427 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as | 416 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as |
| 428 // appropriate. If an explicit password has been set previously, we drop | 417 // appropriate. If an explicit password has been set previously, we drop |
| 429 // subsequent requests to set a passphrase. If the cryptographer has pending | 418 // subsequent requests to set a passphrase. If the cryptographer has pending |
| 430 // keys, and a new implicit passphrase is provided, we try decrypting the | 419 // keys, and a new implicit passphrase is provided, we try decrypting the |
| 431 // pending keys with it, and if that fails, we cache the passphrase for | 420 // pending keys with it, and if that fails, we cache the passphrase for |
| 432 // re-encryption once the pending keys are decrypted. | 421 // re-encryption once the pending keys are decrypted. |
| 433 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); | 422 void SetEncryptionPassphrase(const std::string& passphrase, bool is_explicit); |
| 434 | 423 |
| 435 // Provides a passphrase for decrypting the user's existing sync data. | 424 // Provides a passphrase for decrypting the user's existing sync data. |
| 436 // Notifies observers of the result of the operation via OnPassphraseAccepted | 425 // Notifies observers of the result of the operation via OnPassphraseAccepted |
| 437 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as | 426 // or OnPassphraseRequired, updates the nigori node, and does re-encryption as |
| 438 // appropriate if there is a previously cached encryption passphrase. It is an | 427 // appropriate if there is a previously cached encryption passphrase. It is an |
| 439 // error to call this when we don't have pending keys. | 428 // error to call this when we don't have pending keys. |
| 440 void SetDecryptionPassphrase(const std::string& passphrase); | 429 void SetDecryptionPassphrase(const std::string& passphrase); |
| 441 | 430 |
| 442 // Switches the mode of operation to CONFIGURATION_MODE and performs | 431 // Puts the SyncScheduler into a mode where no normal nudge or poll traffic |
| 443 // any configuration tasks needed as determined by the params. Once complete, | 432 // will occur, but calls to RequestConfig will be supported. If |callback| |
| 444 // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is | 433 // is provided, it will be invoked (from the internal SyncScheduler) when |
| 445 // called. | 434 // the thread has changed to configuration mode. |
| 446 // |ready_task| is invoked when the configuration completes. | 435 void StartConfigurationMode(const base::Closure& callback); |
| 447 // |retry_task| is invoked if the configuration job could not immediately | 436 |
| 448 // execute. |ready_task| will still be called when it eventually | 437 // Switches the mode of operation to CONFIGURATION_MODE and |
| 449 // does finish. | 438 // schedules a config task to fetch updates for |types|. |
| 450 void ConfigureSyncer( | 439 void RequestConfig(const syncer::ModelSafeRoutingInfo& routing_info, |
| 451 ConfigureReason reason, | 440 const syncer::ModelTypeSet& types, |
| 452 const syncer::ModelTypeSet& types_to_config, | 441 syncer::ConfigureReason reason); |
| 453 const syncer::ModelSafeRoutingInfo& new_routing_info, | 442 |
| 454 const base::Closure& ready_task, | 443 void RequestCleanupDisabledTypes( |
| 455 const base::Closure& retry_task); | 444 const syncer::ModelSafeRoutingInfo& routing_info); |
| 456 | 445 |
| 457 // Adds a listener to be notified of sync events. | 446 // Adds a listener to be notified of sync events. |
| 458 // NOTE: It is OK (in fact, it's probably a good idea) to call this before | 447 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
| 459 // having received OnInitializationCompleted. | 448 // having received OnInitializationCompleted. |
| 460 void AddObserver(Observer* observer); | 449 void AddObserver(Observer* observer); |
| 461 | 450 |
| 462 // Remove the given observer. Make sure to call this if the | 451 // Remove the given observer. Make sure to call this if the |
| 463 // Observer is being destroyed so the SyncManager doesn't | 452 // Observer is being destroyed so the SyncManager doesn't |
| 464 // potentially dereference garbage. | 453 // potentially dereference garbage. |
| 465 void RemoveObserver(Observer* observer); | 454 void RemoveObserver(Observer* observer); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 void TriggerOnIncomingNotificationForTest( | 531 void TriggerOnIncomingNotificationForTest( |
| 543 syncer::ModelTypeSet model_types); | 532 syncer::ModelTypeSet model_types); |
| 544 | 533 |
| 545 static const int kDefaultNudgeDelayMilliseconds; | 534 static const int kDefaultNudgeDelayMilliseconds; |
| 546 static const int kPreferencesNudgeDelayMilliseconds; | 535 static const int kPreferencesNudgeDelayMilliseconds; |
| 547 static const int kPiggybackNudgeDelay; | 536 static const int kPiggybackNudgeDelay; |
| 548 | 537 |
| 549 static const FilePath::CharType kSyncDatabaseFilename[]; | 538 static const FilePath::CharType kSyncDatabaseFilename[]; |
| 550 | 539 |
| 551 private: | 540 private: |
| 552 friend class SyncManagerTest; | |
| 553 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); | 541 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); |
| 554 | 542 |
| 555 // For unit tests. | 543 // For unit tests. |
| 556 base::TimeDelta GetNudgeDelayTimeDelta(const syncer::ModelType& model_type); | 544 base::TimeDelta GetNudgeDelayTimeDelta(const syncer::ModelType& model_type); |
| 557 | 545 |
| 558 // Set the internal scheduler for testing purposes. | |
| 559 // TODO(sync): Use dependency injection instead. crbug.com/133061 | |
| 560 void SetSyncSchedulerForTest( | |
| 561 scoped_ptr<syncer::SyncScheduler> scheduler); | |
| 562 | |
| 563 base::ThreadChecker thread_checker_; | 546 base::ThreadChecker thread_checker_; |
| 564 | 547 |
| 565 // An opaque pointer to the nested private class. | 548 // An opaque pointer to the nested private class. |
| 566 SyncInternal* data_; | 549 SyncInternal* data_; |
| 567 | 550 |
| 568 DISALLOW_COPY_AND_ASSIGN(SyncManager); | 551 DISALLOW_COPY_AND_ASSIGN(SyncManager); |
| 569 }; | 552 }; |
| 570 | 553 |
| 571 bool InitialSyncEndedForTypes(syncer::ModelTypeSet types, UserShare* share); | 554 bool InitialSyncEndedForTypes(syncer::ModelTypeSet types, UserShare* share); |
| 572 | 555 |
| 556 syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
| 557 syncer::ModelTypeSet types, |
| 558 syncer::UserShare* share); |
| 559 |
| 573 const char* ConnectionStatusToString(ConnectionStatus status); | 560 const char* ConnectionStatusToString(ConnectionStatus status); |
| 574 | 561 |
| 575 // Returns the string representation of a PassphraseRequiredReason value. | 562 // Returns the string representation of a PassphraseRequiredReason value. |
| 576 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); | 563 const char* PassphraseRequiredReasonToString(PassphraseRequiredReason reason); |
| 577 | 564 |
| 578 } // namespace syncer | 565 } // namespace syncer |
| 579 | 566 |
| 580 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ | 567 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_MANAGER_H_ |
| OLD | NEW |