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

Unified Diff: components/browser_sync/browser/profile_sync_service.cc

Issue 2044303004: Sync: Support multiple setup UIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename variable 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 side-by-side diff with in-line comments
Download patch
Index: components/browser_sync/browser/profile_sync_service.cc
diff --git a/components/browser_sync/browser/profile_sync_service.cc b/components/browser_sync/browser/profile_sync_service.cc
index 95a951dfedc552f8a56d2297eb16ad4dba80a54d..5f0c8da7319e3d3b01d721f4aeec014651e682a5 100644
--- a/components/browser_sync/browser/profile_sync_service.cc
+++ b/components/browser_sync/browser/profile_sync_service.cc
@@ -1528,15 +1528,19 @@ bool ProfileSyncService::IsFirstSetupInProgress() const {
return !IsFirstSetupComplete() && startup_controller_->IsSetupInProgress();
}
-void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) {
- // This method is a no-op if |setup_in_progress_| remains unchanged.
- if (startup_controller_->IsSetupInProgress() == setup_in_progress)
- return;
+std::unique_ptr<sync_driver::SyncSetupInProgressHandle>
+ProfileSyncService::GetSetupInProgressHandle() {
+ if (++outstanding_setup_in_progress_handles_ == 1) {
+ DCHECK(!startup_controller_->IsSetupInProgress());
+ startup_controller_->SetSetupInProgress(true);
- startup_controller_->SetSetupInProgress(setup_in_progress);
- if (!setup_in_progress && IsBackendInitialized())
- ReconfigureDatatypeManager();
- NotifyObservers();
+ NotifyObservers();
+ }
+
+ return std::unique_ptr<sync_driver::SyncSetupInProgressHandle>(
+ new sync_driver::SyncSetupInProgressHandle(
+ base::Bind(&ProfileSyncService::OnSetupInProgressHandleDestroyed,
+ weak_factory_.GetWeakPtr())));
}
bool ProfileSyncService::IsSyncAllowed() const {
@@ -2544,3 +2548,18 @@ tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
const {
return unrecoverable_error_location_;
}
+
+void ProfileSyncService::OnSetupInProgressHandleDestroyed() {
+ DCHECK_GT(outstanding_setup_in_progress_handles_, 0);
+
+ // Don't re-start Sync until all outstanding handles are destroyed.
+ if (--outstanding_setup_in_progress_handles_ != 0)
+ return;
+
+ DCHECK(startup_controller_->IsSetupInProgress());
+ startup_controller_->SetSetupInProgress(false);
+
+ if (IsBackendInitialized())
+ ReconfigureDatatypeManager();
+ NotifyObservers();
+}

Powered by Google App Engine
This is Rietveld 408576698