| 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> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 49 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 50 #include "sync/js/sync_js_controller.h" | 50 #include "sync/js/sync_js_controller.h" |
| 51 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 52 | 52 |
| 53 class ManagedUserSigninManagerWrapper; | 53 class ManagedUserSigninManagerWrapper; |
| 54 class Profile; | 54 class Profile; |
| 55 class ProfileOAuth2TokenService; | 55 class ProfileOAuth2TokenService; |
| 56 class ProfileSyncComponentsFactory; | 56 class ProfileSyncComponentsFactory; |
| 57 class SyncErrorController; | 57 class SyncErrorController; |
| 58 | 58 |
| 59 namespace base { |
| 60 class CommandLine; |
| 61 }; |
| 62 |
| 59 namespace extensions { | 63 namespace extensions { |
| 60 struct Event; | 64 struct Event; |
| 61 } | 65 } |
| 62 | 66 |
| 63 namespace browser_sync { | 67 namespace browser_sync { |
| 64 class BackendMigrator; | 68 class BackendMigrator; |
| 65 class ChangeProcessor; | 69 class ChangeProcessor; |
| 66 class DataTypeManager; | 70 class DataTypeManager; |
| 67 class DeviceInfo; | 71 class DeviceInfo; |
| 68 class FaviconCache; | 72 class FaviconCache; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 264 |
| 261 // Default sync server URL. | 265 // Default sync server URL. |
| 262 static const char* kSyncServerUrl; | 266 static const char* kSyncServerUrl; |
| 263 // Sync server URL for dev channel users | 267 // Sync server URL for dev channel users |
| 264 static const char* kDevServerUrl; | 268 static const char* kDevServerUrl; |
| 265 | 269 |
| 266 // Takes ownership of |factory| and |signin_wrapper|. | 270 // Takes ownership of |factory| and |signin_wrapper|. |
| 267 ProfileSyncService( | 271 ProfileSyncService( |
| 268 ProfileSyncComponentsFactory* factory, | 272 ProfileSyncComponentsFactory* factory, |
| 269 Profile* profile, | 273 Profile* profile, |
| 270 ManagedUserSigninManagerWrapper* signin_wrapper, | 274 scoped_ptr<ManagedUserSigninManagerWrapper> signin_wrapper, |
| 271 ProfileOAuth2TokenService* oauth2_token_service, | 275 ProfileOAuth2TokenService* oauth2_token_service, |
| 272 browser_sync::ProfileSyncServiceStartBehavior start_behavior); | 276 browser_sync::ProfileSyncServiceStartBehavior start_behavior); |
| 273 virtual ~ProfileSyncService(); | 277 virtual ~ProfileSyncService(); |
| 274 | 278 |
| 275 // Initializes the object. This must be called at most once, and | 279 // Initializes the object. This must be called at most once, and |
| 276 // immediately after an object of this class is constructed. | 280 // immediately after an object of this class is constructed. |
| 277 void Initialize(); | 281 void Initialize(); |
| 278 | 282 |
| 279 virtual void SetSyncSetupCompleted(); | 283 virtual void SetSyncSetupCompleted(); |
| 280 | 284 |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 | 770 |
| 767 void SetBackupStartDelayForTest(base::TimeDelta delay); | 771 void SetBackupStartDelayForTest(base::TimeDelta delay); |
| 768 | 772 |
| 769 BackendMode backend_mode() const { | 773 BackendMode backend_mode() const { |
| 770 return backend_mode_; | 774 return backend_mode_; |
| 771 } | 775 } |
| 772 | 776 |
| 773 void SetClearingBrowseringDataForTesting( | 777 void SetClearingBrowseringDataForTesting( |
| 774 base::Callback<void(Profile*, base::Time, base::Time)> c); | 778 base::Callback<void(Profile*, base::Time, base::Time)> c); |
| 775 | 779 |
| 780 // Return the base URL of the Sync Server. |
| 781 static GURL GetSyncServiceURL(const base::CommandLine& command_line); |
| 782 |
| 776 protected: | 783 protected: |
| 777 // Helper to configure the priority data types. | 784 // Helper to configure the priority data types. |
| 778 void ConfigurePriorityDataTypes(); | 785 void ConfigurePriorityDataTypes(); |
| 779 | 786 |
| 780 // Helper to install and configure a data type manager. | 787 // Helper to install and configure a data type manager. |
| 781 void ConfigureDataTypeManager(); | 788 void ConfigureDataTypeManager(); |
| 782 | 789 |
| 783 // Shuts down the backend sync components. | 790 // Shuts down the backend sync components. |
| 784 // |option| indicates if syncing is being disabled or not, and whether | 791 // |option| indicates if syncing is being disabled or not, and whether |
| 785 // to claim ownership of sync thread from backend. | 792 // to claim ownership of sync thread from backend. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 | 960 |
| 954 // The profile whose data we are synchronizing. | 961 // The profile whose data we are synchronizing. |
| 955 Profile* profile_; | 962 Profile* profile_; |
| 956 | 963 |
| 957 // The class that handles getting, setting, and persisting sync | 964 // The class that handles getting, setting, and persisting sync |
| 958 // preferences. | 965 // preferences. |
| 959 sync_driver::SyncPrefs sync_prefs_; | 966 sync_driver::SyncPrefs sync_prefs_; |
| 960 | 967 |
| 961 // TODO(ncarter): Put this in a profile, once there is UI for it. | 968 // TODO(ncarter): Put this in a profile, once there is UI for it. |
| 962 // This specifies where to find the sync server. | 969 // This specifies where to find the sync server. |
| 963 GURL sync_service_url_; | 970 const GURL sync_service_url_; |
| 964 | 971 |
| 965 // The last time we detected a successful transition from SYNCING state. | 972 // The last time we detected a successful transition from SYNCING state. |
| 966 // Our backend notifies us whenever we should take a new snapshot. | 973 // Our backend notifies us whenever we should take a new snapshot. |
| 967 base::Time last_synced_time_; | 974 base::Time last_synced_time_; |
| 968 | 975 |
| 969 // The time that OnConfigureStart is called. This member is zero if | 976 // The time that OnConfigureStart is called. This member is zero if |
| 970 // OnConfigureStart has not yet been called, and is reset to zero once | 977 // OnConfigureStart has not yet been called, and is reset to zero once |
| 971 // OnConfigureDone is called. | 978 // OnConfigureDone is called. |
| 972 base::Time sync_configure_start_time_; | 979 base::Time sync_configure_start_time_; |
| 973 | 980 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 985 // ProfileSyncService from starting backend till browser restarted or user | 992 // ProfileSyncService from starting backend till browser restarted or user |
| 986 // signed out. | 993 // signed out. |
| 987 bool sync_disabled_by_admin_; | 994 bool sync_disabled_by_admin_; |
| 988 | 995 |
| 989 // Set to true if a signin has completed but we're still waiting for the | 996 // Set to true if a signin has completed but we're still waiting for the |
| 990 // backend to refresh its credentials. | 997 // backend to refresh its credentials. |
| 991 bool is_auth_in_progress_; | 998 bool is_auth_in_progress_; |
| 992 | 999 |
| 993 // Encapsulates user signin - used to set/get the user's authenticated | 1000 // Encapsulates user signin - used to set/get the user's authenticated |
| 994 // email address. | 1001 // email address. |
| 995 scoped_ptr<ManagedUserSigninManagerWrapper> signin_; | 1002 const scoped_ptr<ManagedUserSigninManagerWrapper> signin_; |
| 996 | 1003 |
| 997 // Information describing an unrecoverable error. | 1004 // Information describing an unrecoverable error. |
| 998 UnrecoverableErrorReason unrecoverable_error_reason_; | 1005 UnrecoverableErrorReason unrecoverable_error_reason_; |
| 999 std::string unrecoverable_error_message_; | 1006 std::string unrecoverable_error_message_; |
| 1000 tracked_objects::Location unrecoverable_error_location_; | 1007 tracked_objects::Location unrecoverable_error_location_; |
| 1001 | 1008 |
| 1002 // Manages the start and stop of the directory data types. | 1009 // Manages the start and stop of the directory data types. |
| 1003 scoped_ptr<browser_sync::DataTypeManager> directory_data_type_manager_; | 1010 scoped_ptr<browser_sync::DataTypeManager> directory_data_type_manager_; |
| 1004 | 1011 |
| 1005 // Manager for the non-blocking data types. | 1012 // Manager for the non-blocking data types. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 1064 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
| 1058 | 1065 |
| 1059 // A thread where all the sync operations happen. | 1066 // A thread where all the sync operations happen. |
| 1060 // OWNERSHIP Notes: | 1067 // OWNERSHIP Notes: |
| 1061 // * Created when backend starts for the first time. | 1068 // * Created when backend starts for the first time. |
| 1062 // * If sync is disabled, PSS claims ownership from backend. | 1069 // * If sync is disabled, PSS claims ownership from backend. |
| 1063 // * If sync is reenabled, PSS passes ownership to new backend. | 1070 // * If sync is reenabled, PSS passes ownership to new backend. |
| 1064 scoped_ptr<base::Thread> sync_thread_; | 1071 scoped_ptr<base::Thread> sync_thread_; |
| 1065 | 1072 |
| 1066 // ProfileSyncService uses this service to get access tokens. | 1073 // ProfileSyncService uses this service to get access tokens. |
| 1067 ProfileOAuth2TokenService* oauth2_token_service_; | 1074 ProfileOAuth2TokenService* const oauth2_token_service_; |
| 1068 | 1075 |
| 1069 // ProfileSyncService needs to remember access token in order to invalidate it | 1076 // ProfileSyncService needs to remember access token in order to invalidate it |
| 1070 // with OAuth2TokenService. | 1077 // with OAuth2TokenService. |
| 1071 std::string access_token_; | 1078 std::string access_token_; |
| 1072 | 1079 |
| 1073 // ProfileSyncService needs to hold reference to access_token_request_ for | 1080 // ProfileSyncService needs to hold reference to access_token_request_ for |
| 1074 // the duration of request in order to receive callbacks. | 1081 // the duration of request in order to receive callbacks. |
| 1075 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | 1082 scoped_ptr<OAuth2TokenService::Request> access_token_request_; |
| 1076 | 1083 |
| 1077 // If RequestAccessToken fails with transient error then retry requesting | 1084 // If RequestAccessToken fails with transient error then retry requesting |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 base::Callback<void(Profile*, base::Time, base::Time)> clear_browsing_data_; | 1123 base::Callback<void(Profile*, base::Time, base::Time)> clear_browsing_data_; |
| 1117 | 1124 |
| 1118 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1125 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 1119 }; | 1126 }; |
| 1120 | 1127 |
| 1121 bool ShouldShowActionOnUI( | 1128 bool ShouldShowActionOnUI( |
| 1122 const syncer::SyncProtocolError& error); | 1129 const syncer::SyncProtocolError& error); |
| 1123 | 1130 |
| 1124 | 1131 |
| 1125 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1132 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |