Chromium Code Reviews| 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); |