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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_impl.h

Issue 2663783002: [Sync] Split encryption state and logic out of PSS and SBHI. (Closed)
Patch Set: Tweak comment. Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 ~SyncBackendHostImpl() override; 57 ~SyncBackendHostImpl() override;
58 58
59 // SyncEngine implementation. 59 // SyncEngine implementation.
60 void Initialize(InitParams params) override; 60 void Initialize(InitParams params) override;
61 void TriggerRefresh(const ModelTypeSet& types) override; 61 void TriggerRefresh(const ModelTypeSet& types) override;
62 void UpdateCredentials(const SyncCredentials& credentials) override; 62 void UpdateCredentials(const SyncCredentials& credentials) override;
63 void StartConfiguration() override; 63 void StartConfiguration() override;
64 void StartSyncingWithServer() override; 64 void StartSyncingWithServer() override;
65 void SetEncryptionPassphrase(const std::string& passphrase, 65 void SetEncryptionPassphrase(const std::string& passphrase,
66 bool is_explicit) override; 66 bool is_explicit) override;
67 bool SetDecryptionPassphrase(const std::string& passphrase) override 67 void SetDecryptionPassphrase(const std::string& passphrase) override;
68 WARN_UNUSED_RESULT;
69 void StopSyncingForShutdown() override; 68 void StopSyncingForShutdown() override;
70 void Shutdown(ShutdownReason reason) override; 69 void Shutdown(ShutdownReason reason) override;
71 void ConfigureDataTypes(ConfigureParams params) override; 70 void ConfigureDataTypes(ConfigureParams params) override;
72 void RegisterDirectoryDataType(ModelType type, ModelSafeGroup group) override; 71 void RegisterDirectoryDataType(ModelType type, ModelSafeGroup group) override;
73 void UnregisterDirectoryDataType(ModelType type) override; 72 void UnregisterDirectoryDataType(ModelType type) override;
74 void ActivateDirectoryDataType(ModelType type, 73 void ActivateDirectoryDataType(ModelType type,
75 ModelSafeGroup group, 74 ModelSafeGroup group,
76 ChangeProcessor* change_processor) override; 75 ChangeProcessor* change_processor) override;
77 void DeactivateDirectoryDataType(ModelType type) override; 76 void DeactivateDirectoryDataType(ModelType type) override;
78 void ActivateNonBlockingDataType(ModelType type, 77 void ActivateNonBlockingDataType(ModelType type,
79 std::unique_ptr<ActivationContext>) override; 78 std::unique_ptr<ActivationContext>) override;
80 void DeactivateNonBlockingDataType(ModelType type) override; 79 void DeactivateNonBlockingDataType(ModelType type) override;
81 void EnableEncryptEverything() override; 80 void EnableEncryptEverything() override;
82 UserShare* GetUserShare() const override; 81 UserShare* GetUserShare() const override;
83 Status GetDetailedStatus() override; 82 Status GetDetailedStatus() override;
84 bool HasUnsyncedItems() const override; 83 bool HasUnsyncedItems() const override;
85 bool IsNigoriEnabled() const override;
86 PassphraseType GetPassphraseType() const override;
87 base::Time GetExplicitPassphraseTime() const override;
88 bool IsCryptographerReady(const BaseTransaction* trans) const override; 84 bool IsCryptographerReady(const BaseTransaction* trans) const override;
89 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const override; 85 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) const override;
90 void FlushDirectory() const override; 86 void FlushDirectory() const override;
91 void RequestBufferedProtocolEventsAndEnableForwarding() override; 87 void RequestBufferedProtocolEventsAndEnableForwarding() override;
92 void DisableProtocolEventForwarding() override; 88 void DisableProtocolEventForwarding() override;
93 void EnableDirectoryTypeDebugInfoForwarding() override; 89 void EnableDirectoryTypeDebugInfoForwarding() override;
94 void DisableDirectoryTypeDebugInfoForwarding() override; 90 void DisableDirectoryTypeDebugInfoForwarding() override;
95 void RefreshTypesForTest(ModelTypeSet types) override; 91 void RefreshTypesForTest(ModelTypeSet types) override;
96 void ClearServerData( 92 void ClearServerData(
97 const SyncManager::ClearServerDataCallback& callback) override; 93 const SyncManager::ClearServerDataCallback& callback) override;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Called from Core::OnSyncCycleCompleted to handle updating frontend 169 // Called from Core::OnSyncCycleCompleted to handle updating frontend
174 // thread components. 170 // thread components.
175 void HandleSyncCycleCompletedOnFrontendLoop( 171 void HandleSyncCycleCompletedOnFrontendLoop(
176 const SyncCycleSnapshot& snapshot); 172 const SyncCycleSnapshot& snapshot);
177 173
178 // Called when the syncer failed to perform a configuration and will 174 // Called when the syncer failed to perform a configuration and will
179 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called 175 // eventually retry. FinishingConfigurationOnFrontendLoop(..) will be called
180 // on successful completion. 176 // on successful completion.
181 void RetryConfigurationOnFrontendLoop(const base::Closure& retry_callback); 177 void RetryConfigurationOnFrontendLoop(const base::Closure& retry_callback);
182 178
183 // Helpers to persist a token that can be used to bootstrap sync encryption
184 // across browser restart to avoid requiring the user to re-enter their
185 // passphrase. |token| must be valid UTF-8 as we use the PrefService for
186 // storage.
187 void PersistEncryptionBootstrapToken(const std::string& token,
188 BootstrapTokenType token_type);
189
190 // For convenience, checks if initialization state is INITIALIZED. 179 // For convenience, checks if initialization state is INITIALIZED.
191 bool initialized() const { return initialized_; } 180 bool initialized() const { return initialized_; }
192 181
193 // Let the front end handle the actionable error event. 182 // Let the front end handle the actionable error event.
194 void HandleActionableErrorEventOnFrontendLoop( 183 void HandleActionableErrorEventOnFrontendLoop(
195 const SyncProtocolError& sync_error); 184 const SyncProtocolError& sync_error);
196 185
197 // Handle a migration request. 186 // Handle a migration request.
198 void HandleMigrationRequestedOnFrontendLoop(const ModelTypeSet types); 187 void HandleMigrationRequestedOnFrontendLoop(const ModelTypeSet types);
199 188
200 // Checks if |passphrase| can be used to decrypt the cryptographer's pending
201 // keys that were cached during NotifyPassphraseRequired. Returns true if
202 // decryption was successful. Returns false otherwise. Must be called with a
203 // non-empty pending keys cache.
204 bool CheckPassphraseAgainstCachedPendingKeys(
205 const std::string& passphrase) const;
206
207 // Invoked when a passphrase is required to decrypt a set of Nigori keys,
208 // or for encrypting. |reason| denotes why the passphrase was required.
209 // |pending_keys| is a copy of the cryptographer's pending keys, that are
210 // cached by the frontend. If there are no pending keys, or if the passphrase
211 // required reason is REASON_ENCRYPTION, an empty EncryptedData object is
212 // passed.
213 void NotifyPassphraseRequired(PassphraseRequiredReason reason,
214 sync_pb::EncryptedData pending_keys);
215
216 // Invoked when the passphrase provided by the user has been accepted.
217 void NotifyPassphraseAccepted();
218
219 // Invoked when the set of encrypted types or the encrypt
220 // everything flag changes.
221 void NotifyEncryptedTypesChanged(ModelTypeSet encrypted_types,
222 bool encrypt_everything);
223
224 // Invoked when sync finishes encrypting new datatypes.
225 void NotifyEncryptionComplete();
226
227 // Invoked when the passphrase state has changed. Caches the passphrase state
228 // for later use on the UI thread.
229 // If |type| is FROZEN_IMPLICIT_PASSPHRASE or CUSTOM_PASSPHRASE,
230 // |explicit_passphrase_time| is the time at which that passphrase was set
231 // (if available).
232 void HandlePassphraseTypeChangedOnFrontendLoop(
233 PassphraseType type,
234 base::Time explicit_passphrase_time);
235
236 void HandleLocalSetPassphraseEncryptionOnFrontendLoop(
237 const SyncEncryptionHandler::NigoriState& nigori_state);
238
239 // Dispatched to from OnConnectionStatusChange to handle updating 189 // Dispatched to from OnConnectionStatusChange to handle updating
240 // frontend UI components. 190 // frontend UI components.
241 void HandleConnectionStatusChangeOnFrontendLoop(ConnectionStatus status); 191 void HandleConnectionStatusChangeOnFrontendLoop(ConnectionStatus status);
242 192
243 void ClearServerDataDoneOnFrontendLoop( 193 void ClearServerDataDoneOnFrontendLoop(
244 const SyncManager::ClearServerDataCallback& frontend_callback); 194 const SyncManager::ClearServerDataCallback& frontend_callback);
245 195
246 SyncClient* const sync_client_; 196 SyncClient* const sync_client_;
247 197
248 // The task runner where all the sync engine operations happen. 198 // The task runner where all the sync engine operations happen.
(...skipping 15 matching lines...) Expand all
264 214
265 const base::WeakPtr<SyncPrefs> sync_prefs_; 215 const base::WeakPtr<SyncPrefs> sync_prefs_;
266 216
267 // The host which we serve (and are owned by). Set in Initialize() and nulled 217 // The host which we serve (and are owned by). Set in Initialize() and nulled
268 // out in StopSyncingForShutdown(). 218 // out in StopSyncingForShutdown().
269 SyncEngineHost* host_ = nullptr; 219 SyncEngineHost* host_ = nullptr;
270 220
271 // A pointer to the registrar; owned by |core_|. 221 // A pointer to the registrar; owned by |core_|.
272 SyncBackendRegistrar* registrar_ = nullptr; 222 SyncBackendRegistrar* registrar_ = nullptr;
273 223
274 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired
275 // is called. This way, before the UI calls SetDecryptionPassphrase on the
276 // syncer, it can avoid the overhead of an asynchronous decryption call and
277 // give the user immediate feedback about the passphrase entered by first
278 // trying to decrypt the cached pending keys on the UI thread. Note that
279 // SetDecryptionPassphrase can still fail after the cached pending keys are
280 // successfully decrypted if the pending keys have changed since the time they
281 // were cached.
282 sync_pb::EncryptedData cached_pending_keys_;
283
284 // The state of the passphrase required to decrypt the bag of encryption keys
285 // in the nigori node. Updated whenever a new nigori node arrives or the user
286 // manually changes their passphrase state. Cached so we can synchronously
287 // check it from the UI thread.
288 PassphraseType cached_passphrase_type_ = PassphraseType::IMPLICIT_PASSPHRASE;
289
290 // If an explicit passphrase is in use, the time at which the passphrase was
291 // first set (if available).
292 base::Time cached_explicit_passphrase_time_;
293
294 invalidation::InvalidationService* invalidator_; 224 invalidation::InvalidationService* invalidator_;
295 bool invalidation_handler_registered_ = false; 225 bool invalidation_handler_registered_ = false;
296 226
297 // Checks that we're on the same thread this was constructed on (UI thread). 227 // Checks that we're on the same thread this was constructed on (UI thread).
298 base::ThreadChecker thread_checker_; 228 base::ThreadChecker thread_checker_;
299 229
300 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_; 230 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_;
301 231
302 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl); 232 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl);
303 }; 233 };
304 234
305 } // namespace syncer 235 } // namespace syncer
306 236
307 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ 237 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_core.cc ('k') | components/sync/driver/glue/sync_backend_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698