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 COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ |
6 #define COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ | 6 #define COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // The "sync everything" state cannot be read from ProfileSyncService, but | 158 // The "sync everything" state cannot be read from ProfileSyncService, but |
159 // is instead pulled from SyncPrefs.HasKeepEverythingSynced(). | 159 // is instead pulled from SyncPrefs.HasKeepEverythingSynced(). |
160 // | 160 // |
161 // Initial sync setup: | 161 // Initial sync setup: |
162 // | 162 // |
163 // For privacy reasons, it is usually desirable to avoid syncing any data | 163 // For privacy reasons, it is usually desirable to avoid syncing any data |
164 // types until the user has finished setting up sync. There are two APIs | 164 // types until the user has finished setting up sync. There are two APIs |
165 // that control the initial sync download: | 165 // that control the initial sync download: |
166 // | 166 // |
167 // * SetFirstSetupComplete() | 167 // * SetFirstSetupComplete() |
168 // * GetSetupInProgressHandle() | 168 // * SetSetupInProgress() |
169 // | 169 // |
170 // SetFirstSetupComplete() should be called once the user has finished setting | 170 // SetFirstSetupComplete() should be called once the user has finished setting |
171 // up sync at least once on their account. GetSetupInProgressHandle() should | 171 // up sync at least once on their account. SetSetupInProgress(true) should be |
172 // be called while the user is actively configuring their account. The handle | 172 // called while the user is actively configuring their account, and then |
173 // should be deleted once configuration is complete. | 173 // SetSetupInProgress(false) should be called when configuration is complete. |
174 // | 174 // Once both these conditions have been met, CanConfigureDataTypes() will |
175 // Once first setup has completed and there are no outstanding | 175 // return true and datatype configuration can begin. |
176 // setup-in-progress handles, CanConfigureDataTypes() will return true and | |
177 // datatype configuration can begin. | |
178 class ProfileSyncService : public sync_driver::SyncService, | 176 class ProfileSyncService : public sync_driver::SyncService, |
179 public sync_driver::SyncFrontend, | 177 public sync_driver::SyncFrontend, |
180 public sync_driver::SyncPrefObserver, | 178 public sync_driver::SyncPrefObserver, |
181 public sync_driver::DataTypeManagerObserver, | 179 public sync_driver::DataTypeManagerObserver, |
182 public syncer::UnrecoverableErrorHandler, | 180 public syncer::UnrecoverableErrorHandler, |
183 public KeyedService, | 181 public KeyedService, |
184 public OAuth2TokenService::Consumer, | 182 public OAuth2TokenService::Consumer, |
185 public OAuth2TokenService::Observer, | 183 public OAuth2TokenService::Observer, |
186 public SigninManagerBase::Observer, | 184 public SigninManagerBase::Observer, |
187 public GaiaCookieManagerService::Observer { | 185 public GaiaCookieManagerService::Observer { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 bool CanSyncStart() const override; | 273 bool CanSyncStart() const override; |
276 void RequestStop(SyncStopDataFate data_fate) override; | 274 void RequestStop(SyncStopDataFate data_fate) override; |
277 void RequestStart() override; | 275 void RequestStart() override; |
278 syncer::ModelTypeSet GetActiveDataTypes() const override; | 276 syncer::ModelTypeSet GetActiveDataTypes() const override; |
279 sync_driver::SyncClient* GetSyncClient() const override; | 277 sync_driver::SyncClient* GetSyncClient() const override; |
280 syncer::ModelTypeSet GetPreferredDataTypes() const override; | 278 syncer::ModelTypeSet GetPreferredDataTypes() const override; |
281 void OnUserChoseDatatypes(bool sync_everything, | 279 void OnUserChoseDatatypes(bool sync_everything, |
282 syncer::ModelTypeSet chosen_types) override; | 280 syncer::ModelTypeSet chosen_types) override; |
283 void SetFirstSetupComplete() override; | 281 void SetFirstSetupComplete() override; |
284 bool IsFirstSetupInProgress() const override; | 282 bool IsFirstSetupInProgress() const override; |
285 std::unique_ptr<sync_driver::SyncSetupInProgressHandle> | 283 void SetSetupInProgress(bool setup_in_progress) override; |
286 GetSetupInProgressHandle() override; | |
287 bool IsSetupInProgress() const override; | 284 bool IsSetupInProgress() const override; |
288 bool ConfigurationDone() const override; | 285 bool ConfigurationDone() const override; |
289 const GoogleServiceAuthError& GetAuthError() const override; | 286 const GoogleServiceAuthError& GetAuthError() const override; |
290 bool HasUnrecoverableError() const override; | 287 bool HasUnrecoverableError() const override; |
291 bool IsBackendInitialized() const override; | 288 bool IsBackendInitialized() const override; |
292 sync_driver::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; | 289 sync_driver::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; |
293 bool IsPassphraseRequiredForDecryption() const override; | 290 bool IsPassphraseRequiredForDecryption() const override; |
294 base::Time GetExplicitPassphraseTime() const override; | 291 base::Time GetExplicitPassphraseTime() const override; |
295 bool IsUsingSecondaryPassphrase() const override; | 292 bool IsUsingSecondaryPassphrase() const override; |
296 void EnableEncryptEverything() override; | 293 void EnableEncryptEverything() override; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 795 |
799 // Calls sync backend to send ClearServerDataMessage to server. | 796 // Calls sync backend to send ClearServerDataMessage to server. |
800 void ClearAndRestartSyncForPassphraseEncryption(); | 797 void ClearAndRestartSyncForPassphraseEncryption(); |
801 | 798 |
802 // Restarts sync clearing directory in the process. | 799 // Restarts sync clearing directory in the process. |
803 void OnClearServerDataDone(); | 800 void OnClearServerDataDone(); |
804 | 801 |
805 // True if setup has been completed at least once and is not in progress. | 802 // True if setup has been completed at least once and is not in progress. |
806 bool CanConfigureDataTypes() const; | 803 bool CanConfigureDataTypes() const; |
807 | 804 |
808 // Called when a SetupInProgressHandle issued by this instance is destroyed. | |
809 virtual void OnSetupInProgressHandleDestroyed(); | |
810 | |
811 // This profile's SyncClient, which abstracts away non-Sync dependencies and | 805 // This profile's SyncClient, which abstracts away non-Sync dependencies and |
812 // the Sync API component factory. | 806 // the Sync API component factory. |
813 std::unique_ptr<sync_driver::SyncClient> sync_client_; | 807 std::unique_ptr<sync_driver::SyncClient> sync_client_; |
814 | 808 |
815 // The class that handles getting, setting, and persisting sync | 809 // The class that handles getting, setting, and persisting sync |
816 // preferences. | 810 // preferences. |
817 sync_driver::SyncPrefs sync_prefs_; | 811 sync_driver::SyncPrefs sync_prefs_; |
818 | 812 |
819 // TODO(ncarter): Put this in a profile, once there is UI for it. | 813 // TODO(ncarter): Put this in a profile, once there is UI for it. |
820 // This specifies where to find the sync server. | 814 // This specifies where to find the sync server. |
(...skipping 22 matching lines...) Expand all Loading... |
843 | 837 |
844 // Threading context. | 838 // Threading context. |
845 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 839 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
846 scoped_refptr<base::SingleThreadTaskRunner> file_thread_; | 840 scoped_refptr<base::SingleThreadTaskRunner> file_thread_; |
847 base::SequencedWorkerPool* blocking_pool_; | 841 base::SequencedWorkerPool* blocking_pool_; |
848 | 842 |
849 // Indicates if this is the first time sync is being configured. This value | 843 // Indicates if this is the first time sync is being configured. This value |
850 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). | 844 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). |
851 bool is_first_time_sync_configure_; | 845 bool is_first_time_sync_configure_; |
852 | 846 |
853 // Number of UIs currently configuring the Sync service. When this number | |
854 // is decremented back to zero, Sync setup is marked no longer in progress. | |
855 int outstanding_setup_in_progress_handles_ = 0; | |
856 | |
857 // List of available data type controllers. | 847 // List of available data type controllers. |
858 sync_driver::DataTypeController::TypeMap data_type_controllers_; | 848 sync_driver::DataTypeController::TypeMap data_type_controllers_; |
859 | 849 |
860 // Whether the SyncBackendHost has been initialized. | 850 // Whether the SyncBackendHost has been initialized. |
861 bool backend_initialized_; | 851 bool backend_initialized_; |
862 | 852 |
863 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents | 853 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents |
864 // ProfileSyncService from starting backend till browser restarted or user | 854 // ProfileSyncService from starting backend till browser restarted or user |
865 // signed out. | 855 // signed out. |
866 bool sync_disabled_by_admin_; | 856 bool sync_disabled_by_admin_; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; | 1020 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; |
1031 | 1021 |
1032 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); | 1022 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); |
1033 }; | 1023 }; |
1034 | 1024 |
1035 bool ShouldShowActionOnUI( | 1025 bool ShouldShowActionOnUI( |
1036 const syncer::SyncProtocolError& error); | 1026 const syncer::SyncProtocolError& error); |
1037 | 1027 |
1038 | 1028 |
1039 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ | 1029 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ |
OLD | NEW |