| OLD | NEW |
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // changed in another synced client. if | 80 // changed in another synced client. if |
| 81 // |passphrase_required_for_decryption| is false, the passphrase is | 81 // |passphrase_required_for_decryption| is false, the passphrase is |
| 82 // required only for encryption. | 82 // required only for encryption. |
| 83 virtual void OnPassphraseRequired(bool for_decryption) = 0; | 83 virtual void OnPassphraseRequired(bool for_decryption) = 0; |
| 84 | 84 |
| 85 // Called when the passphrase provided by the user is | 85 // Called when the passphrase provided by the user is |
| 86 // accepted. After this is called, updates to sensitive nodes are | 86 // accepted. After this is called, updates to sensitive nodes are |
| 87 // encrypted using the accepted passphrase. | 87 // encrypted using the accepted passphrase. |
| 88 virtual void OnPassphraseAccepted() = 0; | 88 virtual void OnPassphraseAccepted() = 0; |
| 89 | 89 |
| 90 virtual void OnEncryptionComplete( |
| 91 const syncable::ModelTypeSet& encrypted_types) = 0; |
| 92 |
| 90 protected: | 93 protected: |
| 91 // Don't delete through SyncFrontend interface. | 94 // Don't delete through SyncFrontend interface. |
| 92 virtual ~SyncFrontend() { | 95 virtual ~SyncFrontend() { |
| 93 } | 96 } |
| 94 private: | 97 private: |
| 95 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); | 98 DISALLOW_COPY_AND_ASSIGN(SyncFrontend); |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 // A UI-thread safe API into the sync backend that "hosts" the top-level | 101 // A UI-thread safe API into the sync backend that "hosts" the top-level |
| 99 // syncapi element, the SyncManager, on its own thread. This class handles | 102 // syncapi element, the SyncManager, on its own thread. This class handles |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 153 |
| 151 // Changes the set of data types that are currently being synced. | 154 // Changes the set of data types that are currently being synced. |
| 152 // 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 |
| 153 // 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 |
| 154 // upon shutdown. The method takes ownership of the task pointer. | 157 // upon shutdown. The method takes ownership of the task pointer. |
| 155 virtual void ConfigureDataTypes( | 158 virtual void ConfigureDataTypes( |
| 156 const DataTypeController::TypeMap& data_type_controllers, | 159 const DataTypeController::TypeMap& data_type_controllers, |
| 157 const syncable::ModelTypeSet& types, | 160 const syncable::ModelTypeSet& types, |
| 158 CancelableTask* ready_task); | 161 CancelableTask* ready_task); |
| 159 | 162 |
| 163 // Encrypts the specified datatypes and marks them as needing encryption on |
| 164 // other machines. This affects all machines synced to this account and all |
| 165 // data belonging to the specified types. |encrypted_types| must be a subset |
| 166 // of the enabled datatypes. |
| 167 // Note: actual work is done on core_thread_'s message loop. |
| 168 virtual void EncryptDataTypes( |
| 169 const syncable::ModelTypeSet& encrypted_types); |
| 170 |
| 160 syncable::AutofillMigrationState | 171 syncable::AutofillMigrationState |
| 161 GetAutofillMigrationState(); | 172 GetAutofillMigrationState(); |
| 162 | 173 |
| 163 void SetAutofillMigrationState( | 174 void SetAutofillMigrationState( |
| 164 syncable::AutofillMigrationState state); | 175 syncable::AutofillMigrationState state); |
| 165 | 176 |
| 166 syncable::AutofillMigrationDebugInfo | 177 syncable::AutofillMigrationDebugInfo |
| 167 GetAutofillMigrationDebugInfo(); | 178 GetAutofillMigrationDebugInfo(); |
| 168 | 179 |
| 169 void SetAutofillMigrationDebugInfo( | 180 void SetAutofillMigrationDebugInfo( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 virtual void OnInitializationComplete(); | 277 virtual void OnInitializationComplete(); |
| 267 virtual void OnAuthError(const GoogleServiceAuthError& auth_error); | 278 virtual void OnAuthError(const GoogleServiceAuthError& auth_error); |
| 268 virtual void OnPassphraseRequired(bool for_decryption); | 279 virtual void OnPassphraseRequired(bool for_decryption); |
| 269 virtual void OnPassphraseAccepted(const std::string& bootstrap_token); | 280 virtual void OnPassphraseAccepted(const std::string& bootstrap_token); |
| 270 virtual void OnPaused(); | 281 virtual void OnPaused(); |
| 271 virtual void OnResumed(); | 282 virtual void OnResumed(); |
| 272 virtual void OnStopSyncingPermanently(); | 283 virtual void OnStopSyncingPermanently(); |
| 273 virtual void OnUpdatedToken(const std::string& token); | 284 virtual void OnUpdatedToken(const std::string& token); |
| 274 virtual void OnClearServerDataFailed(); | 285 virtual void OnClearServerDataFailed(); |
| 275 virtual void OnClearServerDataSucceeded(); | 286 virtual void OnClearServerDataSucceeded(); |
| 287 virtual void OnEncryptionComplete( |
| 288 const syncable::ModelTypeSet& encrypted_types); |
| 276 | 289 |
| 277 // JsBackend implementation. | 290 // JsBackend implementation. |
| 278 virtual void SetParentJsEventRouter(JsEventRouter* router); | 291 virtual void SetParentJsEventRouter(JsEventRouter* router); |
| 279 virtual void RemoveParentJsEventRouter(); | 292 virtual void RemoveParentJsEventRouter(); |
| 280 virtual const JsEventRouter* GetParentJsEventRouter() const; | 293 virtual const JsEventRouter* GetParentJsEventRouter() const; |
| 281 virtual void ProcessMessage(const std::string& name, const JsArgList& args, | 294 virtual void ProcessMessage(const std::string& name, const JsArgList& args, |
| 282 const JsEventHandler* sender); | 295 const JsEventHandler* sender); |
| 283 | 296 |
| 284 // JsEventRouter implementation. | 297 // JsEventRouter implementation. |
| 285 virtual void RouteJsEvent(const std::string& event_name, | 298 virtual void RouteJsEvent(const std::string& event_name, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // syncer. | 342 // syncer. |
| 330 void DoRequestNudge(); | 343 void DoRequestNudge(); |
| 331 void DoRequestPause(); | 344 void DoRequestPause(); |
| 332 void DoRequestResume(); | 345 void DoRequestResume(); |
| 333 void DoRequestClearServerData(); | 346 void DoRequestClearServerData(); |
| 334 | 347 |
| 335 // Called on our SyncBackendHost's |core_thread_| to set the passphrase | 348 // Called on our SyncBackendHost's |core_thread_| to set the passphrase |
| 336 // on behalf of SyncBackendHost::SupplyPassphrase. | 349 // on behalf of SyncBackendHost::SupplyPassphrase. |
| 337 void DoSetPassphrase(const std::string& passphrase, bool is_explicit); | 350 void DoSetPassphrase(const std::string& passphrase, bool is_explicit); |
| 338 | 351 |
| 352 // Called on SyncBackendHost's |core_thread_| to set the datatypes we need |
| 353 // to encrypt as well as encrypt all local data of that type. |
| 354 void DoEncryptDataTypes(const syncable::ModelTypeSet& encrypted_types); |
| 355 |
| 339 // The shutdown order is a bit complicated: | 356 // The shutdown order is a bit complicated: |
| 340 // 1) From |core_thread_|, invoke the syncapi Shutdown call to do a final | 357 // 1) From |core_thread_|, invoke the syncapi Shutdown call to do a final |
| 341 // SaveChanges, close sqlite handles, and halt the syncer thread (which | 358 // SaveChanges, close sqlite handles, and halt the syncer thread (which |
| 342 // could potentially block for 1 minute). | 359 // could potentially block for 1 minute). |
| 343 // 2) Then, from |frontend_loop_|, halt the core_thread_. This causes | 360 // 2) Then, from |frontend_loop_|, halt the core_thread_. This causes |
| 344 // syncapi thread-exit handlers to run and make use of cached pointers to | 361 // syncapi thread-exit handlers to run and make use of cached pointers to |
| 345 // various components owned implicitly by us. | 362 // various components owned implicitly by us. |
| 346 // 3) Destroy this Core. That will delete syncapi components in a safe order | 363 // 3) Destroy this Core. That will delete syncapi components in a safe order |
| 347 // because the thread that was using them has exited (in step 2). | 364 // because the thread that was using them has exited (in step 2). |
| 348 void DoShutdown(bool stopping_sync); | 365 void DoShutdown(bool stopping_sync); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // or for encrypting. If the reason is decryption, |for_decryption| will | 442 // or for encrypting. If the reason is decryption, |for_decryption| will |
| 426 // be true. | 443 // be true. |
| 427 void NotifyPassphraseRequired(bool for_decryption); | 444 void NotifyPassphraseRequired(bool for_decryption); |
| 428 | 445 |
| 429 // Invoked when the passphrase provided by the user has been accepted. | 446 // Invoked when the passphrase provided by the user has been accepted. |
| 430 void NotifyPassphraseAccepted(const std::string& bootstrap_token); | 447 void NotifyPassphraseAccepted(const std::string& bootstrap_token); |
| 431 | 448 |
| 432 // Invoked when an updated token is available from the sync server. | 449 // Invoked when an updated token is available from the sync server. |
| 433 void NotifyUpdatedToken(const std::string& token); | 450 void NotifyUpdatedToken(const std::string& token); |
| 434 | 451 |
| 452 // Invoked when sync finishes encrypting new datatypes or has become aware |
| 453 // of new datatypes requiring encryption. |
| 454 void NotifyEncryptionComplete(const syncable::ModelTypeSet& |
| 455 encrypted_types); |
| 456 |
| 435 // Called from Core::OnSyncCycleCompleted to handle updating frontend | 457 // Called from Core::OnSyncCycleCompleted to handle updating frontend |
| 436 // thread components. | 458 // thread components. |
| 437 void HandleSyncCycleCompletedOnFrontendLoop( | 459 void HandleSyncCycleCompletedOnFrontendLoop( |
| 438 sessions::SyncSessionSnapshot* snapshot); | 460 sessions::SyncSessionSnapshot* snapshot); |
| 439 | 461 |
| 440 void HandleStopSyncingPermanentlyOnFrontendLoop(); | 462 void HandleStopSyncingPermanentlyOnFrontendLoop(); |
| 441 | 463 |
| 442 // Called to handle success/failure of clearing server data | 464 // Called to handle success/failure of clearing server data |
| 443 void HandleClearServerDataSucceededOnFrontendLoop(); | 465 void HandleClearServerDataSucceededOnFrontendLoop(); |
| 444 void HandleClearServerDataFailedOnFrontendLoop(); | 466 void HandleClearServerDataFailedOnFrontendLoop(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // across browser restart to avoid requiring the user to re-enter their | 513 // across browser restart to avoid requiring the user to re-enter their |
| 492 // passphrase. |token| must be valid UTF-8 as we use the PrefService for | 514 // passphrase. |token| must be valid UTF-8 as we use the PrefService for |
| 493 // storage. | 515 // storage. |
| 494 void PersistEncryptionBootstrapToken(const std::string& token); | 516 void PersistEncryptionBootstrapToken(const std::string& token); |
| 495 std::string RestoreEncryptionBootstrapToken(); | 517 std::string RestoreEncryptionBootstrapToken(); |
| 496 | 518 |
| 497 // Our core, which communicates directly to the syncapi. | 519 // Our core, which communicates directly to the syncapi. |
| 498 scoped_refptr<Core> core_; | 520 scoped_refptr<Core> core_; |
| 499 | 521 |
| 500 private: | 522 private: |
| 501 | |
| 502 UIModelWorker* ui_worker(); | 523 UIModelWorker* ui_worker(); |
| 503 | 524 |
| 504 void ConfigureAutofillMigration(); | 525 void ConfigureAutofillMigration(); |
| 505 | 526 |
| 506 // A thread we dedicate for use by our Core to perform initialization, | 527 // A thread we dedicate for use by our Core to perform initialization, |
| 507 // authentication, handle messages from the syncapi, and periodically tell | 528 // authentication, handle messages from the syncapi, and periodically tell |
| 508 // the syncapi to persist itself. | 529 // the syncapi to persist itself. |
| 509 base::Thread core_thread_; | 530 base::Thread core_thread_; |
| 510 | 531 |
| 511 // A reference to the MessageLoop used to construct |this|, so we know how | 532 // 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 Loading... |
| 565 | 586 |
| 566 // Whether we've processed the initialization complete callback. | 587 // Whether we've processed the initialization complete callback. |
| 567 bool syncapi_initialized_; | 588 bool syncapi_initialized_; |
| 568 | 589 |
| 569 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 590 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
| 570 }; | 591 }; |
| 571 | 592 |
| 572 } // namespace browser_sync | 593 } // namespace browser_sync |
| 573 | 594 |
| 574 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 595 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
| OLD | NEW |