| 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 21 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync
Event(eventID, WebServiceWorkerEventResultCompleted); |
| 168 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven
t(eventID); | 169 return; |
| 170 } |
| 171 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Sync, eventID); |
| 172 // TODO(chasej) - Send registration as in crbug.com/482066 |
| 173 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null
ptr /* registration */, observer)); |
| 174 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); |
| 169 } | 175 } |
| 170 | 176 |
| 171 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID,
const WebCrossOriginServiceWorkerClient& webClient) | 177 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID,
const WebCrossOriginServiceWorkerClient& webClient) |
| 172 { | 178 { |
| 173 ASSERT(m_workerGlobalScope); | 179 ASSERT(m_workerGlobalScope); |
| 174 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work
erGlobalScope, eventID); | 180 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work
erGlobalScope, eventID); |
| 175 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre
ate(webClient); | 181 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre
ate(webClient); |
| 176 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer,
client)); | 182 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer,
client)); |
| 177 observer->didDispatchEvent(); | 183 observer->didDispatchEvent(); |
| 178 } | 184 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 246 |
| 241 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) | 247 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) |
| 242 : m_embeddedWorker(embeddedWorker) | 248 : m_embeddedWorker(embeddedWorker) |
| 243 , m_document(document) | 249 , m_document(document) |
| 244 , m_client(client) | 250 , m_client(client) |
| 245 , m_workerGlobalScope(0) | 251 , m_workerGlobalScope(0) |
| 246 { | 252 { |
| 247 } | 253 } |
| 248 | 254 |
| 249 } // namespace blink | 255 } // namespace blink |
| OLD | NEW |