| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" | 27 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" |
| 28 #include "chrome/browser/sync/startup_controller.h" | 28 #include "chrome/browser/sync/startup_controller.h" |
| 29 #include "components/keyed_service/core/keyed_service.h" | 29 #include "components/keyed_service/core/keyed_service.h" |
| 30 #include "components/signin/core/browser/signin_manager_base.h" | 30 #include "components/signin/core/browser/signin_manager_base.h" |
| 31 #include "components/sync_driver/data_type_controller.h" | 31 #include "components/sync_driver/data_type_controller.h" |
| 32 #include "components/sync_driver/data_type_manager.h" | 32 #include "components/sync_driver/data_type_manager.h" |
| 33 #include "components/sync_driver/data_type_manager_observer.h" | 33 #include "components/sync_driver/data_type_manager_observer.h" |
| 34 #include "components/sync_driver/data_type_status_table.h" | 34 #include "components/sync_driver/data_type_status_table.h" |
| 35 #include "components/sync_driver/device_info_sync_service.h" | 35 #include "components/sync_driver/device_info_sync_service.h" |
| 36 #include "components/sync_driver/local_device_info_provider.h" | 36 #include "components/sync_driver/local_device_info_provider.h" |
| 37 #include "components/sync_driver/non_blocking_data_type_manager.h" | |
| 38 #include "components/sync_driver/protocol_event_observer.h" | 37 #include "components/sync_driver/protocol_event_observer.h" |
| 39 #include "components/sync_driver/sync_frontend.h" | 38 #include "components/sync_driver/sync_frontend.h" |
| 40 #include "components/sync_driver/sync_prefs.h" | 39 #include "components/sync_driver/sync_prefs.h" |
| 41 #include "components/sync_driver/sync_service.h" | 40 #include "components/sync_driver/sync_service.h" |
| 42 #include "components/sync_driver/sync_stopped_reporter.h" | 41 #include "components/sync_driver/sync_stopped_reporter.h" |
| 43 #include "google_apis/gaia/google_service_auth_error.h" | 42 #include "google_apis/gaia/google_service_auth_error.h" |
| 44 #include "google_apis/gaia/oauth2_token_service.h" | 43 #include "google_apis/gaia/oauth2_token_service.h" |
| 45 #include "net/base/backoff_entry.h" | 44 #include "net/base/backoff_entry.h" |
| 46 #include "sync/internal_api/public/base/model_type.h" | 45 #include "sync/internal_api/public/base/model_type.h" |
| 47 #include "sync/internal_api/public/engine/model_safe_worker.h" | 46 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 void GetAllNodes( | 326 void GetAllNodes( |
| 328 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback); | 327 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback); |
| 329 | 328 |
| 330 void RegisterAuthNotifications(); | 329 void RegisterAuthNotifications(); |
| 331 void UnregisterAuthNotifications(); | 330 void UnregisterAuthNotifications(); |
| 332 | 331 |
| 333 // Return whether OAuth2 refresh token is loaded and available for the backend | 332 // Return whether OAuth2 refresh token is loaded and available for the backend |
| 334 // to start up. Virtual to enable mocking in tests. | 333 // to start up. Virtual to enable mocking in tests. |
| 335 virtual bool IsOAuthRefreshTokenAvailable(); | 334 virtual bool IsOAuthRefreshTokenAvailable(); |
| 336 | 335 |
| 337 // Registers a type whose sync storage will not be managed by the | |
| 338 // ProfileSyncService. It declares that this sync type may be activated at | |
| 339 // some point in the future. This function call does not enable or activate | |
| 340 // the syncing of this type | |
| 341 // TODO(stanisc): crbug.com/515962: this should merge with | |
| 342 // RegisterDataTypeController. | |
| 343 void RegisterNonBlockingType(syncer::ModelType type); | |
| 344 | |
| 345 // Called by a component that supports non-blocking sync when it is ready to | |
| 346 // initialize its connection to the sync backend. | |
| 347 // | |
| 348 // If policy allows for syncing this type (ie. it is "preferred"), then this | |
| 349 // should result in a message to enable syncing for this type when the sync | |
| 350 // backend is available. If the type is not to be synced, this should result | |
| 351 // in a message that allows the component to delete its local sync state. | |
| 352 // TODO(stanisc): crbug.com/515962: review usage of this. | |
| 353 void InitializeNonBlockingType( | |
| 354 syncer::ModelType type, | |
| 355 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | |
| 356 const base::WeakPtr<syncer_v2::ModelTypeProcessorImpl>& type_processor); | |
| 357 | |
| 358 // Returns the SyncedWindowDelegatesGetter from the embedded sessions manager. | 336 // Returns the SyncedWindowDelegatesGetter from the embedded sessions manager. |
| 359 virtual browser_sync::SyncedWindowDelegatesGetter* | 337 virtual browser_sync::SyncedWindowDelegatesGetter* |
| 360 GetSyncedWindowDelegatesGetter() const; | 338 GetSyncedWindowDelegatesGetter() const; |
| 361 | 339 |
| 362 // Returns the SyncableService for syncer::SESSIONS. | 340 // Returns the SyncableService for syncer::SESSIONS. |
| 363 virtual syncer::SyncableService* GetSessionsSyncableService(); | 341 virtual syncer::SyncableService* GetSessionsSyncableService(); |
| 364 | 342 |
| 365 // Returns the SyncableService for syncer::DEVICE_INFO. | 343 // Returns the SyncableService for syncer::DEVICE_INFO. |
| 366 virtual syncer::SyncableService* GetDeviceInfoSyncableService(); | 344 virtual syncer::SyncableService* GetDeviceInfoSyncableService(); |
| 367 | 345 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // SyncPrefObserver implementation. | 477 // SyncPrefObserver implementation. |
| 500 void OnSyncManagedPrefChange(bool is_sync_managed) override; | 478 void OnSyncManagedPrefChange(bool is_sync_managed) override; |
| 501 | 479 |
| 502 // Changes which data types we're going to be syncing to |preferred_types|. | 480 // Changes which data types we're going to be syncing to |preferred_types|. |
| 503 // If it is running, the DataTypeManager will be instructed to reconfigure | 481 // If it is running, the DataTypeManager will be instructed to reconfigure |
| 504 // the sync backend so that exactly these datatypes are actively synced. See | 482 // the sync backend so that exactly these datatypes are actively synced. See |
| 505 // class comment for more on what it means for a datatype to be Preferred. | 483 // class comment for more on what it means for a datatype to be Preferred. |
| 506 virtual void ChangePreferredDataTypes( | 484 virtual void ChangePreferredDataTypes( |
| 507 syncer::ModelTypeSet preferred_types); | 485 syncer::ModelTypeSet preferred_types); |
| 508 | 486 |
| 509 // Returns the set of directory types which are preferred for enabling. | |
| 510 virtual syncer::ModelTypeSet GetPreferredDirectoryDataTypes() const; | |
| 511 | |
| 512 // Returns the set of off-thread types which are preferred for enabling. | |
| 513 virtual syncer::ModelTypeSet GetPreferredNonBlockingDataTypes() const; | |
| 514 | |
| 515 // Returns the set of types which are enforced programmatically and can not | 487 // Returns the set of types which are enforced programmatically and can not |
| 516 // be disabled by the user. | 488 // be disabled by the user. |
| 517 virtual syncer::ModelTypeSet GetForcedDataTypes() const; | 489 virtual syncer::ModelTypeSet GetForcedDataTypes() const; |
| 518 | 490 |
| 519 // Gets the set of all data types that could be allowed (the set that | 491 // Gets the set of all data types that could be allowed (the set that |
| 520 // should be advertised to the user). These will typically only change | 492 // should be advertised to the user). These will typically only change |
| 521 // via a command-line option. See class comment for more on what it means | 493 // via a command-line option. See class comment for more on what it means |
| 522 // for a datatype to be Registered. | 494 // for a datatype to be Registered. |
| 523 virtual syncer::ModelTypeSet GetRegisteredDataTypes() const; | 495 virtual syncer::ModelTypeSet GetRegisteredDataTypes() const; |
| 524 | 496 |
| 525 // Gets the set of directory types which could be allowed. | |
| 526 virtual syncer::ModelTypeSet GetRegisteredDirectoryDataTypes() const; | |
| 527 | |
| 528 // Gets the set of off-thread types which could be allowed. | |
| 529 virtual syncer::ModelTypeSet GetRegisteredNonBlockingDataTypes() const; | |
| 530 | |
| 531 // Returns the actual passphrase type being used for encryption. | 497 // Returns the actual passphrase type being used for encryption. |
| 532 virtual syncer::PassphraseType GetPassphraseType() const; | 498 virtual syncer::PassphraseType GetPassphraseType() const; |
| 533 | 499 |
| 534 // Note about setting passphrases: There are different scenarios under which | 500 // Note about setting passphrases: There are different scenarios under which |
| 535 // we might want to apply a passphrase. It could be for first-time encryption, | 501 // we might want to apply a passphrase. It could be for first-time encryption, |
| 536 // re-encryption, or for decryption by clients that sign in at a later time. | 502 // re-encryption, or for decryption by clients that sign in at a later time. |
| 537 // In addition, encryption can either be done using a custom passphrase, or by | 503 // In addition, encryption can either be done using a custom passphrase, or by |
| 538 // reusing the GAIA password. Depending on what is happening in the system, | 504 // reusing the GAIA password. Depending on what is happening in the system, |
| 539 // callers should determine which of the two methods below must be used. | 505 // callers should determine which of the two methods below must be used. |
| 540 | 506 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // Shuts down the backend sync components. | 598 // Shuts down the backend sync components. |
| 633 // |reason| dictates if syncing is being disabled or not, and whether | 599 // |reason| dictates if syncing is being disabled or not, and whether |
| 634 // to claim ownership of sync thread from backend. | 600 // to claim ownership of sync thread from backend. |
| 635 void ShutdownImpl(syncer::ShutdownReason reason); | 601 void ShutdownImpl(syncer::ShutdownReason reason); |
| 636 | 602 |
| 637 // Return SyncCredentials from the OAuth2TokenService. | 603 // Return SyncCredentials from the OAuth2TokenService. |
| 638 syncer::SyncCredentials GetCredentials(); | 604 syncer::SyncCredentials GetCredentials(); |
| 639 | 605 |
| 640 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); | 606 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); |
| 641 | 607 |
| 642 const sync_driver::DataTypeController::TypeMap& | 608 const sync_driver::DataTypeController::TypeMap& data_type_controllers() { |
| 643 directory_data_type_controllers() { | 609 return data_type_controllers_; |
| 644 return directory_data_type_controllers_; | |
| 645 } | 610 } |
| 646 | 611 |
| 647 // Helper method for managing encryption UI. | 612 // Helper method for managing encryption UI. |
| 648 bool IsEncryptedDatatypeEnabled() const; | 613 bool IsEncryptedDatatypeEnabled() const; |
| 649 | 614 |
| 650 // Helper for OnUnrecoverableError. | 615 // Helper for OnUnrecoverableError. |
| 651 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, | 616 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, |
| 652 // and in SyncBackendHost::Shutdown. | 617 // and in SyncBackendHost::Shutdown. |
| 653 void OnUnrecoverableErrorImpl( | 618 void OnUnrecoverableErrorImpl( |
| 654 const tracked_objects::Location& from_here, | 619 const tracked_objects::Location& from_here, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 | 814 |
| 850 // The time that OnConfigureStart is called. This member is zero if | 815 // The time that OnConfigureStart is called. This member is zero if |
| 851 // OnConfigureStart has not yet been called, and is reset to zero once | 816 // OnConfigureStart has not yet been called, and is reset to zero once |
| 852 // OnConfigureDone is called. | 817 // OnConfigureDone is called. |
| 853 base::Time sync_configure_start_time_; | 818 base::Time sync_configure_start_time_; |
| 854 | 819 |
| 855 // Indicates if this is the first time sync is being configured. This value | 820 // Indicates if this is the first time sync is being configured. This value |
| 856 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). | 821 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). |
| 857 bool is_first_time_sync_configure_; | 822 bool is_first_time_sync_configure_; |
| 858 | 823 |
| 859 // List of available data type controllers for directory types. | 824 // List of available data type controllers. |
| 860 sync_driver::DataTypeController::TypeMap directory_data_type_controllers_; | 825 sync_driver::DataTypeController::TypeMap data_type_controllers_; |
| 861 | 826 |
| 862 // Whether the SyncBackendHost has been initialized. | 827 // Whether the SyncBackendHost has been initialized. |
| 863 bool backend_initialized_; | 828 bool backend_initialized_; |
| 864 | 829 |
| 865 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents | 830 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents |
| 866 // ProfileSyncService from starting backend till browser restarted or user | 831 // ProfileSyncService from starting backend till browser restarted or user |
| 867 // signed out. | 832 // signed out. |
| 868 bool sync_disabled_by_admin_; | 833 bool sync_disabled_by_admin_; |
| 869 | 834 |
| 870 // Set to true if a signin has completed but we're still waiting for the | 835 // Set to true if a signin has completed but we're still waiting for the |
| 871 // backend to refresh its credentials. | 836 // backend to refresh its credentials. |
| 872 bool is_auth_in_progress_; | 837 bool is_auth_in_progress_; |
| 873 | 838 |
| 874 // Encapsulates user signin - used to set/get the user's authenticated | 839 // Encapsulates user signin - used to set/get the user's authenticated |
| 875 // email address. | 840 // email address. |
| 876 const scoped_ptr<SigninManagerWrapper> signin_; | 841 const scoped_ptr<SigninManagerWrapper> signin_; |
| 877 | 842 |
| 878 // Information describing an unrecoverable error. | 843 // Information describing an unrecoverable error. |
| 879 UnrecoverableErrorReason unrecoverable_error_reason_; | 844 UnrecoverableErrorReason unrecoverable_error_reason_; |
| 880 std::string unrecoverable_error_message_; | 845 std::string unrecoverable_error_message_; |
| 881 tracked_objects::Location unrecoverable_error_location_; | 846 tracked_objects::Location unrecoverable_error_location_; |
| 882 | 847 |
| 883 // Manages the start and stop of the directory data types. | 848 // Manages the start and stop of the data types. |
| 884 scoped_ptr<sync_driver::DataTypeManager> directory_data_type_manager_; | 849 scoped_ptr<sync_driver::DataTypeManager> data_type_manager_; |
| 885 | |
| 886 // Manager for the non-blocking data types. | |
| 887 sync_driver_v2::NonBlockingDataTypeManager non_blocking_data_type_manager_; | |
| 888 | 850 |
| 889 base::ObserverList<sync_driver::SyncServiceObserver> observers_; | 851 base::ObserverList<sync_driver::SyncServiceObserver> observers_; |
| 890 base::ObserverList<browser_sync::ProtocolEventObserver> | 852 base::ObserverList<browser_sync::ProtocolEventObserver> |
| 891 protocol_event_observers_; | 853 protocol_event_observers_; |
| 892 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; | 854 base::ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; |
| 893 | 855 |
| 894 std::set<SyncTypePreferenceProvider*> preference_providers_; | 856 std::set<SyncTypePreferenceProvider*> preference_providers_; |
| 895 | 857 |
| 896 syncer::SyncJsController sync_js_controller_; | 858 syncer::SyncJsController sync_js_controller_; |
| 897 | 859 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; | 1006 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; |
| 1045 | 1007 |
| 1046 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1008 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 1047 }; | 1009 }; |
| 1048 | 1010 |
| 1049 bool ShouldShowActionOnUI( | 1011 bool ShouldShowActionOnUI( |
| 1050 const syncer::SyncProtocolError& error); | 1012 const syncer::SyncProtocolError& error); |
| 1051 | 1013 |
| 1052 | 1014 |
| 1053 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1015 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |