Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "base/timer/timer.h" | 22 #include "base/timer/timer.h" |
| 23 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" | 23 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" |
| 24 #include "chrome/browser/sync/glue/sync_backend_host.h" | 24 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 25 #include "chrome/browser/sync/glue/synced_device_tracker.h" | 25 #include "chrome/browser/sync/glue/synced_device_tracker.h" |
| 26 #include "chrome/browser/sync/profile_sync_service_base.h" | 26 #include "chrome/browser/sync/profile_sync_service_base.h" |
| 27 #include "chrome/browser/sync/profile_sync_service_observer.h" | 27 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 28 #include "chrome/browser/sync/sessions2/sessions_sync_manager.h" | 28 #include "chrome/browser/sync/sessions2/sessions_sync_manager.h" |
| 29 #include "chrome/browser/sync/startup_controller.h" | |
| 29 #include "chrome/browser/sync/sync_prefs.h" | 30 #include "chrome/browser/sync/sync_prefs.h" |
| 30 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" | 31 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" |
| 31 #include "components/sync_driver/data_type_controller.h" | 32 #include "components/sync_driver/data_type_controller.h" |
| 32 #include "components/sync_driver/data_type_encryption_handler.h" | 33 #include "components/sync_driver/data_type_encryption_handler.h" |
| 33 #include "components/sync_driver/data_type_manager.h" | 34 #include "components/sync_driver/data_type_manager.h" |
| 34 #include "components/sync_driver/data_type_manager_observer.h" | 35 #include "components/sync_driver/data_type_manager_observer.h" |
| 35 #include "components/sync_driver/failed_data_types_handler.h" | 36 #include "components/sync_driver/failed_data_types_handler.h" |
| 36 #include "components/sync_driver/sync_frontend.h" | 37 #include "components/sync_driver/sync_frontend.h" |
| 37 #include "content/public/browser/notification_observer.h" | 38 #include "content/public/browser/notification_observer.h" |
| 38 #include "content/public/browser/notification_registrar.h" | 39 #include "content/public/browser/notification_registrar.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 // types and clicking OK. | 220 // types and clicking OK. |
| 220 // Events resulting in the stoppage of sync service. | 221 // Events resulting in the stoppage of sync service. |
| 221 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. | 222 STOP_FROM_OPTIONS = 20, // Sync was stopped from Wrench->Options. |
| 222 STOP_FROM_ADVANCED_DIALOG = 21, // Sync was stopped via advanced settings. | 223 STOP_FROM_ADVANCED_DIALOG = 21, // Sync was stopped via advanced settings. |
| 223 | 224 |
| 224 // Miscellaneous events caused by sync service. | 225 // Miscellaneous events caused by sync service. |
| 225 | 226 |
| 226 MAX_SYNC_EVENT_CODE | 227 MAX_SYNC_EVENT_CODE |
| 227 }; | 228 }; |
| 228 | 229 |
| 229 // Defines the type of behavior the sync engine should use. If configured for | |
| 230 // AUTO_START, the sync engine will automatically call SetSyncSetupCompleted() | |
| 231 // and start downloading data types as soon as sync credentials are available | |
| 232 // (a signed-in username and a "chromiumsync" token). | |
| 233 // If configured for MANUAL_START, sync will not start until the user | |
| 234 // completes sync setup, at which point the UI makes an explicit call to | |
| 235 // SetSyncSetupCompleted(). | |
| 236 enum StartBehavior { | |
| 237 AUTO_START, | |
| 238 MANUAL_START, | |
| 239 }; | |
| 240 | |
| 241 // Used to specify the kind of passphrase with which sync data is encrypted. | 230 // Used to specify the kind of passphrase with which sync data is encrypted. |
| 242 enum PassphraseType { | 231 enum PassphraseType { |
| 243 IMPLICIT, // The user did not provide a custom passphrase for encryption. | 232 IMPLICIT, // The user did not provide a custom passphrase for encryption. |
| 244 // We implicitly use the GAIA password in such cases. | 233 // We implicitly use the GAIA password in such cases. |
| 245 EXPLICIT, // The user selected the "use custom passphrase" radio button | 234 EXPLICIT, // The user selected the "use custom passphrase" radio button |
| 246 // during sync setup and provided a passphrase. | 235 // during sync setup and provided a passphrase. |
| 247 }; | 236 }; |
| 248 | 237 |
| 249 enum SyncStatusSummary { | 238 enum SyncStatusSummary { |
| 250 UNRECOVERABLE_ERROR, | 239 UNRECOVERABLE_ERROR, |
| 251 NOT_ENABLED, | 240 NOT_ENABLED, |
| 252 SETUP_INCOMPLETE, | 241 SETUP_INCOMPLETE, |
| 253 DATATYPES_NOT_INITIALIZED, | 242 DATATYPES_NOT_INITIALIZED, |
| 254 INITIALIZED, | 243 INITIALIZED, |
| 255 UNKNOWN_ERROR, | 244 UNKNOWN_ERROR, |
| 256 }; | 245 }; |
| 257 | 246 |
| 258 // Default sync server URL. | 247 // Default sync server URL. |
| 259 static const char* kSyncServerUrl; | 248 static const char* kSyncServerUrl; |
| 260 // Sync server URL for dev channel users | 249 // Sync server URL for dev channel users |
| 261 static const char* kDevServerUrl; | 250 static const char* kDevServerUrl; |
| 262 | 251 |
| 263 // Takes ownership of |factory| and |signin_wrapper|. | 252 // Takes ownership of |factory| and |signin_wrapper|. |
| 264 ProfileSyncService(ProfileSyncComponentsFactory* factory, | 253 ProfileSyncService( |
| 265 Profile* profile, | 254 ProfileSyncComponentsFactory* factory, |
| 266 ManagedUserSigninManagerWrapper* signin_wrapper, | 255 Profile* profile, |
| 267 ProfileOAuth2TokenService* oauth2_token_service, | 256 ManagedUserSigninManagerWrapper* signin_wrapper, |
| 268 StartBehavior start_behavior); | 257 ProfileOAuth2TokenService* oauth2_token_service, |
| 258 browser_sync::ProfileSyncServiceStartBehavior start_behavior); | |
| 269 virtual ~ProfileSyncService(); | 259 virtual ~ProfileSyncService(); |
| 270 | 260 |
| 271 // Initializes the object. This must be called at most once, and | 261 // Initializes the object. This must be called at most once, and |
| 272 // immediately after an object of this class is constructed. | 262 // immediately after an object of this class is constructed. |
| 273 void Initialize(); | 263 void Initialize(); |
| 274 | 264 |
| 275 virtual void SetSyncSetupCompleted(); | 265 virtual void SetSyncSetupCompleted(); |
| 276 | 266 |
| 277 // ProfileSyncServiceBase implementation. | 267 // ProfileSyncServiceBase implementation. |
| 278 virtual bool HasSyncSetupCompleted() const OVERRIDE; | 268 virtual bool HasSyncSetupCompleted() const OVERRIDE; |
| 279 virtual bool ShouldPushChanges() OVERRIDE; | 269 virtual bool ShouldPushChanges() OVERRIDE; |
| 280 virtual syncer::ModelTypeSet GetActiveDataTypes() const OVERRIDE; | 270 virtual syncer::ModelTypeSet GetActiveDataTypes() const OVERRIDE; |
| 281 virtual void AddObserver(ProfileSyncServiceBase::Observer* observer) OVERRIDE; | 271 virtual void AddObserver(ProfileSyncServiceBase::Observer* observer) OVERRIDE; |
| 282 virtual void RemoveObserver( | 272 virtual void RemoveObserver( |
| 283 ProfileSyncServiceBase::Observer* observer) OVERRIDE; | 273 ProfileSyncServiceBase::Observer* observer) OVERRIDE; |
| 284 virtual bool HasObserver( | 274 virtual bool HasObserver( |
| 285 ProfileSyncServiceBase::Observer* observer) const OVERRIDE; | 275 ProfileSyncServiceBase::Observer* observer) const OVERRIDE; |
| 286 | 276 |
| 287 void RegisterAuthNotifications(); | 277 void RegisterAuthNotifications(); |
| 288 void UnregisterAuthNotifications(); | 278 void UnregisterAuthNotifications(); |
| 289 | 279 |
| 290 // Returns true if sync is enabled/not suppressed and the user is logged in. | 280 // Returns true if sync is enabled/not suppressed and the user is logged in. |
| 291 // (being logged in does not mean that tokens are available - tokens may | 281 // (being logged in does not mean that tokens are available - tokens may |
| 292 // be missing because they have not loaded yet, or because they were deleted | 282 // be missing because they have not loaded yet, or because they were deleted |
| 293 // due to http://crbug.com/121755). | 283 // due to http://crbug.com/121755). |
| 294 // Virtual to enable mocking in tests. | 284 // Virtual to enable mocking in tests. |
| 285 // TODO(tim): Remove this? Nothing in ProfileSyncService uses it, and outside | |
| 286 // callers use a seemingly arbitrary / redundant / bug prone combination of | |
| 287 // this method, IsSyncAccessible, and others. | |
| 295 virtual bool IsSyncEnabledAndLoggedIn(); | 288 virtual bool IsSyncEnabledAndLoggedIn(); |
| 296 | 289 |
| 297 // Return whether OAuth2 refresh token is loaded and available for the backend | 290 // Return whether OAuth2 refresh token is loaded and available for the backend |
| 298 // to start up. Virtual to enable mocking in tests. | 291 // to start up. Virtual to enable mocking in tests. |
| 299 virtual bool IsOAuthRefreshTokenAvailable(); | 292 virtual bool IsOAuthRefreshTokenAvailable(); |
| 300 | 293 |
| 301 // Registers a data type controller with the sync service. This | 294 // Registers a data type controller with the sync service. This |
| 302 // makes the data type controller available for use, it does not | 295 // makes the data type controller available for use, it does not |
| 303 // enable or activate the synchronization of the data type (see | 296 // enable or activate the synchronization of the data type (see |
| 304 // ActivateDataType). Takes ownership of the pointer. | 297 // ActivateDataType). Takes ownership of the pointer. |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 // Returns true if we are currently set to encrypt all the sync data. Note: | 627 // Returns true if we are currently set to encrypt all the sync data. Note: |
| 635 // this is based on the cryptographer's settings, so if the user has recently | 628 // this is based on the cryptographer's settings, so if the user has recently |
| 636 // requested encryption to be turned on, this may not be true yet. For that, | 629 // requested encryption to be turned on, this may not be true yet. For that, |
| 637 // encryption_pending() must be checked. | 630 // encryption_pending() must be checked. |
| 638 virtual bool EncryptEverythingEnabled() const; | 631 virtual bool EncryptEverythingEnabled() const; |
| 639 | 632 |
| 640 // Returns true if the syncer is waiting for new datatypes to be encrypted. | 633 // Returns true if the syncer is waiting for new datatypes to be encrypted. |
| 641 virtual bool encryption_pending() const; | 634 virtual bool encryption_pending() const; |
| 642 | 635 |
| 643 const GURL& sync_service_url() const { return sync_service_url_; } | 636 const GURL& sync_service_url() const { return sync_service_url_; } |
| 644 bool auto_start_enabled() const { return auto_start_enabled_; } | |
| 645 SigninManagerBase* signin() const; | 637 SigninManagerBase* signin() const; |
| 646 bool setup_in_progress() const { return setup_in_progress_; } | 638 |
| 639 // Used by tests. | |
| 640 bool auto_start_enabled() const; | |
| 641 bool setup_in_progress() const; | |
| 647 | 642 |
| 648 // Stops the sync backend and sets the flag for suppressing sync startup. | 643 // Stops the sync backend and sets the flag for suppressing sync startup. |
| 649 void StopAndSuppress(); | 644 void StopAndSuppress(); |
| 650 | 645 |
| 651 // Resets the flag for suppressing sync startup and starts the sync backend. | 646 // Resets the flag for suppressing sync startup and starts the sync backend. |
| 652 virtual void UnsuppressAndStart(); | 647 virtual void UnsuppressAndStart(); |
| 653 | 648 |
| 654 // Marks all currently registered types as "acknowledged" so we won't prompt | 649 // Marks all currently registered types as "acknowledged" so we won't prompt |
| 655 // the user about them any more. | 650 // the user about them any more. |
| 656 void AcknowledgeSyncedTypes(); | 651 void AcknowledgeSyncedTypes(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 779 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); | 774 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServiceTest, InitialState); |
| 780 | 775 |
| 781 // Update the last auth error and notify observers of error state. | 776 // Update the last auth error and notify observers of error state. |
| 782 void UpdateAuthErrorState(const GoogleServiceAuthError& error); | 777 void UpdateAuthErrorState(const GoogleServiceAuthError& error); |
| 783 | 778 |
| 784 // Detects and attempts to recover from a previous improper datatype | 779 // Detects and attempts to recover from a previous improper datatype |
| 785 // configuration where Keep Everything Synced and the preferred types were | 780 // configuration where Keep Everything Synced and the preferred types were |
| 786 // not correctly set. | 781 // not correctly set. |
| 787 void TrySyncDatatypePrefRecovery(); | 782 void TrySyncDatatypePrefRecovery(); |
| 788 | 783 |
| 789 // Starts up sync if it is not suppressed and preconditions are met. | |
| 790 // Called from Initialize() and UnsuppressAndStart(). | |
| 791 void TryStart(); | |
| 792 | |
| 793 // Puts the backend's sync scheduler into NORMAL mode. | 784 // Puts the backend's sync scheduler into NORMAL mode. |
| 794 // Called when configuration is complete. | 785 // Called when configuration is complete. |
| 795 void StartSyncingWithServer(); | 786 void StartSyncingWithServer(); |
| 796 | 787 |
| 797 // Called when we've determined that we don't need a passphrase (either | 788 // Called when we've determined that we don't need a passphrase (either |
| 798 // because OnPassphraseAccepted() was called, or because we've gotten a | 789 // because OnPassphraseAccepted() was called, or because we've gotten a |
| 799 // OnPassphraseRequired() but no data types are enabled). | 790 // OnPassphraseRequired() but no data types are enabled). |
| 800 void ResolvePassphraseRequired(); | 791 void ResolvePassphraseRequired(); |
| 801 | 792 |
| 802 // During initial signin, ProfileSyncService caches the user's signin | 793 // During initial signin, ProfileSyncService caches the user's signin |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 821 // Sets the last synced time to the current time. | 812 // Sets the last synced time to the current time. |
| 822 void UpdateLastSyncedTime(); | 813 void UpdateLastSyncedTime(); |
| 823 | 814 |
| 824 void NotifyObservers(); | 815 void NotifyObservers(); |
| 825 void NotifySyncCycleCompleted(); | 816 void NotifySyncCycleCompleted(); |
| 826 | 817 |
| 827 void ClearStaleErrors(); | 818 void ClearStaleErrors(); |
| 828 | 819 |
| 829 void ClearUnrecoverableError(); | 820 void ClearUnrecoverableError(); |
| 830 | 821 |
| 831 enum StartUpDeferredOption { | |
| 832 STARTUP_BACKEND_DEFERRED, | |
| 833 STARTUP_IMMEDIATE | |
| 834 }; | |
| 835 void StartUp(StartUpDeferredOption deferred_option); | |
| 836 | |
| 837 // Starts up the backend sync components. | 822 // Starts up the backend sync components. |
| 838 void StartUpSlowBackendComponents(); | 823 void StartUpSlowBackendComponents(); |
| 839 | 824 |
| 840 // About-flags experiment names for datatypes that aren't enabled by default | 825 // About-flags experiment names for datatypes that aren't enabled by default |
| 841 // yet. | 826 // yet. |
| 842 static std::string GetExperimentNameForDataType( | 827 static std::string GetExperimentNameForDataType( |
| 843 syncer::ModelType data_type); | 828 syncer::ModelType data_type); |
| 844 | 829 |
| 845 // Create and register a new datatype controller. | 830 // Create and register a new datatype controller. |
| 846 void RegisterNewDataType(syncer::ModelType data_type); | 831 void RegisterNewDataType(syncer::ModelType data_type); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 865 void RefreshSpareBootstrapToken(const std::string& passphrase); | 850 void RefreshSpareBootstrapToken(const std::string& passphrase); |
| 866 #endif | 851 #endif |
| 867 | 852 |
| 868 // Internal unrecoverable error handler. Used to track error reason via | 853 // Internal unrecoverable error handler. Used to track error reason via |
| 869 // Sync.UnrecoverableErrors histogram. | 854 // Sync.UnrecoverableErrors histogram. |
| 870 void OnInternalUnrecoverableError(const tracked_objects::Location& from_here, | 855 void OnInternalUnrecoverableError(const tracked_objects::Location& from_here, |
| 871 const std::string& message, | 856 const std::string& message, |
| 872 bool delete_sync_database, | 857 bool delete_sync_database, |
| 873 UnrecoverableErrorReason reason); | 858 UnrecoverableErrorReason reason); |
| 874 | 859 |
| 875 // Returns the username (in form of an email address) that should be used in | |
| 876 // the credentials. | |
| 877 std::string GetEffectiveUsername(); | |
| 878 | |
| 879 // Returns the account ID to use to get tokens. | |
| 880 std::string GetAccountIdToUse(); | |
| 881 | |
| 882 // Factory used to create various dependent objects. | 860 // Factory used to create various dependent objects. |
| 883 scoped_ptr<ProfileSyncComponentsFactory> factory_; | 861 scoped_ptr<ProfileSyncComponentsFactory> factory_; |
| 884 | 862 |
| 885 // The profile whose data we are synchronizing. | 863 // The profile whose data we are synchronizing. |
| 886 Profile* profile_; | 864 Profile* profile_; |
| 887 | 865 |
| 888 // The class that handles getting, setting, and persisting sync | 866 // The class that handles getting, setting, and persisting sync |
| 889 // preferences. | 867 // preferences. |
| 890 browser_sync::SyncPrefs sync_prefs_; | 868 browser_sync::SyncPrefs sync_prefs_; |
| 891 | 869 |
| 892 // TODO(ncarter): Put this in a profile, once there is UI for it. | 870 // TODO(ncarter): Put this in a profile, once there is UI for it. |
| 893 // This specifies where to find the sync server. | 871 // This specifies where to find the sync server. |
| 894 GURL sync_service_url_; | 872 GURL sync_service_url_; |
| 895 | 873 |
| 896 // The last time we detected a successful transition from SYNCING state. | 874 // The last time we detected a successful transition from SYNCING state. |
| 897 // Our backend notifies us whenever we should take a new snapshot. | 875 // Our backend notifies us whenever we should take a new snapshot. |
| 898 base::Time last_synced_time_; | 876 base::Time last_synced_time_; |
| 899 | 877 |
| 900 // The time that StartUp() is called. This member is zero if StartUp() has | |
| 901 // never been called, and is reset to zero once OnBackendInitialized() is | |
| 902 // called. | |
| 903 base::Time start_up_time_; | |
| 904 | |
| 905 // Whether we have received a signal from a SyncableService requesting that | |
| 906 // sync starts as soon as possible. | |
| 907 // TODO(tim): Move this and other TryStart related logic + state to separate | |
| 908 // class. Bug 80149. | |
| 909 bool data_type_requested_sync_startup_; | |
| 910 | |
| 911 // The time that OnConfigureStart is called. This member is zero if | 878 // The time that OnConfigureStart is called. This member is zero if |
| 912 // OnConfigureStart has not yet been called, and is reset to zero once | 879 // OnConfigureStart has not yet been called, and is reset to zero once |
| 913 // OnConfigureDone is called. | 880 // OnConfigureDone is called. |
| 914 base::Time sync_configure_start_time_; | 881 base::Time sync_configure_start_time_; |
| 915 | 882 |
| 916 // Indicates if this is the first time sync is being configured. This value | 883 // Indicates if this is the first time sync is being configured. This value |
| 917 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). | 884 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). |
| 918 bool is_first_time_sync_configure_; | 885 bool is_first_time_sync_configure_; |
| 919 | 886 |
| 920 // List of available data type controllers. | 887 // List of available data type controllers. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 syncer::ModelTypeSet encrypted_types_; | 933 syncer::ModelTypeSet encrypted_types_; |
| 967 | 934 |
| 968 // Whether we want to encrypt everything. | 935 // Whether we want to encrypt everything. |
| 969 bool encrypt_everything_; | 936 bool encrypt_everything_; |
| 970 | 937 |
| 971 // Whether we're waiting for an attempt to encryption all sync data to | 938 // Whether we're waiting for an attempt to encryption all sync data to |
| 972 // complete. We track this at this layer in order to allow the user to cancel | 939 // complete. We track this at this layer in order to allow the user to cancel |
| 973 // if they e.g. don't remember their explicit passphrase. | 940 // if they e.g. don't remember their explicit passphrase. |
| 974 bool encryption_pending_; | 941 bool encryption_pending_; |
| 975 | 942 |
| 976 // If true, we want to automatically start sync signin whenever we have | |
| 977 // credentials (user doesn't need to go through the startup flow). This is | |
| 978 // typically enabled on platforms (like ChromeOS) that have their own | |
| 979 // distinct signin flow. | |
| 980 const bool auto_start_enabled_; | |
| 981 | |
| 982 scoped_ptr<browser_sync::BackendMigrator> migrator_; | 943 scoped_ptr<browser_sync::BackendMigrator> migrator_; |
| 983 | 944 |
| 984 // This is the last |SyncProtocolError| we received from the server that had | 945 // This is the last |SyncProtocolError| we received from the server that had |
| 985 // an action set on it. | 946 // an action set on it. |
| 986 syncer::SyncProtocolError last_actionable_error_; | 947 syncer::SyncProtocolError last_actionable_error_; |
| 987 | 948 |
| 988 // This is used to show sync errors in the wrench menu. | 949 // This is used to show sync errors in the wrench menu. |
| 989 scoped_ptr<SyncGlobalError> sync_global_error_; | 950 scoped_ptr<SyncGlobalError> sync_global_error_; |
| 990 | 951 |
| 991 // Tracks the set of failed data types (those that encounter an error | 952 // Tracks the set of failed data types (those that encounter an error |
| 992 // or must delay loading for some reason). | 953 // or must delay loading for some reason). |
| 993 browser_sync::FailedDataTypesHandler failed_data_types_handler_; | 954 browser_sync::FailedDataTypesHandler failed_data_types_handler_; |
| 994 | 955 |
| 995 browser_sync::DataTypeManager::ConfigureStatus configure_status_; | 956 browser_sync::DataTypeManager::ConfigureStatus configure_status_; |
| 996 | 957 |
| 997 // If |true|, there is setup UI visible so we should not start downloading | |
| 998 // data types. | |
| 999 bool setup_in_progress_; | |
| 1000 | |
| 1001 // The set of currently enabled sync experiments. | 958 // The set of currently enabled sync experiments. |
| 1002 syncer::Experiments current_experiments_; | 959 syncer::Experiments current_experiments_; |
| 1003 | 960 |
| 1004 // Sync's internal debug info listener. Used to record datatype configuration | 961 // Sync's internal debug info listener. Used to record datatype configuration |
| 1005 // and association information. | 962 // and association information. |
| 1006 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 963 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
| 1007 | 964 |
| 1008 // A thread where all the sync operations happen. | 965 // A thread where all the sync operations happen. |
| 1009 // OWNERSHIP Notes: | 966 // OWNERSHIP Notes: |
| 1010 // * Created when backend starts for the first time. | 967 // * Created when backend starts for the first time. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1023 // the duration of request in order to receive callbacks. | 980 // the duration of request in order to receive callbacks. |
| 1024 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | 981 scoped_ptr<OAuth2TokenService::Request> access_token_request_; |
| 1025 | 982 |
| 1026 // If RequestAccessToken fails with transient error then retry requesting | 983 // If RequestAccessToken fails with transient error then retry requesting |
| 1027 // access token with exponential backoff. | 984 // access token with exponential backoff. |
| 1028 base::OneShotTimer<ProfileSyncService> request_access_token_retry_timer_; | 985 base::OneShotTimer<ProfileSyncService> request_access_token_retry_timer_; |
| 1029 net::BackoffEntry request_access_token_backoff_; | 986 net::BackoffEntry request_access_token_backoff_; |
| 1030 | 987 |
| 1031 base::WeakPtrFactory<ProfileSyncService> weak_factory_; | 988 base::WeakPtrFactory<ProfileSyncService> weak_factory_; |
| 1032 | 989 |
| 990 // We don't use |weak_factory_| for the StartupController because the weak | |
| 991 // ptrs should be bound to the lifetime of ProfileSyncService and not to the | |
| 992 // [Initialize -> sync disabled/shutdown] lifetime. We don't pass | |
| 993 // StartupController an Unretained reference to future-proof against | |
| 994 // the controller impl changing to post tasks. Therefore, we have a separate | |
| 995 // factory. | |
| 996 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; | |
| 997 | |
| 1033 // States related to sync token and connection. | 998 // States related to sync token and connection. |
| 1034 base::Time connection_status_update_time_; | 999 base::Time connection_status_update_time_; |
| 1035 syncer::ConnectionStatus connection_status_; | 1000 syncer::ConnectionStatus connection_status_; |
| 1036 base::Time token_request_time_; | 1001 base::Time token_request_time_; |
| 1037 base::Time token_receive_time_; | 1002 base::Time token_receive_time_; |
| 1038 GoogleServiceAuthError last_get_token_error_; | 1003 GoogleServiceAuthError last_get_token_error_; |
| 1039 base::Time next_token_request_time_; | 1004 base::Time next_token_request_time_; |
| 1040 | 1005 |
| 1041 scoped_ptr<SessionsSyncManager> sessions_sync_manager_; | 1006 scoped_ptr<SessionsSyncManager> sessions_sync_manager_; |
| 1042 | 1007 |
| 1043 scoped_ptr<syncer::NetworkResources> network_resources_; | 1008 scoped_ptr<syncer::NetworkResources> network_resources_; |
| 1044 | 1009 |
| 1010 browser_sync::StartupController startup_controller_; | |
|
haitaol1
2014/02/20 00:01:06
How about using scoped_ptr to always start fresh o
tim (not reviewing)
2014/02/20 22:52:52
There isn't a great place to instantiate it right
| |
| 1011 | |
| 1045 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1012 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 1046 }; | 1013 }; |
| 1047 | 1014 |
| 1048 bool ShouldShowActionOnUI( | 1015 bool ShouldShowActionOnUI( |
| 1049 const syncer::SyncProtocolError& error); | 1016 const syncer::SyncProtocolError& error); |
| 1050 | 1017 |
| 1051 | 1018 |
| 1052 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1019 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |