Chromium Code Reviews| Index: Source/web/ServiceWorkerGlobalScopeProxy.cpp |
| diff --git a/Source/web/ServiceWorkerGlobalScopeProxy.cpp b/Source/web/ServiceWorkerGlobalScopeProxy.cpp |
| index 45e2d0aef78196b72fc78abc671f9b2949ba0714..972357a7bab801c02d33b2ca178b49dd9c211272 100644 |
| --- a/Source/web/ServiceWorkerGlobalScopeProxy.cpp |
| +++ b/Source/web/ServiceWorkerGlobalScopeProxy.cpp |
| @@ -39,6 +39,7 @@ |
| #include "core/events/MessageEvent.h" |
| #include "core/inspector/ConsoleMessage.h" |
| #include "core/workers/WorkerGlobalScope.h" |
| +#include "modules/background_sync/SyncEvent.h" |
| #include "modules/fetch/Headers.h" |
| #include "modules/geofencing/CircularGeofencingRegion.h" |
| #include "modules/geofencing/GeofencingEvent.h" |
| @@ -163,9 +164,17 @@ void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri |
| void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) |
| { |
| ASSERT(m_workerGlobalScope); |
| - if (RuntimeEnabledFeatures::backgroundSyncEnabled()) |
| - m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); |
| - ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEvent(eventID); |
| + if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { |
| + // Avoid potential race condition where the feature is disabled after a |
| + // sync event has been triggered. The client should be notified that |
| + // the event finished to allow for cleanup/handling. |
|
michaeln
2015/06/09 20:42:57
This comment probably isn't needed. Blink generall
chasej
2015/06/10 21:04:59
Done.
|
| + ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEvent(eventID, WebServiceWorkerEventResultCompleted); |
| + return; |
| + } |
| + WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID); |
| + // TODO(chasej) - Send registration as in crbug.com/482066 |
| + RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, nullptr /* registration */, observer)); |
| + m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); |
| } |
| void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID, const WebCrossOriginServiceWorkerClient& webClient) |