Commit 378cb1f7 authored by johnme@chromium.org's avatar johnme@chromium.org

Allow Blink to respond asynchronously to SW Push events (side 2/3)

This will be necessary once Push events support event.waitUntil to keep the
Service Worker alive until the Promise is resolved
(https://github.com/w3c/push-api/issues/85).

Depends on Chromium https://codereview.chromium.org/708913003
Required by Chromium https://codereview.chromium.org/707243003

BUG=430888, 401438

Review URL: https://codereview.chromium.org/709103002

git-svn-id: svn://svn.chromium.org/blink/trunk@185008 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c8c5b977
......@@ -63,6 +63,7 @@ public:
// provided by the service worker in the fetch events, so fallback to native.
virtual void didHandleFetchEvent(int fetchEventID) = 0;
virtual void didHandleFetchEvent(int fetchEventID, const WebServiceWorkerResponse&) = 0;
virtual void didHandlePushEvent(int pushEventID, WebServiceWorkerEventResult) = 0;
virtual void didHandleSyncEvent(int syncEventID) = 0;
virtual void postMessageToClient(int clientID, const WebString& message, PassOwnPtr<WebMessagePortChannelArray>) = 0;
......
......@@ -83,6 +83,11 @@ void ServiceWorkerGlobalScopeClientImpl::didHandleFetchEvent(int fetchEventID, c
m_client.didHandleFetchEvent(fetchEventID, webResponse);
}
void ServiceWorkerGlobalScopeClientImpl::didHandlePushEvent(int pushEventID, WebServiceWorkerEventResult result)
{
m_client.didHandlePushEvent(pushEventID, result);
}
void ServiceWorkerGlobalScopeClientImpl::didHandleSyncEvent(int syncEventID)
{
m_client.didHandleSyncEvent(syncEventID);
......
......@@ -55,6 +55,7 @@ public:
virtual void didHandleInstallEvent(int installEventID, WebServiceWorkerEventResult) override;
virtual void didHandleFetchEvent(int fetchEventID) override;
virtual void didHandleFetchEvent(int fetchEventID, const WebServiceWorkerResponse&) override;
virtual void didHandlePushEvent(int pushEventID, WebServiceWorkerEventResult) override;
virtual void didHandleSyncEvent(int syncEventID) override;
virtual void postMessageToClient(int clientID, const WebString& message, PassOwnPtr<WebMessagePortChannelArray>) override;
......
......@@ -48,6 +48,7 @@
#include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
#include "modules/serviceworkers/WaitUntilObserver.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "public/platform/WebServiceWorkerEventResult.h"
#include "public/platform/WebServiceWorkerRequest.h"
#include "public/web/WebSerializedScriptValue.h"
#include "public/web/WebServiceWorkerContextClient.h"
......@@ -118,6 +119,10 @@ void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri
{
ASSERT(m_workerGlobalScope);
m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, data));
// TODO(mvanouwerkerk): Instead of calling didHandlePushEvent here, it
// should get called from WaitUntilObserver::decrementPendingActivity once
// the push event is hooked up to event.waitUntil (crbug.com/430888).
ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandlePushEvent(eventID, WebServiceWorkerEventResultCompleted);
}
void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
......
......@@ -122,6 +122,11 @@ public:
virtual void didHandleFetchEvent(int fetchEventID) { }
virtual void didHandleFetchEvent(int fetchEventID, const WebServiceWorkerResponse& response) { }
// ServiceWorker specific method. Called after PushEvent (dispatched via
// WebServiceWorkerContextProxy) is handled by the ServiceWorker's script
// context.
virtual void didHandlePushEvent(int pushEventID, WebServiceWorkerEventResult result) { }
// ServiceWorker specific method. Called after SyncEvent (dispatched via
// WebServiceWorkerContextProxy) is handled by the ServiceWorker's script
// context.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment