summaryrefslogtreecommitdiffstats
path: root/content/browser/background_sync/background_sync_registration.cc
diff options
context:
space:
mode:
authorjkarlin <jkarlin@chromium.org>2015-10-05 14:12:32 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-05 21:13:38 +0000
commit6b4e8f1d827b923e9fb55b038066bdee5bdc953b (patch)
treea1400a6ae602fb6ae1883d6c5320a17bc48fc2b0 /content/browser/background_sync/background_sync_registration.cc
parent110ba3b377b3e294b1a49333945b5732a0635f86 (diff)
downloadchromium_src-6b4e8f1d827b923e9fb55b038066bdee5bdc953b.zip
chromium_src-6b4e8f1d827b923e9fb55b038066bdee5bdc953b.tar.gz
chromium_src-6b4e8f1d827b923e9fb55b038066bdee5bdc953b.tar.bz2
Notify that pending registrations are done when BackgroundSyncManager is disabled.
Registrations that are in the middle of firing when disabling occurs are allowed to complete (so that NotifyWhenDone has the accurate result). BUG=536875 Review URL: https://codereview.chromium.org/1371233002 Cr-Commit-Position: refs/heads/master@{#352425}
Diffstat (limited to 'content/browser/background_sync/background_sync_registration.cc')
-rw-r--r--content/browser/background_sync/background_sync_registration.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/content/browser/background_sync/background_sync_registration.cc b/content/browser/background_sync/background_sync_registration.cc
index 30bbf9e..d3da8e8 100644
--- a/content/browser/background_sync/background_sync_registration.cc
+++ b/content/browser/background_sync/background_sync_registration.cc
@@ -62,4 +62,20 @@ bool BackgroundSyncRegistration::HasCompleted() const {
return false;
}
+void BackgroundSyncRegistration::SetUnregisteredState() {
+ DCHECK(!HasCompleted());
+ bool firing = sync_state_ == BACKGROUND_SYNC_STATE_FIRING ||
+ sync_state_ == BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING;
+
+ sync_state_ = firing ? BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING
+ : BACKGROUND_SYNC_STATE_UNREGISTERED;
+
+ if (!firing) {
+ // If the registration is currently firing then wait to run
+ // RunDoneCallbacks until after it has finished as it might
+ // change state to SUCCESS first.
+ RunDoneCallbacks();
+ }
+}
+
} // namespace content