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/notifications/Notification.h" | 50 #include "modules/notifications/Notification.h" |
50 #include "modules/notifications/NotificationEvent.h" | 51 #include "modules/notifications/NotificationEvent.h" |
51 #include "modules/push_messaging/PushEvent.h" | 52 #include "modules/push_messaging/PushEvent.h" |
52 #include "modules/push_messaging/PushMessageData.h" | 53 #include "modules/push_messaging/PushMessageData.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 149 } |
149 | 150 |
150 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri
ng& data) | 151 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri
ng& data) |
151 { | 152 { |
152 ASSERT(m_workerGlobalScope); | 153 ASSERT(m_workerGlobalScope); |
153 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Push, eventID); | 154 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Push, eventID); |
154 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push
MessageData::create(data), observer)); | 155 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push
MessageData::create(data), observer)); |
155 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | 156 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); |
156 } | 157 } |
157 | 158 |
| 159 // FIXME: Remove this method in favor of the two-parameter version below, once |
| 160 // all call sites have been updated. |
158 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) | 161 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) |
159 { | 162 { |
160 ASSERT(m_workerGlobalScope); | 163 ASSERT(m_workerGlobalScope); |
161 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { | 164 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { |
162 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync
Event(eventID, WebServiceWorkerEventResultCompleted); | 165 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync
Event(eventID, WebServiceWorkerEventResultCompleted); |
163 return; | 166 return; |
164 } | 167 } |
165 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Sync, eventID); | 168 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Sync, eventID); |
166 // TODO(chasej) - Send registration as in crbug.com/482066 | 169 // TODO(chasej) - Send registration as in crbug.com/482066 |
167 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null
ptr /* registration */, observer)); | 170 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null
ptr /* registration */, observer)); |
168 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | 171 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); |
169 } | 172 } |
170 | 173 |
| 174 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID, const WebSync
Registration& registration) |
| 175 { |
| 176 ASSERT(m_workerGlobalScope); |
| 177 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { |
| 178 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync
Event(eventID, WebServiceWorkerEventResultCompleted); |
| 179 return; |
| 180 } |
| 181 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Sync, eventID); |
| 182 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, Sync
Registration::create(registration, m_workerGlobalScope->registration()), observe
r)); |
| 183 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); |
| 184 } |
| 185 |
171 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID,
const WebCrossOriginServiceWorkerClient& webClient) | 186 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID,
const WebCrossOriginServiceWorkerClient& webClient) |
172 { | 187 { |
173 ASSERT(m_workerGlobalScope); | 188 ASSERT(m_workerGlobalScope); |
174 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work
erGlobalScope, eventID); | 189 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work
erGlobalScope, eventID); |
175 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre
ate(webClient); | 190 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre
ate(webClient); |
176 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer,
client)); | 191 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer,
client)); |
177 observer->didDispatchEvent(); | 192 observer->didDispatchEvent(); |
178 } | 193 } |
179 | 194 |
180 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro
ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa
gePortChannelArray& webChannels) | 195 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... |
240 | 255 |
241 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) | 256 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) |
242 : m_embeddedWorker(embeddedWorker) | 257 : m_embeddedWorker(embeddedWorker) |
243 , m_document(document) | 258 , m_document(document) |
244 , m_client(client) | 259 , m_client(client) |
245 , m_workerGlobalScope(0) | 260 , m_workerGlobalScope(0) |
246 { | 261 { |
247 } | 262 } |
248 | 263 |
249 } // namespace blink | 264 } // namespace blink |
OLD | NEW |