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

Unified Diff: third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp

Issue 2762663002: BackgroundFetchRegistration.abort() should return a Promise. (Closed)
Patch Set: Created 3 years, 9 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: third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp
diff --git a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp
index b5ed2d0963c5fe4398dcb62928ec19d45d3caae8..3350cd57ce2b589a602f85d5595a9e19210a92ec 100644
--- a/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp
+++ b/third_party/WebKit/Source/modules/background_fetch/BackgroundFetchRegistration.cpp
@@ -4,6 +4,7 @@
#include "modules/background_fetch/BackgroundFetchRegistration.h"
+#include "bindings/core/v8/ScriptState.h"
#include "modules/background_fetch/BackgroundFetchBridge.h"
#include "modules/background_fetch/IconDefinition.h"
#include "modules/serviceworkers/ServiceWorkerRegistration.h"
@@ -40,8 +41,33 @@ String BackgroundFetchRegistration::title() const {
return m_title;
}
-void BackgroundFetchRegistration::abort() {
- BackgroundFetchBridge::from(m_registration)->abort(m_tag);
+ScriptPromise BackgroundFetchRegistration::abort(ScriptState* scriptState) {
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+
+ BackgroundFetchBridge::from(m_registration)
+ ->abort(m_tag, WTF::bind(&BackgroundFetchRegistration::didAbort,
+ wrapPersistent(this), wrapPersistent(resolver)));
+
+ return promise;
+}
+
+void BackgroundFetchRegistration::didAbort(
+ ScriptPromiseResolver* resolver,
+ mojom::blink::BackgroundFetchError error) {
+ switch (error) {
+ case mojom::blink::BackgroundFetchError::NONE:
+ resolver->resolve(true /* success */);
+ return;
+ case mojom::blink::BackgroundFetchError::INVALID_TAG:
+ resolver->resolve(false /* success */);
+ return;
+ case mojom::blink::BackgroundFetchError::DUPLICATED_TAG:
+ // Not applicable for this callback.
+ break;
+ }
+
+ NOTREACHED();
}
DEFINE_TRACE(BackgroundFetchRegistration) {

Powered by Google App Engine
This is Rietveld 408576698