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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.h

Issue 6465005: [Sync] Initial support for encrypting any datatype (no UI hookup yet). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_GLUE_SYNC_BACKEND_HOST_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // changed in another synced client. if 77 // changed in another synced client. if
78 // |passphrase_required_for_decryption| is false, the passphrase is 78 // |passphrase_required_for_decryption| is false, the passphrase is
79 // required only for encryption. 79 // required only for encryption.
80 virtual void OnPassphraseRequired(bool for_decryption) = 0; 80 virtual void OnPassphraseRequired(bool for_decryption) = 0;
81 81
82 // Called when the passphrase provided by the user is 82 // Called when the passphrase provided by the user is
83 // accepted. After this is called, updates to sensitive nodes are 83 // accepted. After this is called, updates to sensitive nodes are
84 // encrypted using the accepted passphrase. 84 // encrypted using the accepted passphrase.
85 virtual void OnPassphraseAccepted() = 0; 85 virtual void OnPassphraseAccepted() = 0;
86 86
87 virtual void OnEncryptionComplete(
88 const syncable::ModelTypeSet& encrypted_types) = 0;
89
87 protected: 90 protected:
88 // Don't delete through SyncFrontend interface. 91 // Don't delete through SyncFrontend interface.
89 virtual ~SyncFrontend() { 92 virtual ~SyncFrontend() {
90 } 93 }
91 private: 94 private:
92 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); 95 DISALLOW_COPY_AND_ASSIGN(SyncFrontend);
93 }; 96 };
94 97
95 // A UI-thread safe API into the sync backend that "hosts" the top-level 98 // A UI-thread safe API into the sync backend that "hosts" the top-level
96 // syncapi element, the SyncManager, on its own thread. This class handles 99 // syncapi element, the SyncManager, on its own thread. This class handles
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 150
148 // Changes the set of data types that are currently being synced. 151 // Changes the set of data types that are currently being synced.
149 // The ready_task will be run when all of the requested data types 152 // The ready_task will be run when all of the requested data types
150 // are up-to-date and ready for activation. The task will cancelled 153 // are up-to-date and ready for activation. The task will cancelled
151 // upon shutdown. The method takes ownership of the task pointer. 154 // upon shutdown. The method takes ownership of the task pointer.
152 virtual void ConfigureDataTypes( 155 virtual void ConfigureDataTypes(
153 const DataTypeController::TypeMap& data_type_controllers, 156 const DataTypeController::TypeMap& data_type_controllers,
154 const syncable::ModelTypeSet& types, 157 const syncable::ModelTypeSet& types,
155 CancelableTask* ready_task); 158 CancelableTask* ready_task);
156 159
160 // Encrypts the specified datatypes and marks them as needing encryption on
161 // other machines. This affects all machines synced to this account and all
162 // data belonging to the specified types. |encrypted_types| must be a subset
163 // of the enabled datatypes.
164 // Note: actual work is done on core_thread_'s message loop.
165 virtual void EncryptDataTypes(
166 const syncable::ModelTypeSet& encrypted_types);
167
157 syncable::AutofillMigrationState 168 syncable::AutofillMigrationState
158 GetAutofillMigrationState(); 169 GetAutofillMigrationState();
159 170
160 void SetAutofillMigrationState( 171 void SetAutofillMigrationState(
161 syncable::AutofillMigrationState state); 172 syncable::AutofillMigrationState state);
162 173
163 syncable::AutofillMigrationDebugInfo 174 syncable::AutofillMigrationDebugInfo
164 GetAutofillMigrationDebugInfo(); 175 GetAutofillMigrationDebugInfo();
165 176
166 void SetAutofillMigrationDebugInfo( 177 void SetAutofillMigrationDebugInfo(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 virtual void OnInitializationComplete(); 263 virtual void OnInitializationComplete();
253 virtual void OnAuthError(const GoogleServiceAuthError& auth_error); 264 virtual void OnAuthError(const GoogleServiceAuthError& auth_error);
254 virtual void OnPassphraseRequired(bool for_decryption); 265 virtual void OnPassphraseRequired(bool for_decryption);
255 virtual void OnPassphraseAccepted(const std::string& bootstrap_token); 266 virtual void OnPassphraseAccepted(const std::string& bootstrap_token);
256 virtual void OnPaused(); 267 virtual void OnPaused();
257 virtual void OnResumed(); 268 virtual void OnResumed();
258 virtual void OnStopSyncingPermanently(); 269 virtual void OnStopSyncingPermanently();
259 virtual void OnUpdatedToken(const std::string& token); 270 virtual void OnUpdatedToken(const std::string& token);
260 virtual void OnClearServerDataFailed(); 271 virtual void OnClearServerDataFailed();
261 virtual void OnClearServerDataSucceeded(); 272 virtual void OnClearServerDataSucceeded();
273 virtual void OnEncryptionComplete(
274 const syncable::ModelTypeSet& encrypted_types);
262 275
263 struct DoInitializeOptions { 276 struct DoInitializeOptions {
264 DoInitializeOptions( 277 DoInitializeOptions(
265 const GURL& service_url, 278 const GURL& service_url,
266 sync_api::HttpPostProviderFactory* http_bridge_factory, 279 sync_api::HttpPostProviderFactory* http_bridge_factory,
267 const sync_api::SyncCredentials& credentials, 280 const sync_api::SyncCredentials& credentials,
268 bool delete_sync_data_folder, 281 bool delete_sync_data_folder,
269 const notifier::NotifierOptions& notifier_options, 282 const notifier::NotifierOptions& notifier_options,
270 std::string restored_key_for_bootstrapping, 283 std::string restored_key_for_bootstrapping,
271 bool setup_for_test_mode); 284 bool setup_for_test_mode);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // syncer. 316 // syncer.
304 void DoRequestNudge(); 317 void DoRequestNudge();
305 void DoRequestPause(); 318 void DoRequestPause();
306 void DoRequestResume(); 319 void DoRequestResume();
307 void DoRequestClearServerData(); 320 void DoRequestClearServerData();
308 321
309 // Called on our SyncBackendHost's |core_thread_| to set the passphrase 322 // Called on our SyncBackendHost's |core_thread_| to set the passphrase
310 // on behalf of SyncBackendHost::SupplyPassphrase. 323 // on behalf of SyncBackendHost::SupplyPassphrase.
311 void DoSetPassphrase(const std::string& passphrase, bool is_explicit); 324 void DoSetPassphrase(const std::string& passphrase, bool is_explicit);
312 325
326 // Called on SyncBackendHost's |core_thread_| to set the datatypes we need
327 // to encrypt as well as encrypt all local data of that type.
328 void DoEncryptDataTypes(const syncable::ModelTypeSet& encrypted_types);
329
313 // The shutdown order is a bit complicated: 330 // The shutdown order is a bit complicated:
314 // 1) From |core_thread_|, invoke the syncapi Shutdown call to do a final 331 // 1) From |core_thread_|, invoke the syncapi Shutdown call to do a final
315 // SaveChanges, close sqlite handles, and halt the syncer thread (which 332 // SaveChanges, close sqlite handles, and halt the syncer thread (which
316 // could potentially block for 1 minute). 333 // could potentially block for 1 minute).
317 // 2) Then, from |frontend_loop_|, halt the core_thread_. This causes 334 // 2) Then, from |frontend_loop_|, halt the core_thread_. This causes
318 // syncapi thread-exit handlers to run and make use of cached pointers to 335 // syncapi thread-exit handlers to run and make use of cached pointers to
319 // various components owned implicitly by us. 336 // various components owned implicitly by us.
320 // 3) Destroy this Core. That will delete syncapi components in a safe order 337 // 3) Destroy this Core. That will delete syncapi components in a safe order
321 // because the thread that was using them has exited (in step 2). 338 // because the thread that was using them has exited (in step 2).
322 void DoShutdown(bool stopping_sync); 339 void DoShutdown(bool stopping_sync);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // or for encrypting. If the reason is decryption, |for_decryption| will 408 // or for encrypting. If the reason is decryption, |for_decryption| will
392 // be true. 409 // be true.
393 void NotifyPassphraseRequired(bool for_decryption); 410 void NotifyPassphraseRequired(bool for_decryption);
394 411
395 // Invoked when the passphrase provided by the user has been accepted. 412 // Invoked when the passphrase provided by the user has been accepted.
396 void NotifyPassphraseAccepted(const std::string& bootstrap_token); 413 void NotifyPassphraseAccepted(const std::string& bootstrap_token);
397 414
398 // Invoked when an updated token is available from the sync server. 415 // Invoked when an updated token is available from the sync server.
399 void NotifyUpdatedToken(const std::string& token); 416 void NotifyUpdatedToken(const std::string& token);
400 417
418 // Invoked when sync finishes encrypting new datatypes or has become aware
419 // of new datatypes requiring encryption.
420 void NotifyEncryptionComplete(const syncable::ModelTypeSet&
421 encrypted_types);
422
401 // Called from Core::OnSyncCycleCompleted to handle updating frontend 423 // Called from Core::OnSyncCycleCompleted to handle updating frontend
402 // thread components. 424 // thread components.
403 void HandleSyncCycleCompletedOnFrontendLoop( 425 void HandleSyncCycleCompletedOnFrontendLoop(
404 sessions::SyncSessionSnapshot* snapshot); 426 sessions::SyncSessionSnapshot* snapshot);
405 427
406 void HandleStopSyncingPermanentlyOnFrontendLoop(); 428 void HandleStopSyncingPermanentlyOnFrontendLoop();
407 429
408 // Called to handle success/failure of clearing server data 430 // Called to handle success/failure of clearing server data
409 void HandleClearServerDataSucceededOnFrontendLoop(); 431 void HandleClearServerDataSucceededOnFrontendLoop();
410 void HandleClearServerDataFailedOnFrontendLoop(); 432 void HandleClearServerDataFailedOnFrontendLoop();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // across browser restart to avoid requiring the user to re-enter their 476 // across browser restart to avoid requiring the user to re-enter their
455 // passphrase. |token| must be valid UTF-8 as we use the PrefService for 477 // passphrase. |token| must be valid UTF-8 as we use the PrefService for
456 // storage. 478 // storage.
457 void PersistEncryptionBootstrapToken(const std::string& token); 479 void PersistEncryptionBootstrapToken(const std::string& token);
458 std::string RestoreEncryptionBootstrapToken(); 480 std::string RestoreEncryptionBootstrapToken();
459 481
460 // Our core, which communicates directly to the syncapi. 482 // Our core, which communicates directly to the syncapi.
461 scoped_refptr<Core> core_; 483 scoped_refptr<Core> core_;
462 484
463 private: 485 private:
464
465 UIModelWorker* ui_worker(); 486 UIModelWorker* ui_worker();
466 487
467 void ConfigureAutofillMigration(); 488 void ConfigureAutofillMigration();
468 489
469 // A thread we dedicate for use by our Core to perform initialization, 490 // A thread we dedicate for use by our Core to perform initialization,
470 // authentication, handle messages from the syncapi, and periodically tell 491 // authentication, handle messages from the syncapi, and periodically tell
471 // the syncapi to persist itself. 492 // the syncapi to persist itself.
472 base::Thread core_thread_; 493 base::Thread core_thread_;
473 494
474 // A reference to the MessageLoop used to construct |this|, so we know how 495 // A reference to the MessageLoop used to construct |this|, so we know how
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 549
529 // Whether we've processed the initialization complete callback. 550 // Whether we've processed the initialization complete callback.
530 bool syncapi_initialized_; 551 bool syncapi_initialized_;
531 552
532 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 553 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
533 }; 554 };
534 555
535 } // namespace browser_sync 556 } // namespace browser_sync
536 557
537 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 558 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698