Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: components/browser_sync/browser/profile_sync_service.h

Issue 2044303004: Sync: Support multiple setup UIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix old tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // * SetSetupInProgress() 168 // * GetSetupInProgressHandle()
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. SetSetupInProgress(true) should be 171 // up sync at least once on their account. GetSetupInProgressHandle() should
172 // called while the user is actively configuring their account, and then 172 // be called while the user is actively configuring their account. The handle
173 // SetSetupInProgress(false) should be called when configuration is complete. 173 // should be deleted once configuration is complete.
174 // Once both these conditions have been met, CanConfigureDataTypes() will 174 //
175 // return true and datatype configuration can begin. 175 // Once first setup has completed and there are no outstanding
176 // setup-in-progress handles, CanConfigureDataTypes() will return true and
177 // datatype configuration can begin.
176 class ProfileSyncService : public sync_driver::SyncService, 178 class ProfileSyncService : public sync_driver::SyncService,
177 public sync_driver::SyncFrontend, 179 public sync_driver::SyncFrontend,
178 public sync_driver::SyncPrefObserver, 180 public sync_driver::SyncPrefObserver,
179 public sync_driver::DataTypeManagerObserver, 181 public sync_driver::DataTypeManagerObserver,
180 public syncer::UnrecoverableErrorHandler, 182 public syncer::UnrecoverableErrorHandler,
181 public KeyedService, 183 public KeyedService,
182 public OAuth2TokenService::Consumer, 184 public OAuth2TokenService::Consumer,
183 public OAuth2TokenService::Observer, 185 public OAuth2TokenService::Observer,
184 public SigninManagerBase::Observer, 186 public SigninManagerBase::Observer,
185 public GaiaCookieManagerService::Observer { 187 public GaiaCookieManagerService::Observer {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 bool CanSyncStart() const override; 275 bool CanSyncStart() const override;
274 void RequestStop(SyncStopDataFate data_fate) override; 276 void RequestStop(SyncStopDataFate data_fate) override;
275 void RequestStart() override; 277 void RequestStart() override;
276 syncer::ModelTypeSet GetActiveDataTypes() const override; 278 syncer::ModelTypeSet GetActiveDataTypes() const override;
277 sync_driver::SyncClient* GetSyncClient() const override; 279 sync_driver::SyncClient* GetSyncClient() const override;
278 syncer::ModelTypeSet GetPreferredDataTypes() const override; 280 syncer::ModelTypeSet GetPreferredDataTypes() const override;
279 void OnUserChoseDatatypes(bool sync_everything, 281 void OnUserChoseDatatypes(bool sync_everything,
280 syncer::ModelTypeSet chosen_types) override; 282 syncer::ModelTypeSet chosen_types) override;
281 void SetFirstSetupComplete() override; 283 void SetFirstSetupComplete() override;
282 bool IsFirstSetupInProgress() const override; 284 bool IsFirstSetupInProgress() const override;
283 void SetSetupInProgress(bool setup_in_progress) override; 285 std::unique_ptr<sync_driver::SyncSetupInProgressHandle>
286 GetSetupInProgressHandle() override;
284 bool IsSetupInProgress() const override; 287 bool IsSetupInProgress() const override;
285 bool ConfigurationDone() const override; 288 bool ConfigurationDone() const override;
286 const GoogleServiceAuthError& GetAuthError() const override; 289 const GoogleServiceAuthError& GetAuthError() const override;
287 bool HasUnrecoverableError() const override; 290 bool HasUnrecoverableError() const override;
288 bool IsBackendInitialized() const override; 291 bool IsBackendInitialized() const override;
289 sync_driver::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override; 292 sync_driver::OpenTabsUIDelegate* GetOpenTabsUIDelegate() override;
290 bool IsPassphraseRequiredForDecryption() const override; 293 bool IsPassphraseRequiredForDecryption() const override;
291 base::Time GetExplicitPassphraseTime() const override; 294 base::Time GetExplicitPassphraseTime() const override;
292 bool IsUsingSecondaryPassphrase() const override; 295 bool IsUsingSecondaryPassphrase() const override;
293 void EnableEncryptEverything() override; 296 void EnableEncryptEverything() override;
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 798
796 // Calls sync backend to send ClearServerDataMessage to server. 799 // Calls sync backend to send ClearServerDataMessage to server.
797 void ClearAndRestartSyncForPassphraseEncryption(); 800 void ClearAndRestartSyncForPassphraseEncryption();
798 801
799 // Restarts sync clearing directory in the process. 802 // Restarts sync clearing directory in the process.
800 void OnClearServerDataDone(); 803 void OnClearServerDataDone();
801 804
802 // True if setup has been completed at least once and is not in progress. 805 // True if setup has been completed at least once and is not in progress.
803 bool CanConfigureDataTypes() const; 806 bool CanConfigureDataTypes() const;
804 807
808 // Called when a SetupInProgressHandle issued by this instance is destroyed.
809 virtual void OnSetupInProgressHandleDestroyed();
810
805 // This profile's SyncClient, which abstracts away non-Sync dependencies and 811 // This profile's SyncClient, which abstracts away non-Sync dependencies and
806 // the Sync API component factory. 812 // the Sync API component factory.
807 std::unique_ptr<sync_driver::SyncClient> sync_client_; 813 std::unique_ptr<sync_driver::SyncClient> sync_client_;
808 814
809 // The class that handles getting, setting, and persisting sync 815 // The class that handles getting, setting, and persisting sync
810 // preferences. 816 // preferences.
811 sync_driver::SyncPrefs sync_prefs_; 817 sync_driver::SyncPrefs sync_prefs_;
812 818
813 // TODO(ncarter): Put this in a profile, once there is UI for it. 819 // TODO(ncarter): Put this in a profile, once there is UI for it.
814 // This specifies where to find the sync server. 820 // This specifies where to find the sync server.
(...skipping 22 matching lines...) Expand all
837 843
838 // Threading context. 844 // Threading context.
839 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; 845 scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
840 scoped_refptr<base::SingleThreadTaskRunner> file_thread_; 846 scoped_refptr<base::SingleThreadTaskRunner> file_thread_;
841 base::SequencedWorkerPool* blocking_pool_; 847 base::SequencedWorkerPool* blocking_pool_;
842 848
843 // Indicates if this is the first time sync is being configured. This value 849 // Indicates if this is the first time sync is being configured. This value
844 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized(). 850 // is equal to !IsFirstSetupComplete() at the time of OnBackendInitialized().
845 bool is_first_time_sync_configure_; 851 bool is_first_time_sync_configure_;
846 852
853 // Number of UIs currently configuring the Sync service. When this number
854 // is decremented back to zero, Sync setup in marked no longer in progress.
Nicolas Zea 2016/06/13 20:01:00 nit: "in marked" -> "is marked"
tommycli 2016/06/13 20:27:31 Done.
855 int outstanding_setup_in_progress_handles_ = 0;
856
847 // List of available data type controllers. 857 // List of available data type controllers.
848 sync_driver::DataTypeController::TypeMap data_type_controllers_; 858 sync_driver::DataTypeController::TypeMap data_type_controllers_;
849 859
850 // Whether the SyncBackendHost has been initialized. 860 // Whether the SyncBackendHost has been initialized.
851 bool backend_initialized_; 861 bool backend_initialized_;
852 862
853 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents 863 // Set when sync receives DISABLED_BY_ADMIN error from server. Prevents
854 // ProfileSyncService from starting backend till browser restarted or user 864 // ProfileSyncService from starting backend till browser restarted or user
855 // signed out. 865 // signed out.
856 bool sync_disabled_by_admin_; 866 bool sync_disabled_by_admin_;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_; 1030 base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_;
1021 1031
1022 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); 1032 DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
1023 }; 1033 };
1024 1034
1025 bool ShouldShowActionOnUI( 1035 bool ShouldShowActionOnUI(
1026 const syncer::SyncProtocolError& error); 1036 const syncer::SyncProtocolError& error);
1027 1037
1028 1038
1029 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_ 1039 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698