| Index: content/child/background_sync/background_sync_provider.cc
|
| diff --git a/content/child/background_sync/background_sync_provider.cc b/content/child/background_sync/background_sync_provider.cc
|
| index 28ebdf33293d621e8a0f05625a434ab4771342c2..2742016c33430e298c5d811e3db0d02ed24517b2 100644
|
| --- a/content/child/background_sync/background_sync_provider.cc
|
| +++ b/content/child/background_sync/background_sync_provider.cc
|
| @@ -143,6 +143,21 @@ void BackgroundSyncProvider::releaseRegistration(int64_t handle_id) {
|
| GetBackgroundSyncServicePtr()->ReleaseRegistration(handle_id);
|
| }
|
|
|
| +void BackgroundSyncProvider::notifyWhenDone(
|
| + int64_t handle_id,
|
| + blink::WebSyncNotifyWhenDoneCallbacks* callbacks) {
|
| + DCHECK(callbacks);
|
| +
|
| + scoped_ptr<blink::WebSyncNotifyWhenDoneCallbacks> callbacks_ptr(callbacks);
|
| +
|
| + // base::Unretained is safe here, as the mojo channel will be deleted (and
|
| + // will wipe its callbacks) before 'this' is deleted.
|
| + GetBackgroundSyncServicePtr()->NotifyWhenDone(
|
| + handle_id,
|
| + base::Bind(&BackgroundSyncProvider::NotifyWhenDoneCallback,
|
| + base::Unretained(this), base::Passed(callbacks_ptr.Pass())));
|
| +}
|
| +
|
| void BackgroundSyncProvider::DuplicateRegistrationHandle(
|
| int handle_id,
|
| const BackgroundSyncService::DuplicateRegistrationHandleCallback&
|
| @@ -322,6 +337,44 @@ void BackgroundSyncProvider::GetPermissionStatusCallback(
|
| }
|
| }
|
|
|
| +void BackgroundSyncProvider::NotifyWhenDoneCallback(
|
| + scoped_ptr<blink::WebSyncNotifyWhenDoneCallbacks> callbacks,
|
| + BackgroundSyncError error,
|
| + BackgroundSyncState state) {
|
| + switch (error) {
|
| + case BACKGROUND_SYNC_ERROR_NONE:
|
| + switch (state) {
|
| + case BACKGROUND_SYNC_STATE_PENDING:
|
| + case BACKGROUND_SYNC_STATE_FIRING:
|
| + case BACKGROUND_SYNC_STATE_UNREGISTERED_WHILE_FIRING:
|
| + NOTREACHED();
|
| + break;
|
| + case BACKGROUND_SYNC_STATE_SUCCESS:
|
| + callbacks->onSuccess(true);
|
| + break;
|
| + case BACKGROUND_SYNC_STATE_FAILED:
|
| + case BACKGROUND_SYNC_STATE_UNREGISTERED:
|
| + callbacks->onSuccess(false);
|
| + break;
|
| + }
|
| + break;
|
| + case BACKGROUND_SYNC_ERROR_NOT_FOUND:
|
| + case BACKGROUND_SYNC_ERROR_NOT_ALLOWED:
|
| + NOTREACHED();
|
| + break;
|
| + case BACKGROUND_SYNC_ERROR_STORAGE:
|
| + callbacks->onError(
|
| + blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown,
|
| + "Background Sync is disabled."));
|
| + break;
|
| + case BACKGROUND_SYNC_ERROR_NO_SERVICE_WORKER:
|
| + callbacks->onError(
|
| + blink::WebSyncError(blink::WebSyncError::ErrorTypeUnknown,
|
| + "No service worker is active."));
|
| + break;
|
| + }
|
| +}
|
| +
|
| BackgroundSyncServicePtr&
|
| BackgroundSyncProvider::GetBackgroundSyncServicePtr() {
|
| if (!background_sync_service_.get()) {
|
|
|