Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/sync/engine/syncapi.h

Issue 6902101: Refactor sync passphrase setup flow and fix passphrase tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: de Morgan's law simplification. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This file defines the "sync API", an interface to the syncer 5 // This file defines the "sync API", an interface to the syncer
6 // backend that exposes (1) the core functionality of maintaining a consistent 6 // backend that exposes (1) the core functionality of maintaining a consistent
7 // local snapshot of a hierarchical object set; (2) a means to transactionally 7 // local snapshot of a hierarchical object set; (2) a means to transactionally
8 // access and modify those objects; (3) a means to control client/server 8 // access and modify those objects; (3) a means to control client/server
9 // synchronization tasks, namely: pushing local object modifications to a 9 // synchronization tasks, namely: pushing local object modifications to a
10 // server, pulling nonlocal object modifications from a server to this client, 10 // server, pulling nonlocal object modifications from a server to this client,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 class TypedUrlSpecifics; 100 class TypedUrlSpecifics;
101 } 101 }
102 102
103 namespace sync_api { 103 namespace sync_api {
104 104
105 class BaseTransaction; 105 class BaseTransaction;
106 class HttpPostProviderFactory; 106 class HttpPostProviderFactory;
107 class SyncManager; 107 class SyncManager;
108 class WriteTransaction; 108 class WriteTransaction;
109 109
110 // Reasons due to which browser_sync::Cryptographer might require a passphrase.
111 enum PassphraseRequiredReason {
112 REASON_PASSPHRASE_NOT_REQUIRED = 0, // Initial value.
113 REASON_ENCRYPTION = 1, // The cryptographer requires a
114 // passphrase for its first attempt at
115 // encryption. Happens only during
116 // migration or upgrade.
117 REASON_DECRYPTION = 2, // The cryptographer requires a
118 // passphrase for its first attempt at
119 // decryption.
120 REASON_SET_PASSPHRASE_FAILED = 3, // The cryptographer requires a new
121 // passphrase because its attempt at
122 // decryption with the cached passphrase
123 // was unsuccessful.
124 };
125
126 // Returns the string representation of a PassphraseRequiredReason value.
127 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason);
128
110 // A UserShare encapsulates the syncable pieces that represent an authenticated 129 // A UserShare encapsulates the syncable pieces that represent an authenticated
111 // user and their data (share). 130 // user and their data (share).
112 // This encompasses all pieces required to build transaction objects on the 131 // This encompasses all pieces required to build transaction objects on the
113 // syncable share. 132 // syncable share.
114 struct UserShare { 133 struct UserShare {
115 UserShare(); 134 UserShare();
116 ~UserShare(); 135 ~UserShare();
117 136
118 // The DirectoryManager itself, which is the parent of Transactions and can 137 // The DirectoryManager itself, which is the parent of Transactions and can
119 // be shared across multiple threads (unlike Directory). 138 // be shared across multiple threads (unlike Directory).
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 virtual void OnSyncCycleCompleted( 791 virtual void OnSyncCycleCompleted(
773 const browser_sync::sessions::SyncSessionSnapshot* snapshot) = 0; 792 const browser_sync::sessions::SyncSessionSnapshot* snapshot) = 0;
774 793
775 // Called when user interaction may be required due to an auth problem. 794 // Called when user interaction may be required due to an auth problem.
776 virtual void OnAuthError(const GoogleServiceAuthError& auth_error) = 0; 795 virtual void OnAuthError(const GoogleServiceAuthError& auth_error) = 0;
777 796
778 // Called when a new auth token is provided by the sync server. 797 // Called when a new auth token is provided by the sync server.
779 virtual void OnUpdatedToken(const std::string& token) = 0; 798 virtual void OnUpdatedToken(const std::string& token) = 0;
780 799
781 // Called when user interaction is required to obtain a valid passphrase. 800 // Called when user interaction is required to obtain a valid passphrase.
782 // If the passphrase is required to decrypt something that has 801 // - If the passphrase is required for encryption, |reason| will be
783 // already been encrypted (and thus has to match the existing key), 802 // REASON_ENCRYPTION.
784 // |for_decryption| will be true. If the passphrase is needed for 803 // - If the passphrase is required for the decryption of data that has
785 // encryption, |for_decryption| will be false. 804 // already been encrypted, |reason| will be REASON_DECRYPTION.
786 virtual void OnPassphraseRequired(bool for_decryption) = 0; 805 // - If the passphrase is required because decryption failed, and a new
787 806 // passphrase is required, |reason| will be REASON_SET_PASSPHRASE_FAILED.
788 // Called only by SyncInternal::SetPassphrase to indiciate that an attempted 807 virtual void OnPassphraseRequired(PassphraseRequiredReason reason) = 0;
789 // passphrase failed to decrypt pending keys. This is different from
790 // OnPassphraseRequired in that it denotes we finished an attempt to set
791 // a passphrase. OnPassphraseRequired means we have data we could not
792 // decrypt yet, and can come from numerous places.
793 virtual void OnPassphraseFailed() = 0;
794 808
795 // Called when the passphrase provided by the user has been accepted and is 809 // Called when the passphrase provided by the user has been accepted and is
796 // now used to encrypt sync data. |bootstrap_token| is an opaque base64 810 // now used to encrypt sync data. |bootstrap_token| is an opaque base64
797 // encoded representation of the key generated by the accepted passphrase, 811 // encoded representation of the key generated by the accepted passphrase,
798 // and is provided to the observer for persistence purposes and use in a 812 // and is provided to the observer for persistence purposes and use in a
799 // future initialization of sync (e.g. after restart). 813 // future initialization of sync (e.g. after restart).
800 virtual void OnPassphraseAccepted(const std::string& bootstrap_token) = 0; 814 virtual void OnPassphraseAccepted(const std::string& bootstrap_token) = 0;
801 815
802 // Called when initialization is complete to the point that SyncManager can 816 // Called when initialization is complete to the point that SyncManager can
803 // process changes. This does not necessarily mean authentication succeeded 817 // process changes. This does not necessarily mean authentication succeeded
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 private: 1022 private:
1009 // An opaque pointer to the nested private class. 1023 // An opaque pointer to the nested private class.
1010 SyncInternal* data_; 1024 SyncInternal* data_;
1011 1025
1012 DISALLOW_COPY_AND_ASSIGN(SyncManager); 1026 DISALLOW_COPY_AND_ASSIGN(SyncManager);
1013 }; 1027 };
1014 1028
1015 } // namespace sync_api 1029 } // namespace sync_api
1016 1030
1017 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_H_ 1031 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698