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 a77aff9b4f36c1e91c23f56fd9de58844003a6af..4250443bda3a8f3eb83834f7bef7b2979bb60c9c 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,53 @@ 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) { |
| + DEFINE_STATIC_LOCAL(const AtomicString, pending, ("pending")); |
|
horo
2017/03/16 07:08:22
We should not use DEFINE_STATIC_LOCAL for AtomicSt
Peter Beverloo
2017/03/16 16:05:58
Removed, thanks
|
| + DEFINE_STATIC_LOCAL(const AtomicString, succeeded, ("succeeded")); |
| + DEFINE_STATIC_LOCAL(const AtomicString, failed, ("failed")); |
| + |
| + 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); |