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

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: 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 a41b846d748d38185b63c7bdc93751727ff758ed..66489bf320f0c3c638dfe0beaafb8e445c0454f3 100644
--- a/components/browser_sync/browser/profile_sync_service.cc
+++ b/components/browser_sync/browser/profile_sync_service.cc
@@ -1530,15 +1530,18 @@ 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 &&
+ !startup_controller_->IsSetupInProgress()) {
maxbogue 2016/06/10 17:28:46 You could probably DCHECK the !IsSetupInProgress p
tommycli 2016/06/10 18:58:21 Done. You're right that would really surprise me.
+ startup_controller_->SetSetupInProgress(true);
+ NotifyObservers();
+ }
- startup_controller_->SetSetupInProgress(setup_in_progress);
- if (!setup_in_progress && IsBackendInitialized())
- ReconfigureDatatypeManager();
- 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 +2547,17 @@ tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
const {
return unrecoverable_error_location_;
}
+
+void ProfileSyncService::OnSetupInProgressHandleDestroyed() {
+ // Don't re-start Sync until all outstanding handles are destroyed.
+ if (--outstanding_setup_in_progress_handles_ != 0)
+ return;
+
+ if (!startup_controller_->IsSetupInProgress())
maxbogue 2016/06/10 17:28:46 Same as above, would it make sense to DCHECK inste
tommycli 2016/06/10 18:58:20 Done.
+ return;
+
+ startup_controller_->SetSetupInProgress(false);
+ if (IsBackendInitialized())
+ ReconfigureDatatypeManager();
+ NotifyObservers();
+}

Powered by Google App Engine
This is Rietveld 408576698