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

Unified Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 2748213003: Service Worker event dispatcher for Background Fetch (Closed)
Patch Set: uma fix 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/web/ServiceWorkerGlobalScopeProxy.cpp
diff --git a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
index b64b6fc17ba2567fc04caada969023b1df37e358..6dc2da9690376baceb3ab95f746eb523f61b4212 100644
--- a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
+++ b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
@@ -42,6 +42,10 @@
#include "core/workers/ParentFrameTaskRunners.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerThread.h"
+#include "modules/background_fetch/BackgroundFetchClickEvent.h"
+#include "modules/background_fetch/BackgroundFetchClickEventInit.h"
+#include "modules/background_fetch/BackgroundFetchEvent.h"
+#include "modules/background_fetch/BackgroundFetchEventInit.h"
#include "modules/background_sync/SyncEvent.h"
#include "modules/fetch/Headers.h"
#include "modules/notifications/Notification.h"
@@ -98,6 +102,49 @@ void ServiceWorkerGlobalScopeProxy::setRegistration(
workerGlobalScope()->setRegistration(std::move(handle));
}
+void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchAbortEvent(
+ int eventID,
+ const WebString& tag) {
+ WaitUntilObserver* observer = WaitUntilObserver::create(
+ workerGlobalScope(), WaitUntilObserver::BackgroundFetchAbort, eventID);
+
+ BackgroundFetchClickEventInit init;
+ init.setTag(tag);
+
+ BackgroundFetchEvent* event = BackgroundFetchEvent::create(
+ EventTypeNames::backgroundfetchabort, init, observer);
+
+ workerGlobalScope()->dispatchExtendableEvent(event, observer);
+}
+
+void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchClickEvent(
+ int eventID,
+ const WebString& tag,
+ BackgroundFetchState status) {
+ WaitUntilObserver* observer = WaitUntilObserver::create(
+ workerGlobalScope(), WaitUntilObserver::BackgroundFetchClick, eventID);
+
+ BackgroundFetchClickEventInit init;
+ init.setTag(tag);
+
+ switch (status) {
+ case BackgroundFetchState::Pending:
+ init.setState("pending");
+ break;
+ case BackgroundFetchState::Succeeded:
+ init.setState("succeeded");
+ break;
+ case BackgroundFetchState::Failed:
+ init.setState("failed");
+ break;
+ }
+
+ BackgroundFetchClickEvent* event = BackgroundFetchClickEvent::create(
+ EventTypeNames::backgroundfetchclick, init, observer);
+
+ workerGlobalScope()->dispatchExtendableEvent(event, observer);
+}
+
void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) {
WaitUntilObserver* observer = WaitUntilObserver::create(
workerGlobalScope(), WaitUntilObserver::Activate, eventID);

Powered by Google App Engine
This is Rietveld 408576698