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

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

Issue 6537027: Revert 75287 - [Sync] Initial support for encrypting any datatype (no UI hook... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // changed in another synced client. if 81 // changed in another synced client. if
82 // |passphrase_required_for_decryption| is false, the passphrase is 82 // |passphrase_required_for_decryption| is false, the passphrase is
83 // required only for encryption. 83 // required only for encryption.
84 virtual void OnPassphraseRequired(bool for_decryption) = 0; 84 virtual void OnPassphraseRequired(bool for_decryption) = 0;
85 85
86 // Called when the passphrase provided by the user is 86 // Called when the passphrase provided by the user is
87 // accepted. After this is called, updates to sensitive nodes are 87 // accepted. After this is called, updates to sensitive nodes are
88 // encrypted using the accepted passphrase. 88 // encrypted using the accepted passphrase.
89 virtual void OnPassphraseAccepted() = 0; 89 virtual void OnPassphraseAccepted() = 0;
90 90
91 virtual void OnEncryptionComplete(
92 const syncable::ModelTypeSet& encrypted_types) = 0;
93
94 protected: 91 protected:
95 // Don't delete through SyncFrontend interface. 92 // Don't delete through SyncFrontend interface.
96 virtual ~SyncFrontend() { 93 virtual ~SyncFrontend() {
97 } 94 }
98 private: 95 private:
99 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); 96 DISALLOW_COPY_AND_ASSIGN(SyncFrontend);
100 }; 97 };
101 98
102 // A UI-thread safe API into the sync backend that "hosts" the top-level 99 // A UI-thread safe API into the sync backend that "hosts" the top-level
103 // syncapi element, the SyncManager, on its own thread. This class handles 100 // syncapi element, the SyncManager, on its own thread. This class handles
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 153
157 // Changes the set of data types that are currently being synced. 154 // Changes the set of data types that are currently being synced.
158 // The ready_task will be run when all of the requested data types 155 // The ready_task will be run when all of the requested data types
159 // are up-to-date and ready for activation. The task will cancelled 156 // are up-to-date and ready for activation. The task will cancelled
160 // upon shutdown. The method takes ownership of the task pointer. 157 // upon shutdown. The method takes ownership of the task pointer.
161 virtual void ConfigureDataTypes( 158 virtual void ConfigureDataTypes(
162 const DataTypeController::TypeMap& data_type_controllers, 159 const DataTypeController::TypeMap& data_type_controllers,
163 const syncable::ModelTypeSet& types, 160 const syncable::ModelTypeSet& types,
164 CancelableTask* ready_task); 161 CancelableTask* ready_task);
165 162
166 // Encrypts the specified datatypes and marks them as needing encryption on
167 // other machines. This affects all machines synced to this account and all
168 // data belonging to the specified types.
169 // Note: actual work is done on core_thread_'s message loop.
170 virtual void EncryptDataTypes(
171 const syncable::ModelTypeSet& encrypted_types);
172
173 syncable::AutofillMigrationState 163 syncable::AutofillMigrationState
174 GetAutofillMigrationState(); 164 GetAutofillMigrationState();
175 165
176 void SetAutofillMigrationState( 166 void SetAutofillMigrationState(
177 syncable::AutofillMigrationState state); 167 syncable::AutofillMigrationState state);
178 168
179 syncable::AutofillMigrationDebugInfo 169 syncable::AutofillMigrationDebugInfo
180 GetAutofillMigrationDebugInfo(); 170 GetAutofillMigrationDebugInfo();
181 171
182 void SetAutofillMigrationDebugInfo( 172 void SetAutofillMigrationDebugInfo(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 virtual void OnInitializationComplete(); 269 virtual void OnInitializationComplete();
280 virtual void OnAuthError(const GoogleServiceAuthError& auth_error); 270 virtual void OnAuthError(const GoogleServiceAuthError& auth_error);
281 virtual void OnPassphraseRequired(bool for_decryption); 271 virtual void OnPassphraseRequired(bool for_decryption);
282 virtual void OnPassphraseAccepted(const std::string& bootstrap_token); 272 virtual void OnPassphraseAccepted(const std::string& bootstrap_token);
283 virtual void OnPaused(); 273 virtual void OnPaused();
284 virtual void OnResumed(); 274 virtual void OnResumed();
285 virtual void OnStopSyncingPermanently(); 275 virtual void OnStopSyncingPermanently();
286 virtual void OnUpdatedToken(const std::string& token); 276 virtual void OnUpdatedToken(const std::string& token);
287 virtual void OnClearServerDataFailed(); 277 virtual void OnClearServerDataFailed();
288 virtual void OnClearServerDataSucceeded(); 278 virtual void OnClearServerDataSucceeded();
289 virtual void OnEncryptionComplete(
290 const syncable::ModelTypeSet& encrypted_types);
291 279
292 // JsBackend implementation. 280 // JsBackend implementation.
293 virtual void SetParentJsEventRouter(JsEventRouter* router); 281 virtual void SetParentJsEventRouter(JsEventRouter* router);
294 virtual void RemoveParentJsEventRouter(); 282 virtual void RemoveParentJsEventRouter();
295 virtual const JsEventRouter* GetParentJsEventRouter() const; 283 virtual const JsEventRouter* GetParentJsEventRouter() const;
296 virtual void ProcessMessage(const std::string& name, const JsArgList& args, 284 virtual void ProcessMessage(const std::string& name, const JsArgList& args,
297 const JsEventHandler* sender); 285 const JsEventHandler* sender);
298 286
299 // JsEventRouter implementation. 287 // JsEventRouter implementation.
300 virtual void RouteJsEvent(const std::string& event_name, 288 virtual void RouteJsEvent(const std::string& event_name,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // syncer. 336 // syncer.
349 void DoRequestNudge(); 337 void DoRequestNudge();
350 void DoRequestPause(); 338 void DoRequestPause();
351 void DoRequestResume(); 339 void DoRequestResume();
352 void DoRequestClearServerData(); 340 void DoRequestClearServerData();
353 341
354 // Called on our SyncBackendHost's |core_thread_| to set the passphrase 342 // Called on our SyncBackendHost's |core_thread_| to set the passphrase
355 // on behalf of SyncBackendHost::SupplyPassphrase. 343 // on behalf of SyncBackendHost::SupplyPassphrase.
356 void DoSetPassphrase(const std::string& passphrase, bool is_explicit); 344 void DoSetPassphrase(const std::string& passphrase, bool is_explicit);
357 345
358 // Called on SyncBackendHost's |core_thread_| to set the datatypes we need
359 // to encrypt as well as encrypt all local data of that type.
360 void DoEncryptDataTypes(const syncable::ModelTypeSet& encrypted_types);
361
362 // The shutdown order is a bit complicated: 346 // The shutdown order is a bit complicated:
363 // 1) From |core_thread_|, invoke the syncapi Shutdown call to do a final 347 // 1) From |core_thread_|, invoke the syncapi Shutdown call to do a final
364 // SaveChanges, close sqlite handles, and halt the syncer thread (which 348 // SaveChanges, close sqlite handles, and halt the syncer thread (which
365 // could potentially block for 1 minute). 349 // could potentially block for 1 minute).
366 // 2) Then, from |frontend_loop_|, halt the core_thread_. This causes 350 // 2) Then, from |frontend_loop_|, halt the core_thread_. This causes
367 // syncapi thread-exit handlers to run and make use of cached pointers to 351 // syncapi thread-exit handlers to run and make use of cached pointers to
368 // various components owned implicitly by us. 352 // various components owned implicitly by us.
369 // 3) Destroy this Core. That will delete syncapi components in a safe order 353 // 3) Destroy this Core. That will delete syncapi components in a safe order
370 // because the thread that was using them has exited (in step 2). 354 // because the thread that was using them has exited (in step 2).
371 void DoShutdown(bool stopping_sync); 355 void DoShutdown(bool stopping_sync);
(...skipping 17 matching lines...) Expand all
389 const std::string& name, const JsArgList& args, 373 const std::string& name, const JsArgList& args,
390 const JsEventHandler* sender); 374 const JsEventHandler* sender);
391 375
392 #if defined(UNIT_TEST) 376 #if defined(UNIT_TEST)
393 // Special form of initialization that does not try and authenticate the 377 // Special form of initialization that does not try and authenticate the
394 // last known user (since it will fail in test mode) and does some extra 378 // last known user (since it will fail in test mode) and does some extra
395 // setup to nudge the syncapi into a usable state. 379 // setup to nudge the syncapi into a usable state.
396 void DoInitializeForTest(const std::wstring& test_user, 380 void DoInitializeForTest(const std::wstring& test_user,
397 sync_api::HttpPostProviderFactory* factory, 381 sync_api::HttpPostProviderFactory* factory,
398 bool delete_sync_data_folder) { 382 bool delete_sync_data_folder) {
383
399 // Construct dummy credentials for test. 384 // Construct dummy credentials for test.
400 sync_api::SyncCredentials credentials; 385 sync_api::SyncCredentials credentials;
401 credentials.email = WideToUTF8(test_user); 386 credentials.email = WideToUTF8(test_user);
402 credentials.sync_token = "token"; 387 credentials.sync_token = "token";
403 DoInitialize(DoInitializeOptions(GURL(), factory, credentials, 388 DoInitialize(DoInitializeOptions(GURL(), factory, credentials,
404 delete_sync_data_folder, 389 delete_sync_data_folder,
405 notifier::NotifierOptions(), "", true)); 390 notifier::NotifierOptions(), "", true));
406 } 391 }
407 #endif 392 #endif
408 393
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // or for encrypting. If the reason is decryption, |for_decryption| will 432 // or for encrypting. If the reason is decryption, |for_decryption| will
448 // be true. 433 // be true.
449 void NotifyPassphraseRequired(bool for_decryption); 434 void NotifyPassphraseRequired(bool for_decryption);
450 435
451 // Invoked when the passphrase provided by the user has been accepted. 436 // Invoked when the passphrase provided by the user has been accepted.
452 void NotifyPassphraseAccepted(const std::string& bootstrap_token); 437 void NotifyPassphraseAccepted(const std::string& bootstrap_token);
453 438
454 // Invoked when an updated token is available from the sync server. 439 // Invoked when an updated token is available from the sync server.
455 void NotifyUpdatedToken(const std::string& token); 440 void NotifyUpdatedToken(const std::string& token);
456 441
457 // Invoked when sync finishes encrypting new datatypes or has become aware
458 // of new datatypes requiring encryption.
459 void NotifyEncryptionComplete(const syncable::ModelTypeSet&
460 encrypted_types);
461
462 // Called from Core::OnSyncCycleCompleted to handle updating frontend 442 // Called from Core::OnSyncCycleCompleted to handle updating frontend
463 // thread components. 443 // thread components.
464 void HandleSyncCycleCompletedOnFrontendLoop( 444 void HandleSyncCycleCompletedOnFrontendLoop(
465 sessions::SyncSessionSnapshot* snapshot); 445 sessions::SyncSessionSnapshot* snapshot);
466 446
467 void HandleStopSyncingPermanentlyOnFrontendLoop(); 447 void HandleStopSyncingPermanentlyOnFrontendLoop();
468 448
469 // Called to handle success/failure of clearing server data 449 // Called to handle success/failure of clearing server data
470 void HandleClearServerDataSucceededOnFrontendLoop(); 450 void HandleClearServerDataSucceededOnFrontendLoop();
471 void HandleClearServerDataFailedOnFrontendLoop(); 451 void HandleClearServerDataFailedOnFrontendLoop();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // across browser restart to avoid requiring the user to re-enter their 500 // across browser restart to avoid requiring the user to re-enter their
521 // passphrase. |token| must be valid UTF-8 as we use the PrefService for 501 // passphrase. |token| must be valid UTF-8 as we use the PrefService for
522 // storage. 502 // storage.
523 void PersistEncryptionBootstrapToken(const std::string& token); 503 void PersistEncryptionBootstrapToken(const std::string& token);
524 std::string RestoreEncryptionBootstrapToken(); 504 std::string RestoreEncryptionBootstrapToken();
525 505
526 // Our core, which communicates directly to the syncapi. 506 // Our core, which communicates directly to the syncapi.
527 scoped_refptr<Core> core_; 507 scoped_refptr<Core> core_;
528 508
529 private: 509 private:
510
530 UIModelWorker* ui_worker(); 511 UIModelWorker* ui_worker();
531 512
532 void ConfigureAutofillMigration(); 513 void ConfigureAutofillMigration();
533 514
534 // A thread we dedicate for use by our Core to perform initialization, 515 // A thread we dedicate for use by our Core to perform initialization,
535 // authentication, handle messages from the syncapi, and periodically tell 516 // authentication, handle messages from the syncapi, and periodically tell
536 // the syncapi to persist itself. 517 // the syncapi to persist itself.
537 base::Thread core_thread_; 518 base::Thread core_thread_;
538 519
539 // A reference to the MessageLoop used to construct |this|, so we know how 520 // 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
593 574
594 // Whether we've processed the initialization complete callback. 575 // Whether we've processed the initialization complete callback.
595 bool syncapi_initialized_; 576 bool syncapi_initialized_;
596 577
597 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); 578 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
598 }; 579 };
599 580
600 } // namespace browser_sync 581 } // namespace browser_sync
601 582
602 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ 583 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_model_associator_unittest.cc ('k') | chrome/browser/sync/glue/sync_backend_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698