| OLD | NEW |
| 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 #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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 17 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 18 #include "base/timer.h" | 19 #include "base/timer.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/browser/sync/engine/syncapi.h" | 21 #include "chrome/browser/sync/engine/syncapi.h" |
| 21 #include "chrome/browser/sync/engine/model_safe_worker.h" | 22 #include "chrome/browser/sync/engine/model_safe_worker.h" |
| 22 #include "chrome/browser/sync/js_backend.h" | 23 #include "chrome/browser/sync/js_backend.h" |
| 23 #include "chrome/browser/sync/js_sync_manager_observer.h" | 24 #include "chrome/browser/sync/js_sync_manager_observer.h" |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // across browser restart to avoid requiring the user to re-enter their | 548 // across browser restart to avoid requiring the user to re-enter their |
| 548 // passphrase. |token| must be valid UTF-8 as we use the PrefService for | 549 // passphrase. |token| must be valid UTF-8 as we use the PrefService for |
| 549 // storage. | 550 // storage. |
| 550 void PersistEncryptionBootstrapToken(const std::string& token); | 551 void PersistEncryptionBootstrapToken(const std::string& token); |
| 551 std::string RestoreEncryptionBootstrapToken(); | 552 std::string RestoreEncryptionBootstrapToken(); |
| 552 | 553 |
| 553 // Our core, which communicates directly to the syncapi. | 554 // Our core, which communicates directly to the syncapi. |
| 554 scoped_refptr<Core> core_; | 555 scoped_refptr<Core> core_; |
| 555 | 556 |
| 556 private: | 557 private: |
| 558 FRIEND_TEST_ALL_PREFIXES(SyncBackendHostTest, MakePendingConfigModeState); |
| 559 |
| 560 struct PendingConfigureDataTypesState { |
| 561 PendingConfigureDataTypesState(); |
| 562 ~PendingConfigureDataTypesState(); |
| 563 |
| 564 // A task that should be called once data type configuration is |
| 565 // complete. |
| 566 scoped_ptr<CancelableTask> ready_task; |
| 567 |
| 568 // The set of types that we are waiting to be initially synced in a |
| 569 // configuration cycle. |
| 570 syncable::ModelTypeSet initial_types; |
| 571 |
| 572 // Additional details about which types were added / removed. |
| 573 bool deleted_type; |
| 574 syncable::ModelTypeBitSet added_types; |
| 575 }; |
| 576 |
| 557 UIModelWorker* ui_worker(); | 577 UIModelWorker* ui_worker(); |
| 558 | 578 |
| 559 void ConfigureAutofillMigration(); | 579 void ConfigureAutofillMigration(); |
| 560 | 580 |
| 581 // Helper function for ConfigureDataTypes(). Caller owns return |
| 582 // value. Takes ownership of |ready_task| (but not |routing_info|). |
| 583 static PendingConfigureDataTypesState* MakePendingConfigModeState( |
| 584 const DataTypeController::TypeMap& data_type_controllers, |
| 585 const syncable::ModelTypeSet& types, |
| 586 CancelableTask* ready_task, |
| 587 ModelSafeRoutingInfo* routing_info); |
| 588 |
| 561 // A thread we dedicate for use by our Core to perform initialization, | 589 // A thread we dedicate for use by our Core to perform initialization, |
| 562 // authentication, handle messages from the syncapi, and periodically tell | 590 // authentication, handle messages from the syncapi, and periodically tell |
| 563 // the syncapi to persist itself. | 591 // the syncapi to persist itself. |
| 564 base::Thread core_thread_; | 592 base::Thread core_thread_; |
| 565 | 593 |
| 566 // A reference to the MessageLoop used to construct |this|, so we know how | 594 // A reference to the MessageLoop used to construct |this|, so we know how |
| 567 // to safely talk back to the SyncFrontend. | 595 // to safely talk back to the SyncFrontend. |
| 568 MessageLoop* const frontend_loop_; | 596 MessageLoop* const frontend_loop_; |
| 569 | 597 |
| 570 Profile* profile_; | 598 Profile* profile_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 597 | 625 |
| 598 // The frontend which we serve (and are owned by). | 626 // The frontend which we serve (and are owned by). |
| 599 SyncFrontend* frontend_; | 627 SyncFrontend* frontend_; |
| 600 | 628 |
| 601 // The change processors that handle the different data types. | 629 // The change processors that handle the different data types. |
| 602 std::map<syncable::ModelType, ChangeProcessor*> processors_; | 630 std::map<syncable::ModelType, ChangeProcessor*> processors_; |
| 603 | 631 |
| 604 // Path of the folder that stores the sync data files. | 632 // Path of the folder that stores the sync data files. |
| 605 FilePath sync_data_folder_path_; | 633 FilePath sync_data_folder_path_; |
| 606 | 634 |
| 607 struct PendingConfigureDataTypesState { | |
| 608 PendingConfigureDataTypesState(); | |
| 609 ~PendingConfigureDataTypesState(); | |
| 610 | |
| 611 // A task that should be called once data type configuration is | |
| 612 // complete. | |
| 613 scoped_ptr<CancelableTask> ready_task; | |
| 614 | |
| 615 // The set of types that we are waiting to be initially synced in a | |
| 616 // configuration cycle. | |
| 617 syncable::ModelTypeSet initial_types; | |
| 618 | |
| 619 // Additional details about which types were added / removed. | |
| 620 bool deleted_type; | |
| 621 syncable::ModelTypeBitSet added_types; | |
| 622 }; | |
| 623 | |
| 624 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_; | 635 scoped_ptr<PendingConfigureDataTypesState> pending_download_state_; |
| 625 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_; | 636 scoped_ptr<PendingConfigureDataTypesState> pending_config_mode_state_; |
| 626 | 637 |
| 627 // UI-thread cache of the last AuthErrorState received from syncapi. | 638 // UI-thread cache of the last AuthErrorState received from syncapi. |
| 628 GoogleServiceAuthError last_auth_error_; | 639 GoogleServiceAuthError last_auth_error_; |
| 629 | 640 |
| 630 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. | 641 // UI-thread cache of the last SyncSessionSnapshot received from syncapi. |
| 631 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; | 642 scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_; |
| 632 | 643 |
| 633 // While two impls are in flight, using this for sanity checking. Bug 26339. | 644 // While two impls are in flight, using this for sanity checking. Bug 26339. |
| 634 const bool using_new_syncer_thread_; | 645 const bool using_new_syncer_thread_; |
| 635 | 646 |
| 636 // Whether we've processed the initialization complete callback. | 647 // Whether we've processed the initialization complete callback. |
| 637 bool syncapi_initialized_; | 648 bool syncapi_initialized_; |
| 638 | 649 |
| 639 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 650 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
| 640 }; | 651 }; |
| 641 | 652 |
| 642 } // namespace browser_sync | 653 } // namespace browser_sync |
| 643 | 654 |
| 644 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ | 655 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_H_ |
| OLD | NEW |