| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 // Count of empty and non empty getupdates; | 152 // Count of empty and non empty getupdates; |
| 153 int nonempty_get_updates; | 153 int nonempty_get_updates; |
| 154 int empty_get_updates; | 154 int empty_get_updates; |
| 155 | 155 |
| 156 // Count of useless and useful syncs we perform. | 156 // Count of useless and useful syncs we perform. |
| 157 int useless_sync_cycles; | 157 int useless_sync_cycles; |
| 158 int useful_sync_cycles; | 158 int useful_sync_cycles; |
| 159 | 159 |
| 160 // Encryption related. | 160 // Encryption related. |
| 161 syncable::ModelEnumSet encrypted_types; | 161 syncable::ModelTypeSet encrypted_types; |
| 162 bool cryptographer_ready; | 162 bool cryptographer_ready; |
| 163 bool crypto_has_pending_keys; | 163 bool crypto_has_pending_keys; |
| 164 | 164 |
| 165 // The unique identifer for this client. | 165 // The unique identifer for this client. |
| 166 std::string unique_id; | 166 std::string unique_id; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 // An interface the embedding application implements to be notified | 169 // An interface the embedding application implements to be notified |
| 170 // on change events. Note that these methods may be called on *any* | 170 // on change events. Note that these methods may be called on *any* |
| 171 // thread. | 171 // thread. |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // |encrypted_types| will always be a superset of | 383 // |encrypted_types| will always be a superset of |
| 384 // Cryptographer::SensitiveTypes(). If |encrypt_everything| is | 384 // Cryptographer::SensitiveTypes(). If |encrypt_everything| is |
| 385 // true, |encrypted_types| will be the set of all known types. | 385 // true, |encrypted_types| will be the set of all known types. |
| 386 // | 386 // |
| 387 // Until this function is called, observers can assume that the | 387 // Until this function is called, observers can assume that the |
| 388 // set of encrypted types is Cryptographer::SensitiveTypes() and | 388 // set of encrypted types is Cryptographer::SensitiveTypes() and |
| 389 // that the encrypt everything flag is false. | 389 // that the encrypt everything flag is false. |
| 390 // | 390 // |
| 391 // Called from within a transaction. | 391 // Called from within a transaction. |
| 392 virtual void OnEncryptedTypesChanged( | 392 virtual void OnEncryptedTypesChanged( |
| 393 syncable::ModelEnumSet encrypted_types, | 393 syncable::ModelTypeSet encrypted_types, |
| 394 bool encrypt_everything) = 0; | 394 bool encrypt_everything) = 0; |
| 395 | 395 |
| 396 // Called after we finish encrypting the current set of encrypted | 396 // Called after we finish encrypting the current set of encrypted |
| 397 // types. | 397 // types. |
| 398 // | 398 // |
| 399 // Called from within a transaction. | 399 // Called from within a transaction. |
| 400 virtual void OnEncryptionComplete() = 0; | 400 virtual void OnEncryptionComplete() = 0; |
| 401 | 401 |
| 402 virtual void OnActionableError( | 402 virtual void OnActionableError( |
| 403 const browser_sync::SyncProtocolError& sync_protocol_error) = 0; | 403 const browser_sync::SyncProtocolError& sync_protocol_error) = 0; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 bool InitialSyncEndedForAllEnabledTypes(); | 450 bool InitialSyncEndedForAllEnabledTypes(); |
| 451 | 451 |
| 452 // Update tokens that we're using in Sync. Email must stay the same. | 452 // Update tokens that we're using in Sync. Email must stay the same. |
| 453 void UpdateCredentials(const SyncCredentials& credentials); | 453 void UpdateCredentials(const SyncCredentials& credentials); |
| 454 | 454 |
| 455 // Called when the user disables or enables a sync type. | 455 // Called when the user disables or enables a sync type. |
| 456 void UpdateEnabledTypes(); | 456 void UpdateEnabledTypes(); |
| 457 | 457 |
| 458 // Conditionally sets the flag in the Nigori node which instructs other | 458 // Conditionally sets the flag in the Nigori node which instructs other |
| 459 // clients to start syncing tabs. | 459 // clients to start syncing tabs. |
| 460 void MaybeSetSyncTabsInNigoriNode(syncable::ModelEnumSet enabled_types); | 460 void MaybeSetSyncTabsInNigoriNode(syncable::ModelTypeSet enabled_types); |
| 461 | 461 |
| 462 // Put the syncer in normal mode ready to perform nudges and polls. | 462 // Put the syncer in normal mode ready to perform nudges and polls. |
| 463 void StartSyncingNormally(); | 463 void StartSyncingNormally(); |
| 464 | 464 |
| 465 // Attempt to set the passphrase. If the passphrase is valid, | 465 // Attempt to set the passphrase. If the passphrase is valid, |
| 466 // OnPassphraseAccepted will be fired to notify the ProfileSyncService and the | 466 // OnPassphraseAccepted will be fired to notify the ProfileSyncService and the |
| 467 // syncer will be nudged so that any update that was waiting for this | 467 // syncer will be nudged so that any update that was waiting for this |
| 468 // passphrase gets applied as soon as possible. | 468 // passphrase gets applied as soon as possible. |
| 469 // If the passphrase in invalid, OnPassphraseRequired will be fired. | 469 // If the passphrase in invalid, OnPassphraseRequired will be fired. |
| 470 // Calling this metdod again is the appropriate course of action to "retry" | 470 // Calling this metdod again is the appropriate course of action to "retry" |
| 471 // with a new passphrase. | 471 // with a new passphrase. |
| 472 // |is_explicit| is true if the call is in response to the user explicitly | 472 // |is_explicit| is true if the call is in response to the user explicitly |
| 473 // setting a passphrase as opposed to implicitly (from the users' perspective) | 473 // setting a passphrase as opposed to implicitly (from the users' perspective) |
| 474 // using their Google Account password. An implicit SetPassphrase will *not* | 474 // using their Google Account password. An implicit SetPassphrase will *not* |
| 475 // *not* override an explicit passphrase set previously. | 475 // *not* override an explicit passphrase set previously. |
| 476 void SetPassphrase(const std::string& passphrase, bool is_explicit); | 476 void SetPassphrase(const std::string& passphrase, bool is_explicit); |
| 477 | 477 |
| 478 // Puts the SyncScheduler into a mode where no normal nudge or poll traffic | 478 // Puts the SyncScheduler into a mode where no normal nudge or poll traffic |
| 479 // will occur, but calls to RequestConfig will be supported. If |callback| | 479 // will occur, but calls to RequestConfig will be supported. If |callback| |
| 480 // is provided, it will be invoked (from the internal SyncScheduler) when | 480 // is provided, it will be invoked (from the internal SyncScheduler) when |
| 481 // the thread has changed to configuration mode. | 481 // the thread has changed to configuration mode. |
| 482 void StartConfigurationMode(const base::Closure& callback); | 482 void StartConfigurationMode(const base::Closure& callback); |
| 483 | 483 |
| 484 // Switches the mode of operation to CONFIGURATION_MODE and | 484 // Switches the mode of operation to CONFIGURATION_MODE and |
| 485 // schedules a config task to fetch updates for |types|. | 485 // schedules a config task to fetch updates for |types|. |
| 486 void RequestConfig(syncable::ModelEnumSet types, | 486 void RequestConfig(syncable::ModelTypeSet types, |
| 487 sync_api::ConfigureReason reason); | 487 sync_api::ConfigureReason reason); |
| 488 | 488 |
| 489 void RequestCleanupDisabledTypes(); | 489 void RequestCleanupDisabledTypes(); |
| 490 | 490 |
| 491 // Request a clearing of all data on the server | 491 // Request a clearing of all data on the server |
| 492 void RequestClearServerData(); | 492 void RequestClearServerData(); |
| 493 | 493 |
| 494 // Adds a listener to be notified of sync events. | 494 // Adds a listener to be notified of sync events. |
| 495 // NOTE: It is OK (in fact, it's probably a good idea) to call this before | 495 // NOTE: It is OK (in fact, it's probably a good idea) to call this before |
| 496 // having received OnInitializationCompleted. | 496 // having received OnInitializationCompleted. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 // OnPassphraseRequired(), but otherwise it will trigger | 552 // OnPassphraseRequired(), but otherwise it will trigger |
| 553 // OnEncryptionComplete(). | 553 // OnEncryptionComplete(). |
| 554 void EnableEncryptEverything(); | 554 void EnableEncryptEverything(); |
| 555 | 555 |
| 556 // Returns true if we are currently encrypting all sync data. May | 556 // Returns true if we are currently encrypting all sync data. May |
| 557 // be called on any thread. | 557 // be called on any thread. |
| 558 bool EncryptEverythingEnabledForTest() const; | 558 bool EncryptEverythingEnabledForTest() const; |
| 559 | 559 |
| 560 // Gets the set of encrypted types from the cryptographer | 560 // Gets the set of encrypted types from the cryptographer |
| 561 // Note: opens a transaction. May be called from any thread. | 561 // Note: opens a transaction. May be called from any thread. |
| 562 syncable::ModelEnumSet GetEncryptedDataTypesForTest() const; | 562 syncable::ModelTypeSet GetEncryptedDataTypesForTest() const; |
| 563 | 563 |
| 564 // Reads the nigori node to determine if any experimental types should be | 564 // Reads the nigori node to determine if any experimental types should be |
| 565 // enabled. | 565 // enabled. |
| 566 // Note: opens a transaction. May be called on any thread. | 566 // Note: opens a transaction. May be called on any thread. |
| 567 bool ReceivedExperimentalTypes(syncable::ModelEnumSet* to_add) const; | 567 bool ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add) const; |
| 568 | 568 |
| 569 // Uses a read-only transaction to determine if the directory being synced has | 569 // Uses a read-only transaction to determine if the directory being synced has |
| 570 // any remaining unsynced items. May be called on any thread. | 570 // any remaining unsynced items. May be called on any thread. |
| 571 bool HasUnsyncedItems() const; | 571 bool HasUnsyncedItems() const; |
| 572 | 572 |
| 573 // Functions used for testing. | 573 // Functions used for testing. |
| 574 | 574 |
| 575 void TriggerOnNotificationStateChangeForTest( | 575 void TriggerOnNotificationStateChangeForTest( |
| 576 bool notifications_enabled); | 576 bool notifications_enabled); |
| 577 | 577 |
| 578 void TriggerOnIncomingNotificationForTest( | 578 void TriggerOnIncomingNotificationForTest( |
| 579 syncable::ModelEnumSet model_types); | 579 syncable::ModelTypeSet model_types); |
| 580 | 580 |
| 581 private: | 581 private: |
| 582 base::ThreadChecker thread_checker_; | 582 base::ThreadChecker thread_checker_; |
| 583 | 583 |
| 584 // An opaque pointer to the nested private class. | 584 // An opaque pointer to the nested private class. |
| 585 SyncInternal* data_; | 585 SyncInternal* data_; |
| 586 | 586 |
| 587 DISALLOW_COPY_AND_ASSIGN(SyncManager); | 587 DISALLOW_COPY_AND_ASSIGN(SyncManager); |
| 588 }; | 588 }; |
| 589 | 589 |
| 590 bool InitialSyncEndedForTypes(syncable::ModelEnumSet types, UserShare* share); | 590 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); |
| 591 | 591 |
| 592 syncable::ModelEnumSet GetTypesWithEmptyProgressMarkerToken( | 592 syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
| 593 syncable::ModelEnumSet types, | 593 syncable::ModelTypeSet types, |
| 594 sync_api::UserShare* share); | 594 sync_api::UserShare* share); |
| 595 | 595 |
| 596 // Returns the string representation of a PassphraseRequiredReason value. | 596 // Returns the string representation of a PassphraseRequiredReason value. |
| 597 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason); | 597 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason); |
| 598 | 598 |
| 599 } // namespace sync_api | 599 } // namespace sync_api |
| 600 | 600 |
| 601 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 601 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| OLD | NEW |