| 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 <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "base/time.h" | 19 #include "base/time.h" |
| 20 #include "base/timer.h" | 20 #include "base/timer.h" |
| 21 #include "chrome/browser/profiles/profile_keyed_service.h" | 21 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 22 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" | 22 #include "chrome/browser/sync/backend_unrecoverable_error_handler.h" |
| 23 #include "chrome/browser/sync/failed_datatypes_handler.h" | 23 #include "chrome/browser/sync/failed_datatypes_handler.h" |
| 24 #include "chrome/browser/sync/glue/data_type_controller.h" | 24 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 25 #include "chrome/browser/sync/glue/data_type_manager.h" | 25 #include "chrome/browser/sync/glue/data_type_manager.h" |
| 26 #include "chrome/browser/sync/glue/data_type_manager_observer.h" |
| 26 #include "chrome/browser/sync/glue/sync_backend_host.h" | 27 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 27 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 28 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 28 #include "chrome/browser/sync/profile_sync_service_observer.h" | 29 #include "chrome/browser/sync/profile_sync_service_observer.h" |
| 29 #include "chrome/browser/sync/sync_prefs.h" | 30 #include "chrome/browser/sync/sync_prefs.h" |
| 30 #include "chrome/common/net/gaia/google_service_auth_error.h" | 31 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 31 #include "content/public/browser/notification_observer.h" | 32 #include "content/public/browser/notification_observer.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
| 34 #include "googleurl/src/gurl.h" | 35 #include "googleurl/src/gurl.h" |
| 35 #include "sync/internal_api/public/base/model_type.h" | 36 #include "sync/internal_api/public/base/model_type.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // When SetSyncSetupCompleted() == false, but SetSetupInProgress(true) has | 143 // When SetSyncSetupCompleted() == false, but SetSetupInProgress(true) has |
| 143 // been called, then the sync engine knows not to download any user data. | 144 // been called, then the sync engine knows not to download any user data. |
| 144 // | 145 // |
| 145 // When initial sync is complete, the UI code should call | 146 // When initial sync is complete, the UI code should call |
| 146 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will | 147 // SetSyncSetupCompleted() followed by SetSetupInProgress(false) - this will |
| 147 // tell the sync engine that setup is completed and it can begin downloading | 148 // tell the sync engine that setup is completed and it can begin downloading |
| 148 // data from the sync server. | 149 // data from the sync server. |
| 149 // | 150 // |
| 150 class ProfileSyncService : public browser_sync::SyncFrontend, | 151 class ProfileSyncService : public browser_sync::SyncFrontend, |
| 151 public browser_sync::SyncPrefObserver, | 152 public browser_sync::SyncPrefObserver, |
| 153 public browser_sync::DataTypeManagerObserver, |
| 152 public syncer::UnrecoverableErrorHandler, | 154 public syncer::UnrecoverableErrorHandler, |
| 153 public content::NotificationObserver, | 155 public content::NotificationObserver, |
| 154 public ProfileKeyedService { | 156 public ProfileKeyedService { |
| 155 public: | 157 public: |
| 156 typedef ProfileSyncServiceObserver Observer; | 158 typedef ProfileSyncServiceObserver Observer; |
| 157 typedef browser_sync::SyncBackendHost::Status Status; | 159 typedef browser_sync::SyncBackendHost::Status Status; |
| 158 | 160 |
| 159 enum SyncEventCodes { | 161 enum SyncEventCodes { |
| 160 MIN_SYNC_EVENT_CODE = 0, | 162 MIN_SYNC_EVENT_CODE = 0, |
| 161 | 163 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 syncer::ModelTypeSet encrypted_types, | 281 syncer::ModelTypeSet encrypted_types, |
| 280 bool encrypt_everything) OVERRIDE; | 282 bool encrypt_everything) OVERRIDE; |
| 281 virtual void OnEncryptionComplete() OVERRIDE; | 283 virtual void OnEncryptionComplete() OVERRIDE; |
| 282 virtual void OnMigrationNeededForTypes( | 284 virtual void OnMigrationNeededForTypes( |
| 283 syncer::ModelTypeSet types) OVERRIDE; | 285 syncer::ModelTypeSet types) OVERRIDE; |
| 284 virtual void OnExperimentsChanged( | 286 virtual void OnExperimentsChanged( |
| 285 const syncer::Experiments& experiments) OVERRIDE; | 287 const syncer::Experiments& experiments) OVERRIDE; |
| 286 virtual void OnActionableError( | 288 virtual void OnActionableError( |
| 287 const syncer::SyncProtocolError& error) OVERRIDE; | 289 const syncer::SyncProtocolError& error) OVERRIDE; |
| 288 | 290 |
| 291 // DataTypeManagerObserver implementation. |
| 292 virtual void OnConfigureBlocked() OVERRIDE; |
| 293 virtual void OnConfigureDone( |
| 294 const browser_sync::DataTypeManager::ConfigureResult& result) OVERRIDE; |
| 295 virtual void OnConfigureRetry() OVERRIDE; |
| 296 virtual void OnConfigureStart() OVERRIDE; |
| 297 |
| 289 // Update the last auth error and notify observers of error state. | 298 // Update the last auth error and notify observers of error state. |
| 290 void UpdateAuthErrorState(const GoogleServiceAuthError& error); | 299 void UpdateAuthErrorState(const GoogleServiceAuthError& error); |
| 291 | 300 |
| 292 // Called when a user chooses which data types to sync as part of the sync | 301 // Called when a user chooses which data types to sync as part of the sync |
| 293 // setup wizard. |sync_everything| represents whether they chose the | 302 // setup wizard. |sync_everything| represents whether they chose the |
| 294 // "keep everything synced" option; if true, |chosen_types| will be ignored | 303 // "keep everything synced" option; if true, |chosen_types| will be ignored |
| 295 // and all data types will be synced. |sync_everything| means "sync all | 304 // and all data types will be synced. |sync_everything| means "sync all |
| 296 // current and future data types." | 305 // current and future data types." |
| 297 virtual void OnUserChoseDatatypes(bool sync_everything, | 306 virtual void OnUserChoseDatatypes(bool sync_everything, |
| 298 syncer::ModelTypeSet chosen_types); | 307 syncer::ModelTypeSet chosen_types); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 | 783 |
| 775 // The last time we detected a successful transition from SYNCING state. | 784 // The last time we detected a successful transition from SYNCING state. |
| 776 // Our backend notifies us whenever we should take a new snapshot. | 785 // Our backend notifies us whenever we should take a new snapshot. |
| 777 base::Time last_synced_time_; | 786 base::Time last_synced_time_; |
| 778 | 787 |
| 779 // The time that StartUp() is called. This member is zero if StartUp() has | 788 // The time that StartUp() is called. This member is zero if StartUp() has |
| 780 // never been called, and is reset to zero once OnBackendInitialized() is | 789 // never been called, and is reset to zero once OnBackendInitialized() is |
| 781 // called. | 790 // called. |
| 782 base::Time start_up_time_; | 791 base::Time start_up_time_; |
| 783 | 792 |
| 784 // The time that NOTIFICATION_SYNC_CONFIGURE_START is received. This member | 793 // The time that OnConfigureStart is called. This member is zero if |
| 785 // is zero if NOTIFICATION_SYNC_CONFIGURE_START has not been fired yet, and | 794 // OnConfigureStart has not yet been called, and is reset to zero once |
| 786 // is reset to zero once NOTIFICATION_SYNC_CONFIGURE_DONE is received. | 795 // OnConfigureDone is called. |
| 787 base::Time sync_configure_start_time_; | 796 base::Time sync_configure_start_time_; |
| 788 | 797 |
| 789 // Indicates if this is the first time sync is being configured. This value | 798 // Indicates if this is the first time sync is being configured. This value |
| 790 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). | 799 // is equal to !HasSyncSetupCompleted() at the time of OnBackendInitialized(). |
| 791 bool is_first_time_sync_configure_; | 800 bool is_first_time_sync_configure_; |
| 792 | 801 |
| 793 // List of available data type controllers. | 802 // List of available data type controllers. |
| 794 browser_sync::DataTypeController::TypeMap data_type_controllers_; | 803 browser_sync::DataTypeController::TypeMap data_type_controllers_; |
| 795 | 804 |
| 796 // Whether the SyncBackendHost has been initialized. | 805 // Whether the SyncBackendHost has been initialized. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 syncer::SyncNotifierRegistrar notifier_registrar_; | 889 syncer::SyncNotifierRegistrar notifier_registrar_; |
| 881 | 890 |
| 882 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 891 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
| 883 }; | 892 }; |
| 884 | 893 |
| 885 bool ShouldShowActionOnUI( | 894 bool ShouldShowActionOnUI( |
| 886 const syncer::SyncProtocolError& error); | 895 const syncer::SyncProtocolError& error); |
| 887 | 896 |
| 888 | 897 |
| 889 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ | 898 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |