OLD | NEW |
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 22 matching lines...) Expand all Loading... |
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/background_sync/SyncEvent.h" |
| 43 #include "modules/background_sync/SyncRegistration.h" |
43 #include "modules/fetch/Headers.h" | 44 #include "modules/fetch/Headers.h" |
44 #include "modules/geofencing/CircularGeofencingRegion.h" | 45 #include "modules/geofencing/CircularGeofencingRegion.h" |
45 #include "modules/geofencing/GeofencingEvent.h" | 46 #include "modules/geofencing/GeofencingEvent.h" |
46 #include "modules/navigatorconnect/AcceptConnectionObserver.h" | 47 #include "modules/navigatorconnect/AcceptConnectionObserver.h" |
47 #include "modules/navigatorconnect/CrossOriginConnectEvent.h" | 48 #include "modules/navigatorconnect/CrossOriginConnectEvent.h" |
48 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h" | 49 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h" |
49 #include "modules/navigatorconnect/ServicePortCollection.h" | 50 #include "modules/navigatorconnect/ServicePortCollection.h" |
50 #include "modules/navigatorconnect/WorkerNavigatorServices.h" | 51 #include "modules/navigatorconnect/WorkerNavigatorServices.h" |
51 #include "modules/notifications/Notification.h" | 52 #include "modules/notifications/Notification.h" |
52 #include "modules/notifications/NotificationEvent.h" | 53 #include "modules/notifications/NotificationEvent.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 154 } |
154 | 155 |
155 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo
rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString&
origin, WebServicePortID portID) | 156 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo
rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString&
origin, WebServicePortID portID) |
156 { | 157 { |
157 ASSERT(m_workerGlobalScope); | 158 ASSERT(m_workerGlobalScope); |
158 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback
s); | 159 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback
s); |
159 ServicePortCollection* collection = WorkerNavigatorServices::services(m_work
erGlobalScope, *m_workerGlobalScope->navigator()); | 160 ServicePortCollection* collection = WorkerNavigatorServices::services(m_work
erGlobalScope, *m_workerGlobalScope->navigator()); |
160 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por
tID); | 161 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por
tID); |
161 } | 162 } |
162 | 163 |
| 164 // TODO(iclelland): Remove this method in favor of the two-parameter version |
| 165 // below, once all call sites have been updated. |
163 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) | 166 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) |
164 { | 167 { |
165 ASSERT(m_workerGlobalScope); | 168 ASSERT(m_workerGlobalScope); |
166 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { | 169 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { |
167 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync
Event(eventID, WebServiceWorkerEventResultCompleted); | 170 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync
Event(eventID, WebServiceWorkerEventResultCompleted); |
168 return; | 171 return; |
169 } | 172 } |
170 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Sync, eventID); | 173 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Sync, eventID); |
171 // TODO(chasej) - Send registration as in crbug.com/482066 | 174 // TODO(chasej) - Send registration as in crbug.com/482066 |
172 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null
ptr /* registration */, observer)); | 175 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null
ptr /* registration */, observer)); |
173 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | 176 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); |
174 } | 177 } |
175 | 178 |
| 179 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID, const WebSync
Registration& registration) |
| 180 { |
| 181 ASSERT(m_workerGlobalScope); |
| 182 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { |
| 183 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync
Event(eventID, WebServiceWorkerEventResultCompleted); |
| 184 return; |
| 185 } |
| 186 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Sync, eventID); |
| 187 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, Sync
Registration::create(registration, m_workerGlobalScope->registration()), observe
r)); |
| 188 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); |
| 189 } |
| 190 |
176 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID,
const WebCrossOriginServiceWorkerClient& webClient) | 191 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID,
const WebCrossOriginServiceWorkerClient& webClient) |
177 { | 192 { |
178 ASSERT(m_workerGlobalScope); | 193 ASSERT(m_workerGlobalScope); |
179 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work
erGlobalScope, eventID); | 194 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work
erGlobalScope, eventID); |
180 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre
ate(webClient); | 195 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre
ate(webClient); |
181 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer,
client)); | 196 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer,
client)); |
182 observer->didDispatchEvent(); | 197 observer->didDispatchEvent(); |
183 } | 198 } |
184 | 199 |
185 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro
ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa
gePortChannelArray& webChannels) | 200 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro
ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa
gePortChannelArray& webChannels) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 260 |
246 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) | 261 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) |
247 : m_embeddedWorker(embeddedWorker) | 262 : m_embeddedWorker(embeddedWorker) |
248 , m_document(document) | 263 , m_document(document) |
249 , m_client(client) | 264 , m_client(client) |
250 , m_workerGlobalScope(0) | 265 , m_workerGlobalScope(0) |
251 { | 266 { |
252 } | 267 } |
253 | 268 |
254 } // namespace blink | 269 } // namespace blink |
OLD | NEW |