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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 class ProfileSyncComponentsFactory; | 56 class ProfileSyncComponentsFactory; |
57 class SupervisedUserSigninManagerWrapper; | 57 class SupervisedUserSigninManagerWrapper; |
58 class SyncErrorController; | 58 class SyncErrorController; |
59 | 59 |
60 namespace base { | 60 namespace base { |
61 class CommandLine; | 61 class CommandLine; |
62 }; | 62 }; |
63 | 63 |
64 namespace browser_sync { | 64 namespace browser_sync { |
65 class BackendMigrator; | 65 class BackendMigrator; |
66 class ChangeProcessor; | |
67 class DataTypeManager; | |
68 class DeviceInfo; | 66 class DeviceInfo; |
69 class FaviconCache; | 67 class FaviconCache; |
70 class JsController; | 68 class JsController; |
71 class OpenTabsUIDelegate; | 69 class OpenTabsUIDelegate; |
72 | 70 |
73 namespace sessions { | 71 namespace sessions { |
74 class SyncSessionSnapshot; | 72 class SyncSessionSnapshot; |
75 } // namespace sessions | 73 } // namespace sessions |
76 } // namespace browser_sync | 74 } // namespace browser_sync |
77 | 75 |
| 76 namespace sync_driver { |
| 77 class ChangeProcessor; |
| 78 class DataTypeManager; |
| 79 } // namespace sync_driver |
| 80 |
78 namespace syncer { | 81 namespace syncer { |
79 class BaseTransaction; | 82 class BaseTransaction; |
80 class NetworkResources; | 83 class NetworkResources; |
81 struct CommitCounters; | 84 struct CommitCounters; |
82 struct StatusCounters; | 85 struct StatusCounters; |
83 struct SyncCredentials; | 86 struct SyncCredentials; |
84 struct UpdateCounters; | 87 struct UpdateCounters; |
85 struct UserShare; | 88 struct UserShare; |
86 } // namespace syncer | 89 } // namespace syncer |
87 | 90 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // SetSetupInProgress(false) should be called when configuration is complete. | 172 // SetSetupInProgress(false) should be called when configuration is complete. |
170 // When SetSyncSetupCompleted() == false, but SetSetupInProgress(true) has | 173 // When SetSyncSetupCompleted() == false, but SetSetupInProgress(true) has |
171 // been called, then the sync engine knows not to download any user data. | 174 // been called, then the sync engine knows not to download any user data. |
172 // | 175 // |
173 // When initial sync is complete, the UI code should call | 176 // When initial sync is complete, the UI code should call |
174 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will | 177 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will |
175 // tell the sync engine that setup is completed and it can begin downloading | 178 // tell the sync engine that setup is completed and it can begin downloading |
176 // data from the sync server. | 179 // data from the sync server. |
177 // | 180 // |
178 class ProfileSyncService : public ProfileSyncServiceBase, | 181 class ProfileSyncService : public ProfileSyncServiceBase, |
179 public browser_sync::SyncFrontend, | 182 public sync_driver::SyncFrontend, |
180 public sync_driver::SyncPrefObserver, | 183 public sync_driver::SyncPrefObserver, |
181 public browser_sync::DataTypeManagerObserver, | 184 public sync_driver::DataTypeManagerObserver, |
182 public syncer::UnrecoverableErrorHandler, | 185 public syncer::UnrecoverableErrorHandler, |
183 public KeyedService, | 186 public KeyedService, |
184 public browser_sync::DataTypeEncryptionHandler, | 187 public sync_driver::DataTypeEncryptionHandler, |
185 public OAuth2TokenService::Consumer, | 188 public OAuth2TokenService::Consumer, |
186 public OAuth2TokenService::Observer, | 189 public OAuth2TokenService::Observer, |
187 public SigninManagerBase::Observer { | 190 public SigninManagerBase::Observer { |
188 public: | 191 public: |
189 typedef browser_sync::SyncBackendHost::Status Status; | 192 typedef browser_sync::SyncBackendHost::Status Status; |
190 | 193 |
191 // Status of sync server connection, sync token and token request. | 194 // Status of sync server connection, sync token and token request. |
192 struct SyncTokenStatus { | 195 struct SyncTokenStatus { |
193 SyncTokenStatus(); | 196 SyncTokenStatus(); |
194 ~SyncTokenStatus(); | 197 ~SyncTokenStatus(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 324 |
322 // Return whether OAuth2 refresh token is loaded and available for the backend | 325 // Return whether OAuth2 refresh token is loaded and available for the backend |
323 // to start up. Virtual to enable mocking in tests. | 326 // to start up. Virtual to enable mocking in tests. |
324 virtual bool IsOAuthRefreshTokenAvailable(); | 327 virtual bool IsOAuthRefreshTokenAvailable(); |
325 | 328 |
326 // Registers a data type controller with the sync service. This | 329 // Registers a data type controller with the sync service. This |
327 // makes the data type controller available for use, it does not | 330 // makes the data type controller available for use, it does not |
328 // enable or activate the synchronization of the data type (see | 331 // enable or activate the synchronization of the data type (see |
329 // ActivateDataType). Takes ownership of the pointer. | 332 // ActivateDataType). Takes ownership of the pointer. |
330 void RegisterDataTypeController( | 333 void RegisterDataTypeController( |
331 browser_sync::DataTypeController* data_type_controller); | 334 sync_driver::DataTypeController* data_type_controller); |
332 | 335 |
333 // Registers a type whose sync storage will not be managed by the | 336 // Registers a type whose sync storage will not be managed by the |
334 // ProfileSyncService. It declares that this sync type may be activated at | 337 // ProfileSyncService. It declares that this sync type may be activated at |
335 // some point in the future. This function call does not enable or activate | 338 // some point in the future. This function call does not enable or activate |
336 // the syncing of this type | 339 // the syncing of this type |
337 void RegisterNonBlockingType(syncer::ModelType type); | 340 void RegisterNonBlockingType(syncer::ModelType type); |
338 | 341 |
339 // Called by a component that supports non-blocking sync when it is ready to | 342 // Called by a component that supports non-blocking sync when it is ready to |
340 // initialize its connection to the sync backend. | 343 // initialize its connection to the sync backend. |
341 // | 344 // |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 virtual void AddObserverForDeviceInfoChange( | 379 virtual void AddObserverForDeviceInfoChange( |
377 browser_sync::SyncedDeviceTracker::Observer* observer); | 380 browser_sync::SyncedDeviceTracker::Observer* observer); |
378 | 381 |
379 // Removes the observer from device info notification. | 382 // Removes the observer from device info notification. |
380 virtual void RemoveObserverForDeviceInfoChange( | 383 virtual void RemoveObserverForDeviceInfoChange( |
381 browser_sync::SyncedDeviceTracker::Observer* observer); | 384 browser_sync::SyncedDeviceTracker::Observer* observer); |
382 | 385 |
383 // Fills state_map with a map of current data types that are possible to | 386 // Fills state_map with a map of current data types that are possible to |
384 // sync, as well as their states. | 387 // sync, as well as their states. |
385 void GetDataTypeControllerStates( | 388 void GetDataTypeControllerStates( |
386 browser_sync::DataTypeController::StateMap* state_map) const; | 389 sync_driver::DataTypeController::StateMap* state_map) const; |
387 | 390 |
388 // Disables sync for user. Use ShowLoginDialog to enable. | 391 // Disables sync for user. Use ShowLoginDialog to enable. |
389 virtual void DisableForUser(); | 392 virtual void DisableForUser(); |
390 | 393 |
391 // Disables sync for the user and prevents it from starting on next restart. | 394 // Disables sync for the user and prevents it from starting on next restart. |
392 virtual void StopSyncingPermanently(); | 395 virtual void StopSyncingPermanently(); |
393 | 396 |
394 // SyncFrontend implementation. | 397 // SyncFrontend implementation. |
395 virtual void OnBackendInitialized( | 398 virtual void OnBackendInitialized( |
396 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 399 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
(...skipping 25 matching lines...) Expand all Loading... |
422 virtual void OnEncryptionComplete() OVERRIDE; | 425 virtual void OnEncryptionComplete() OVERRIDE; |
423 virtual void OnMigrationNeededForTypes( | 426 virtual void OnMigrationNeededForTypes( |
424 syncer::ModelTypeSet types) OVERRIDE; | 427 syncer::ModelTypeSet types) OVERRIDE; |
425 virtual void OnExperimentsChanged( | 428 virtual void OnExperimentsChanged( |
426 const syncer::Experiments& experiments) OVERRIDE; | 429 const syncer::Experiments& experiments) OVERRIDE; |
427 virtual void OnActionableError( | 430 virtual void OnActionableError( |
428 const syncer::SyncProtocolError& error) OVERRIDE; | 431 const syncer::SyncProtocolError& error) OVERRIDE; |
429 | 432 |
430 // DataTypeManagerObserver implementation. | 433 // DataTypeManagerObserver implementation. |
431 virtual void OnConfigureDone( | 434 virtual void OnConfigureDone( |
432 const browser_sync::DataTypeManager::ConfigureResult& result) OVERRIDE; | 435 const sync_driver::DataTypeManager::ConfigureResult& result) OVERRIDE; |
433 virtual void OnConfigureRetry() OVERRIDE; | 436 virtual void OnConfigureRetry() OVERRIDE; |
434 virtual void OnConfigureStart() OVERRIDE; | 437 virtual void OnConfigureStart() OVERRIDE; |
435 | 438 |
436 // DataTypeEncryptionHandler implementation. | 439 // DataTypeEncryptionHandler implementation. |
437 virtual bool IsPassphraseRequired() const OVERRIDE; | 440 virtual bool IsPassphraseRequired() const OVERRIDE; |
438 virtual syncer::ModelTypeSet GetEncryptedDataTypes() const OVERRIDE; | 441 virtual syncer::ModelTypeSet GetEncryptedDataTypes() const OVERRIDE; |
439 | 442 |
440 // SigninManagerBase::Observer implementation. | 443 // SigninManagerBase::Observer implementation. |
441 virtual void GoogleSigninSucceeded(const std::string& username, | 444 virtual void GoogleSigninSucceeded(const std::string& username, |
442 const std::string& password) OVERRIDE; | 445 const std::string& password) OVERRIDE; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 706 |
704 // Marks all currently registered types as "acknowledged" so we won't prompt | 707 // Marks all currently registered types as "acknowledged" so we won't prompt |
705 // the user about them any more. | 708 // the user about them any more. |
706 void AcknowledgeSyncedTypes(); | 709 void AcknowledgeSyncedTypes(); |
707 | 710 |
708 SyncErrorController* sync_error_controller() { | 711 SyncErrorController* sync_error_controller() { |
709 return sync_error_controller_.get(); | 712 return sync_error_controller_.get(); |
710 } | 713 } |
711 | 714 |
712 // TODO(sync): This is only used in tests. Can we remove it? | 715 // TODO(sync): This is only used in tests. Can we remove it? |
713 const browser_sync::FailedDataTypesHandler& failed_data_types_handler() const; | 716 const sync_driver::FailedDataTypesHandler& failed_data_types_handler() const; |
714 | 717 |
715 browser_sync::DataTypeManager::ConfigureStatus configure_status() { | 718 sync_driver::DataTypeManager::ConfigureStatus configure_status() { |
716 return configure_status_; | 719 return configure_status_; |
717 } | 720 } |
718 | 721 |
719 // If true, the ProfileSyncService has detected that a new GAIA signin has | 722 // If true, the ProfileSyncService has detected that a new GAIA signin has |
720 // succeeded, and is waiting for initialization to complete. This is used by | 723 // succeeded, and is waiting for initialization to complete. This is used by |
721 // the UI to differentiate between a new auth error (encountered as part of | 724 // the UI to differentiate between a new auth error (encountered as part of |
722 // the initialization process) and a pre-existing auth error that just hasn't | 725 // the initialization process) and a pre-existing auth error that just hasn't |
723 // been cleared yet. Virtual for testing purposes. | 726 // been cleared yet. Virtual for testing purposes. |
724 virtual bool waiting_for_auth() const; | 727 virtual bool waiting_for_auth() const; |
725 | 728 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 // Shuts down the backend sync components. | 791 // Shuts down the backend sync components. |
789 // |option| indicates if syncing is being disabled or not, and whether | 792 // |option| indicates if syncing is being disabled or not, and whether |
790 // to claim ownership of sync thread from backend. | 793 // to claim ownership of sync thread from backend. |
791 void ShutdownImpl(browser_sync::SyncBackendHost::ShutdownOption option); | 794 void ShutdownImpl(browser_sync::SyncBackendHost::ShutdownOption option); |
792 | 795 |
793 // Return SyncCredentials from the OAuth2TokenService. | 796 // Return SyncCredentials from the OAuth2TokenService. |
794 syncer::SyncCredentials GetCredentials(); | 797 syncer::SyncCredentials GetCredentials(); |
795 | 798 |
796 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); | 799 virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); |
797 | 800 |
798 const browser_sync::DataTypeController::TypeMap& | 801 const sync_driver::DataTypeController::TypeMap& |
799 directory_data_type_controllers() { | 802 directory_data_type_controllers() { |
800 return directory_data_type_controllers_; | 803 return directory_data_type_controllers_; |
801 } | 804 } |
802 | 805 |
803 // Helper method for managing encryption UI. | 806 // Helper method for managing encryption UI. |
804 bool IsEncryptedDatatypeEnabled() const; | 807 bool IsEncryptedDatatypeEnabled() const; |
805 | 808 |
806 // Helper for OnUnrecoverableError. | 809 // Helper for OnUnrecoverableError. |
807 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, | 810 // TODO(tim): Use an enum for |delete_sync_database| here, in ShutdownImpl, |
808 // and in SyncBackendHost::Shutdown. | 811 // and in SyncBackendHost::Shutdown. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 // The time that OnConfigureStart is called. This member is zero if | 983 // The time that OnConfigureStart is called. This member is zero if |
981 // OnConfigureStart has not yet been called, and is reset to zero once | 984 // OnConfigureStart has not yet been called, and is reset to zero once |
982 // OnConfigureDone is called. | 985 // OnConfigureDone is called. |
983 base::Time sync_configure_start_time_; | 986 base::Time sync_configure_start_time_; |
984 | 987 |
985 // Indicates if this is the first time sync is being configured. This value | 988 // Indicates if this is the first time sync is being configured. This value |
986 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). | 989 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). |
987 bool is_first_time_sync_configure_; | 990 bool is_first_time_sync_configure_; |
988 | 991 |
989 // List of available data type controllers for directory types. | 992 // List of available data type controllers for directory types. |
990 browser_sync::DataTypeController::TypeMap directory_data_type_controllers_; | 993 sync_driver::DataTypeController::TypeMap directory_data_type_controllers_; |
991 | 994 |
992 // Whether the SyncBackendHost has been initialized. | 995 // Whether the SyncBackendHost has been initialized. |
993 bool backend_initialized_; | 996 bool backend_initialized_; |
994 | 997 |
995 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents | 998 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents |
996 // ProfileSyncService from starting backend till browser restarted or user | 999 // ProfileSyncService from starting backend till browser restarted or user |
997 // signed out. | 1000 // signed out. |
998 bool sync_disabled_by_admin_; | 1001 bool sync_disabled_by_admin_; |
999 | 1002 |
1000 // Set to true if a signin has completed but we're still waiting for the | 1003 // Set to true if a signin has completed but we're still waiting for the |
1001 // backend to refresh its credentials. | 1004 // backend to refresh its credentials. |
1002 bool is_auth_in_progress_; | 1005 bool is_auth_in_progress_; |
1003 | 1006 |
1004 // Encapsulates user signin - used to set/get the user's authenticated | 1007 // Encapsulates user signin - used to set/get the user's authenticated |
1005 // email address. | 1008 // email address. |
1006 const scoped_ptr<SupervisedUserSigninManagerWrapper> signin_; | 1009 const scoped_ptr<SupervisedUserSigninManagerWrapper> signin_; |
1007 | 1010 |
1008 // Information describing an unrecoverable error. | 1011 // Information describing an unrecoverable error. |
1009 UnrecoverableErrorReason unrecoverable_error_reason_; | 1012 UnrecoverableErrorReason unrecoverable_error_reason_; |
1010 std::string unrecoverable_error_message_; | 1013 std::string unrecoverable_error_message_; |
1011 tracked_objects::Location unrecoverable_error_location_; | 1014 tracked_objects::Location unrecoverable_error_location_; |
1012 | 1015 |
1013 // Manages the start and stop of the directory data types. | 1016 // Manages the start and stop of the directory data types. |
1014 scoped_ptr<browser_sync::DataTypeManager> directory_data_type_manager_; | 1017 scoped_ptr<sync_driver::DataTypeManager> directory_data_type_manager_; |
1015 | 1018 |
1016 // Manager for the non-blocking data types. | 1019 // Manager for the non-blocking data types. |
1017 browser_sync::NonBlockingDataTypeManager non_blocking_data_type_manager_; | 1020 sync_driver::NonBlockingDataTypeManager non_blocking_data_type_manager_; |
1018 | 1021 |
1019 ObserverList<ProfileSyncServiceBase::Observer> observers_; | 1022 ObserverList<ProfileSyncServiceBase::Observer> observers_; |
1020 ObserverList<browser_sync::ProtocolEventObserver> protocol_event_observers_; | 1023 ObserverList<browser_sync::ProtocolEventObserver> protocol_event_observers_; |
1021 ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; | 1024 ObserverList<syncer::TypeDebugInfoObserver> type_debug_info_observers_; |
1022 | 1025 |
1023 syncer::SyncJsController sync_js_controller_; | 1026 syncer::SyncJsController sync_js_controller_; |
1024 | 1027 |
1025 // This allows us to gracefully handle an ABORTED return code from the | 1028 // This allows us to gracefully handle an ABORTED return code from the |
1026 // DataTypeManager in the event that the server informed us to cease and | 1029 // DataTypeManager in the event that the server informed us to cease and |
1027 // desist syncing immediately. | 1030 // desist syncing immediately. |
(...skipping 21 matching lines...) Expand all Loading... |
1049 | 1052 |
1050 // This is the last |SyncProtocolError| we received from the server that had | 1053 // This is the last |SyncProtocolError| we received from the server that had |
1051 // an action set on it. | 1054 // an action set on it. |
1052 syncer::SyncProtocolError last_actionable_error_; | 1055 syncer::SyncProtocolError last_actionable_error_; |
1053 | 1056 |
1054 // Exposes sync errors to the UI. | 1057 // Exposes sync errors to the UI. |
1055 scoped_ptr<SyncErrorController> sync_error_controller_; | 1058 scoped_ptr<SyncErrorController> sync_error_controller_; |
1056 | 1059 |
1057 // Tracks the set of failed data types (those that encounter an error | 1060 // Tracks the set of failed data types (those that encounter an error |
1058 // or must delay loading for some reason). | 1061 // or must delay loading for some reason). |
1059 browser_sync::FailedDataTypesHandler failed_data_types_handler_; | 1062 sync_driver::FailedDataTypesHandler failed_data_types_handler_; |
1060 | 1063 |
1061 browser_sync::DataTypeManager::ConfigureStatus configure_status_; | 1064 sync_driver::DataTypeManager::ConfigureStatus configure_status_; |
1062 | 1065 |
1063 // The set of currently enabled sync experiments. | 1066 // The set of currently enabled sync experiments. |
1064 syncer::Experiments current_experiments_; | 1067 syncer::Experiments current_experiments_; |
1065 | 1068 |
1066 // Sync's internal debug info listener. Used to record datatype configuration | 1069 // Sync's internal debug info listener. Used to record datatype configuration |
1067 // and association information. | 1070 // and association information. |
1068 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 1071 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
1069 | 1072 |
1070 // A thread where all the sync operations happen. | 1073 // A thread where all the sync operations happen. |
1071 // OWNERSHIP Notes: | 1074 // OWNERSHIP Notes: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 scoped_ptr<base::Time> last_backup_time_; | 1136 scoped_ptr<base::Time> last_backup_time_; |
1134 | 1137 |
1135 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1138 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
1136 }; | 1139 }; |
1137 | 1140 |
1138 bool ShouldShowActionOnUI( | 1141 bool ShouldShowActionOnUI( |
1139 const syncer::SyncProtocolError& error); | 1142 const syncer::SyncProtocolError& error); |
1140 | 1143 |
1141 | 1144 |
1142 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 1145 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |