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

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

Issue 2767093004: Implement the BackgroundFetch{Fail,ed} Service Worker events (Closed)
Patch Set: add missing uma 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 2b130e66be030703ee5766ac85f774426aa204d3..436acf53fc26fcc43d2fa0fb3a7189f9b979c2c9 100644
--- a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
+++ b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
@@ -46,6 +46,10 @@
#include "modules/background_fetch/BackgroundFetchClickEventInit.h"
#include "modules/background_fetch/BackgroundFetchEvent.h"
#include "modules/background_fetch/BackgroundFetchEventInit.h"
+#include "modules/background_fetch/BackgroundFetchFailEvent.h"
+#include "modules/background_fetch/BackgroundFetchFailEventInit.h"
+#include "modules/background_fetch/BackgroundFetchedEvent.h"
+#include "modules/background_fetch/BackgroundFetchedEventInit.h"
#include "modules/background_sync/SyncEvent.h"
#include "modules/fetch/Headers.h"
#include "modules/notifications/Notification.h"
@@ -145,6 +149,50 @@ void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchClickEvent(
workerGlobalScope()->dispatchExtendableEvent(event, observer);
}
+void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchFailEvent(
+ int eventID,
+ const WebString& tag,
+ const WebVector<WebBackgroundFetchSettledFetch>& fetches) {
+ WaitUntilObserver* observer = WaitUntilObserver::create(
+ workerGlobalScope(), WaitUntilObserver::BackgroundFetchFail, eventID);
+
+ BackgroundFetchFailEventInit init;
+ init.setTag(tag);
+
+ ScriptState::Scope scope(
+ workerGlobalScope()->scriptController()->getScriptState());
+ ScriptState* scriptState =
+ workerGlobalScope()->scriptController()->getScriptState();
kinuko 2017/03/24 03:40:03 nit: you can reverse these lines to make the scope
Peter Beverloo 2017/03/24 14:11:09 Done. Also in dispatchBackgroundFetchedEvent.
+
+ BackgroundFetchFailEvent* event =
+ BackgroundFetchFailEvent::create(EventTypeNames::backgroundfetchfail,
+ init, fetches, scriptState, observer);
+
+ workerGlobalScope()->dispatchExtendableEvent(event, observer);
+}
+
+void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchedEvent(
+ int eventID,
+ const WebString& tag,
+ const WebVector<WebBackgroundFetchSettledFetch>& fetches) {
+ WaitUntilObserver* observer = WaitUntilObserver::create(
+ workerGlobalScope(), WaitUntilObserver::BackgroundFetched, eventID);
+
+ BackgroundFetchedEventInit init;
+ init.setTag(tag);
+
+ ScriptState::Scope scope(
+ workerGlobalScope()->scriptController()->getScriptState());
+ ScriptState* scriptState =
+ workerGlobalScope()->scriptController()->getScriptState();
+
+ BackgroundFetchedEvent* event = BackgroundFetchedEvent::create(
+ EventTypeNames::backgroundfetched, init, fetches, scriptState, observer,
+ m_workerGlobalScope->registration());
+
+ 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