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

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: Remove OnPassphraseFailed; Plumb enum all the way through; Shave yak. 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 UNKNOWN = 0, // Initial value
113 ENCRYPTION = 1, // The cryptographer requires a passphrase for
tim (not reviewing) 2011/04/29 01:21:48 Since this is in the syncapi ns, we should probabl
Raghu Simha 2011/04/29 18:59:14 Done.
114 // its first attempt at encryption.
115 DECRYPTION = 2, // The cryptographer requires a passphrase for
116 // its first attempt at decryption.
117 DECRYPTION_FAILED = 3, // The cryptographer requires a new passphrase
tim (not reviewing) 2011/04/29 01:21:48 SET_PASSPHRASE_FAILED
Raghu Simha 2011/04/29 18:59:14 Done.
118 // because its attempt at decryption with the
119 // cached passphrase was unsuccessful.
120 };
121
122 // Returns the string representation of a PassphraseRequiredReason value.
123 std::string PassphraseRequiredReasonToString(PassphraseRequiredReason reason) {
124 switch (reason) {
125 case UNKNOWN:
126 return "UNKNOWN";
127 case ENCRYPTION:
128 return "ENCRYPTION";
129 case DECRYPTION:
130 return "DECRYPTION";
131 case DECRYPTION_FAILED:
132 return "DECRYPTION_FAILED";
133 default:
134 NOTREACHED();
135 return "INVALID_REASON";
136 }
137 }
138
110 // A UserShare encapsulates the syncable pieces that represent an authenticated 139 // A UserShare encapsulates the syncable pieces that represent an authenticated
111 // user and their data (share). 140 // user and their data (share).
112 // This encompasses all pieces required to build transaction objects on the 141 // This encompasses all pieces required to build transaction objects on the
113 // syncable share. 142 // syncable share.
114 struct UserShare { 143 struct UserShare {
115 UserShare(); 144 UserShare();
116 ~UserShare(); 145 ~UserShare();
117 146
118 // The DirectoryManager itself, which is the parent of Transactions and can 147 // The DirectoryManager itself, which is the parent of Transactions and can
119 // be shared across multiple threads (unlike Directory). 148 // be shared across multiple threads (unlike Directory).
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 virtual void OnSyncCycleCompleted( 801 virtual void OnSyncCycleCompleted(
773 const browser_sync::sessions::SyncSessionSnapshot* snapshot) = 0; 802 const browser_sync::sessions::SyncSessionSnapshot* snapshot) = 0;
774 803
775 // Called when user interaction may be required due to an auth problem. 804 // Called when user interaction may be required due to an auth problem.
776 virtual void OnAuthError(const GoogleServiceAuthError& auth_error) = 0; 805 virtual void OnAuthError(const GoogleServiceAuthError& auth_error) = 0;
777 806
778 // Called when a new auth token is provided by the sync server. 807 // Called when a new auth token is provided by the sync server.
779 virtual void OnUpdatedToken(const std::string& token) = 0; 808 virtual void OnUpdatedToken(const std::string& token) = 0;
780 809
781 // Called when user interaction is required to obtain a valid passphrase. 810 // Called when user interaction is required to obtain a valid passphrase.
782 // If the passphrase is required to decrypt something that has 811 // - If the passphrase is required for encryption, |reason| is ENCRYPTION.
783 // already been encrypted (and thus has to match the existing key), 812 // - If the passphrase is required for the decryption of data that has
784 // |for_decryption| will be true. If the passphrase is needed for 813 // already been encrypted, |reason| will be DECRYPTION.
785 // encryption, |for_decryption| will be false. 814 // - If the passphrase is required because decryption failed, and a new
786 virtual void OnPassphraseRequired(bool for_decryption) = 0; 815 // passphrase is required, |reason| will be DECRYPTION_FAILED.
787 816 virtual void OnPassphraseRequired(PassphraseRequiredReason reason) = 0;
788 // Called only by SyncInternal::SetPassphrase to indiciate that an attempted
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 817
795 // Called when the passphrase provided by the user has been accepted and is 818 // 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 819 // now used to encrypt sync data. |bootstrap_token| is an opaque base64
797 // encoded representation of the key generated by the accepted passphrase, 820 // encoded representation of the key generated by the accepted passphrase,
798 // and is provided to the observer for persistence purposes and use in a 821 // and is provided to the observer for persistence purposes and use in a
799 // future initialization of sync (e.g. after restart). 822 // future initialization of sync (e.g. after restart).
800 virtual void OnPassphraseAccepted(const std::string& bootstrap_token) = 0; 823 virtual void OnPassphraseAccepted(const std::string& bootstrap_token) = 0;
801 824
802 // Called when initialization is complete to the point that SyncManager can 825 // Called when initialization is complete to the point that SyncManager can
803 // process changes. This does not necessarily mean authentication succeeded 826 // process changes. This does not necessarily mean authentication succeeded
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 private: 1033 private:
1011 // An opaque pointer to the nested private class. 1034 // An opaque pointer to the nested private class.
1012 SyncInternal* data_; 1035 SyncInternal* data_;
1013 1036
1014 DISALLOW_COPY_AND_ASSIGN(SyncManager); 1037 DISALLOW_COPY_AND_ASSIGN(SyncManager);
1015 }; 1038 };
1016 1039
1017 } // namespace sync_api 1040 } // namespace sync_api
1018 1041
1019 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_H_ 1042 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/engine/syncapi.cc » ('j') | chrome/browser/sync/js_sync_manager_observer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698