| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // be disabled and state cleaned up at once. This can happen for a number | 369 // be disabled and state cleaned up at once. This can happen for a number |
| 370 // of reasons, e.g. swapping from a test instance to production, or a | 370 // of reasons, e.g. swapping from a test instance to production, or a |
| 371 // global stop syncing operation has wiped the store. | 371 // global stop syncing operation has wiped the store. |
| 372 virtual void OnStopSyncingPermanently() = 0; | 372 virtual void OnStopSyncingPermanently() = 0; |
| 373 | 373 |
| 374 // After a request to clear server data, these callbacks are invoked to | 374 // After a request to clear server data, these callbacks are invoked to |
| 375 // indicate success or failure. | 375 // indicate success or failure. |
| 376 virtual void OnClearServerDataSucceeded() = 0; | 376 virtual void OnClearServerDataSucceeded() = 0; |
| 377 virtual void OnClearServerDataFailed() = 0; | 377 virtual void OnClearServerDataFailed() = 0; |
| 378 | 378 |
| 379 // Called after we finish encrypting all appropriate datatypes. | 379 // Called when the set of encrypted types or the encrypt |
| 380 virtual void OnEncryptionComplete( | 380 // everything flag has been changed. Note that encryption isn't |
| 381 const syncable::ModelTypeSet& encrypted_types) = 0; | 381 // complete until the OnEncryptionComplete() notification has been |
| 382 // sent (see below). |
| 383 // |
| 384 // |encrypted_types| will always be a superset of |
| 385 // Cryptographer::SensitiveTypes(). If |encrypt_everything| is |
| 386 // true, |encrypted_types| will be the set of all known types. |
| 387 // |
| 388 // Until this function is called, observers can assume that the |
| 389 // set of encrypted types is Cryptographer::SensitiveTypes() and |
| 390 // that the encrypt everything flag is false. |
| 391 // |
| 392 // Called from within a transaction. |
| 393 virtual void OnEncryptedTypesChanged( |
| 394 const syncable::ModelTypeSet& encrypted_types, |
| 395 bool encrypt_everything) = 0; |
| 396 |
| 397 // Called after we finish encrypting the current set of encrypted |
| 398 // types. |
| 399 // |
| 400 // Called from within a transaction. |
| 401 virtual void OnEncryptionComplete() = 0; |
| 382 | 402 |
| 383 virtual void OnActionableError( | 403 virtual void OnActionableError( |
| 384 const browser_sync::SyncProtocolError& sync_protocol_error) = 0; | 404 const browser_sync::SyncProtocolError& sync_protocol_error) = 0; |
| 385 | 405 |
| 386 protected: | 406 protected: |
| 387 virtual ~Observer(); | 407 virtual ~Observer(); |
| 388 }; | 408 }; |
| 389 | 409 |
| 390 // Create an uninitialized SyncManager. Callers must Init() before using. | 410 // Create an uninitialized SyncManager. Callers must Init() before using. |
| 391 explicit SyncManager(const std::string& name); | 411 explicit SyncManager(const std::string& name); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 // this was created on, which is the sync loop), as sync is effectively | 535 // this was created on, which is the sync loop), as sync is effectively |
| 516 // stopped. | 536 // stopped. |
| 517 void StopSyncingForShutdown(const base::Closure& callback); | 537 void StopSyncingForShutdown(const base::Closure& callback); |
| 518 | 538 |
| 519 // Issue a final SaveChanges, and close sqlite handles. | 539 // Issue a final SaveChanges, and close sqlite handles. |
| 520 void ShutdownOnSyncThread(); | 540 void ShutdownOnSyncThread(); |
| 521 | 541 |
| 522 // May be called from any thread. | 542 // May be called from any thread. |
| 523 UserShare* GetUserShare() const; | 543 UserShare* GetUserShare() const; |
| 524 | 544 |
| 525 // Inform the cryptographer of the most recent passphrase and set of encrypted | 545 // Inform the cryptographer of the most recent passphrase and set of |
| 526 // types (from nigori node), then ensure all data that needs encryption is | 546 // encrypted types (from nigori node), then ensure all data that |
| 527 // encrypted with the appropriate passphrase. | 547 // needs encryption is encrypted with the appropriate passphrase. |
| 528 // Note: opens a transaction and can trigger ON_PASSPHRASE_REQUIRED, so must | 548 // |
| 529 // only be called after syncapi has been initialized. | 549 // May trigger OnPassphraseRequired(). Otherwise, it will trigger |
| 550 // OnEncryptedTypesChanged() if necessary (see comments for |
| 551 // OnEncryptedTypesChanged()), and then OnEncryptionComplete(). |
| 552 // |
| 553 // Note: opens a transaction, so must only be called after syncapi |
| 554 // has been initialized. |
| 530 void RefreshEncryption(); | 555 void RefreshEncryption(); |
| 531 | 556 |
| 532 // Enable encryption of all sync data. Once enabled, it can never be disabled | 557 // Enable encryption of all sync data. Once enabled, it can never be |
| 533 // without clearing the server data. | 558 // disabled without clearing the server data. |
| 559 // |
| 560 // This will trigger OnEncryptedTypesChanged() if necessary (see |
| 561 // comments for OnEncryptedTypesChanged()). It then may trigger |
| 562 // OnPassphraseRequired(), but otherwise it will trigger |
| 563 // OnEncryptionComplete(). |
| 534 void EnableEncryptEverything(); | 564 void EnableEncryptEverything(); |
| 535 | 565 |
| 536 // Returns true if we are currently encrypting all sync data. May | 566 // Returns true if we are currently encrypting all sync data. May |
| 537 // be called on any thread. | 567 // be called on any thread. |
| 538 bool EncryptEverythingEnabled() const; | 568 bool EncryptEverythingEnabledForTest() const; |
| 539 | 569 |
| 540 // Gets the set of encrypted types from the cryptographer | 570 // Gets the set of encrypted types from the cryptographer |
| 541 // Note: opens a transaction. May be called from any thread. | 571 // Note: opens a transaction. May be called from any thread. |
| 542 syncable::ModelTypeSet GetEncryptedDataTypes() const; | 572 syncable::ModelTypeSet GetEncryptedDataTypesForTest() const; |
| 543 | 573 |
| 544 // Reads the nigori node to determine if any experimental types should be | 574 // Reads the nigori node to determine if any experimental types should be |
| 545 // enabled. | 575 // enabled. |
| 546 // Note: opens a transaction. May be called on any thread. | 576 // Note: opens a transaction. May be called on any thread. |
| 547 bool ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add) const; | 577 bool ReceivedExperimentalTypes(syncable::ModelTypeSet* to_add) const; |
| 548 | 578 |
| 549 // Uses a read-only transaction to determine if the directory being synced has | 579 // Uses a read-only transaction to determine if the directory being synced has |
| 550 // any remaining unsynced items. May be called on any thread. | 580 // any remaining unsynced items. May be called on any thread. |
| 551 bool HasUnsyncedItems() const; | 581 bool HasUnsyncedItems() const; |
| 552 | 582 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 568 }; | 598 }; |
| 569 | 599 |
| 570 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); | 600 bool InitialSyncEndedForTypes(syncable::ModelTypeSet types, UserShare* share); |
| 571 | 601 |
| 572 // Returns the string representation of a PassphraseRequiredReason value. | 602 // Returns the string representation of a PassphraseRequiredReason value. |
| 573 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason); | 603 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason); |
| 574 | 604 |
| 575 } // namespace sync_api | 605 } // namespace sync_api |
| 576 | 606 |
| 577 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 607 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| OLD | NEW |