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

Side by Side Diff: Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 1148293011: BackgroundSync sync events need to be ExtendableEvents, blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename unused overload to simplify later cleanup Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #include "web/ServiceWorkerGlobalScopeProxy.h" 32 #include "web/ServiceWorkerGlobalScopeProxy.h"
33 33
34 #include "bindings/core/v8/WorkerScriptController.h" 34 #include "bindings/core/v8/WorkerScriptController.h"
35 #include "core/dom/CrossThreadTask.h" 35 #include "core/dom/CrossThreadTask.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/ExecutionContext.h" 37 #include "core/dom/ExecutionContext.h"
38 #include "core/dom/MessagePort.h" 38 #include "core/dom/MessagePort.h"
39 #include "core/events/MessageEvent.h" 39 #include "core/events/MessageEvent.h"
40 #include "core/inspector/ConsoleMessage.h" 40 #include "core/inspector/ConsoleMessage.h"
41 #include "core/workers/WorkerGlobalScope.h" 41 #include "core/workers/WorkerGlobalScope.h"
42 #include "modules/background_sync/SyncEvent.h"
42 #include "modules/fetch/Headers.h" 43 #include "modules/fetch/Headers.h"
43 #include "modules/geofencing/CircularGeofencingRegion.h" 44 #include "modules/geofencing/CircularGeofencingRegion.h"
44 #include "modules/geofencing/GeofencingEvent.h" 45 #include "modules/geofencing/GeofencingEvent.h"
45 #include "modules/navigatorconnect/AcceptConnectionObserver.h" 46 #include "modules/navigatorconnect/AcceptConnectionObserver.h"
46 #include "modules/navigatorconnect/CrossOriginConnectEvent.h" 47 #include "modules/navigatorconnect/CrossOriginConnectEvent.h"
47 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h" 48 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h"
48 #include "modules/notifications/Notification.h" 49 #include "modules/notifications/Notification.h"
49 #include "modules/notifications/NotificationEvent.h" 50 #include "modules/notifications/NotificationEvent.h"
50 #include "modules/push_messaging/PushEvent.h" 51 #include "modules/push_messaging/PushEvent.h"
51 #include "modules/push_messaging/PushMessageData.h" 52 #include "modules/push_messaging/PushMessageData.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 { 157 {
157 ASSERT(m_workerGlobalScope); 158 ASSERT(m_workerGlobalScope);
158 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID); 159 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID);
159 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); 160 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer));
160 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 161 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
161 } 162 }
162 163
163 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) 164 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
164 { 165 {
165 ASSERT(m_workerGlobalScope); 166 ASSERT(m_workerGlobalScope);
166 if (RuntimeEnabledFeatures::backgroundSyncEnabled()) 167 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) {
167 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); 168 // Avoid potential race condition where the feature is disabled after a
168 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID); 169 // sync event has been triggered. The client should be notified that
170 // 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.
171 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted);
172 return;
173 }
174 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID);
175 // TODO(chasej) - Send registration as in crbug.com/482066
176 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null ptr /* registration */, observer));
177 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
169 } 178 }
170 179
171 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID, const WebCrossOriginServiceWorkerClient& webClient) 180 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID, const WebCrossOriginServiceWorkerClient& webClient)
172 { 181 {
173 ASSERT(m_workerGlobalScope); 182 ASSERT(m_workerGlobalScope);
174 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work erGlobalScope, eventID); 183 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work erGlobalScope, eventID);
175 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre ate(webClient); 184 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre ate(webClient);
176 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer, client)); 185 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer, client));
177 observer->didDispatchEvent(); 186 observer->didDispatchEvent();
178 } 187 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 249
241 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 250 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
242 : m_embeddedWorker(embeddedWorker) 251 : m_embeddedWorker(embeddedWorker)
243 , m_document(document) 252 , m_document(document)
244 , m_client(client) 253 , m_client(client)
245 , m_workerGlobalScope(0) 254 , m_workerGlobalScope(0)
246 { 255 {
247 } 256 }
248 257
249 } // namespace blink 258 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/ServiceWorkerGlobalScopeClientImpl.cpp ('k') | public/web/WebServiceWorkerContextClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698