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

Unified Diff: content/browser/background_sync/background_sync_service_impl.cc

Issue 1344843003: [BackgroundSync] Add browser side support for SyncRegistration.done (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ncn_max
Patch Set: Address comments from PS7 Created 5 years, 3 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: content/browser/background_sync/background_sync_service_impl.cc
diff --git a/content/browser/background_sync/background_sync_service_impl.cc b/content/browser/background_sync/background_sync_service_impl.cc
index 9f51f9a70af6ed03f9c631e5fbb0f07cba7ad88a..b8c03df798b7abba2e6f0ab90a4d0c8964c1e5c6 100644
--- a/content/browser/background_sync/background_sync_service_impl.cc
+++ b/content/browser/background_sync/background_sync_service_impl.cc
@@ -227,6 +227,23 @@ void BackgroundSyncServiceImpl::ReleaseRegistration(
active_handles_.Remove(handle_id);
}
+void BackgroundSyncServiceImpl::NotifyWhenDone(
+ BackgroundSyncRegistrationHandle::HandleId handle_id,
+ const NotifyWhenDoneCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ BackgroundSyncRegistrationHandle* registration =
+ active_handles_.Lookup(handle_id);
+ if (!registration) {
+ callback.Run(BACKGROUND_SYNC_ERROR_NOT_ALLOWED,
+ BACKGROUND_SYNC_STATE_FAILED);
+ return;
+ }
+
+ registration->NotifyWhenDone(
+ base::Bind(&BackgroundSyncServiceImpl::OnNotifyWhenDoneResult,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+}
+
void BackgroundSyncServiceImpl::OnRegisterResult(
const RegisterCallback& callback,
BackgroundSyncStatus status,
@@ -271,4 +288,12 @@ void BackgroundSyncServiceImpl::OnGetRegistrationsResult(
mojo_registrations.Pass());
}
+void BackgroundSyncServiceImpl::OnNotifyWhenDoneResult(
+ const NotifyWhenDoneCallback& callback,
+ BackgroundSyncStatus status,
+ BackgroundSyncState sync_state) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ callback.Run(static_cast<content::BackgroundSyncError>(status), sync_state);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698