| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 44 #include "modules/geofencing/CircularGeofencingRegion.h" | 44 #include "modules/geofencing/CircularGeofencingRegion.h" | 
| 45 #include "modules/geofencing/GeofencingEvent.h" | 45 #include "modules/geofencing/GeofencingEvent.h" | 
| 46 #include "modules/notifications/Notification.h" | 46 #include "modules/notifications/Notification.h" | 
| 47 #include "modules/notifications/NotificationEvent.h" | 47 #include "modules/notifications/NotificationEvent.h" | 
| 48 #include "modules/notifications/NotificationEventInit.h" | 48 #include "modules/notifications/NotificationEventInit.h" | 
| 49 #include "modules/push_messaging/PushEvent.h" | 49 #include "modules/push_messaging/PushEvent.h" | 
| 50 #include "modules/push_messaging/PushMessageData.h" | 50 #include "modules/push_messaging/PushMessageData.h" | 
| 51 #include "modules/serviceworkers/ExtendableEvent.h" | 51 #include "modules/serviceworkers/ExtendableEvent.h" | 
| 52 #include "modules/serviceworkers/ExtendableMessageEvent.h" | 52 #include "modules/serviceworkers/ExtendableMessageEvent.h" | 
| 53 #include "modules/serviceworkers/FetchEvent.h" | 53 #include "modules/serviceworkers/FetchEvent.h" | 
|  | 54 #include "modules/serviceworkers/ForeignFetchEvent.h" | 
| 54 #include "modules/serviceworkers/InstallEvent.h" | 55 #include "modules/serviceworkers/InstallEvent.h" | 
| 55 #include "modules/serviceworkers/ServiceWorkerClient.h" | 56 #include "modules/serviceworkers/ServiceWorkerClient.h" | 
| 56 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" | 57 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" | 
| 57 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 58 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" | 
| 58 #include "modules/serviceworkers/WaitUntilObserver.h" | 59 #include "modules/serviceworkers/WaitUntilObserver.h" | 
| 59 #include "platform/RuntimeEnabledFeatures.h" | 60 #include "platform/RuntimeEnabledFeatures.h" | 
| 60 #include "public/platform/modules/notifications/WebNotificationData.h" | 61 #include "public/platform/modules/notifications/WebNotificationData.h" | 
| 61 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" | 62 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" | 
| 62 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" | 63 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" | 
| 63 #include "public/web/WebSerializedScriptValue.h" | 64 #include "public/web/WebSerializedScriptValue.h" | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 131         origin = sourceOrigin.toString(); | 132         origin = sourceOrigin.toString(); | 
| 132     ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio
     nContext(), adoptPtr(handle.release())); | 133     ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio
     nContext(), adoptPtr(handle.release())); | 
| 133     WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(),
      WaitUntilObserver::Message, eventID); | 134     WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(),
      WaitUntilObserver::Message, eventID); | 
| 134 | 135 | 
| 135     RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou
     rce, observer)); | 136     RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou
     rce, observer)); | 
| 136     workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | 137     workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | 
| 137 } | 138 } | 
| 138 | 139 | 
| 139 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer
     viceWorkerRequest& webRequest) | 140 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer
     viceWorkerRequest& webRequest) | 
| 140 { | 141 { | 
| 141     dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); | 142     RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop
     e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe
     quest.requestContext()); | 
|  | 143     Request* request = Request::create(workerGlobalScope(), webRequest); | 
|  | 144     request->getHeaders()->setGuard(Headers::ImmutableGuard); | 
|  | 145     FetchEventInit eventInit; | 
|  | 146     eventInit.setCancelable(true); | 
|  | 147     eventInit.setRequest(request); | 
|  | 148     eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq
     uest.clientId()); | 
|  | 149     eventInit.setIsReload(webRequest.isReload()); | 
|  | 150     FetchEvent* fetchEvent = FetchEvent::create(EventTypeNames::fetch, eventInit
     , observer); | 
|  | 151     DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc
     hEvent); | 
|  | 152     observer->didDispatchEvent(dispatchResult); | 
| 142 } | 153 } | 
| 143 | 154 | 
| 144 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const
      WebServiceWorkerRequest& webRequest) | 155 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const
      WebServiceWorkerRequest& webRequest) | 
| 145 { | 156 { | 
| 146     dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch); | 157     ForeignFetchRespondWithObserver* observer = ForeignFetchRespondWithObserver:
     :create(workerGlobalScope(), eventID, webRequest.url(), webRequest.mode(), webRe
     quest.frameType(), webRequest.requestContext()); | 
|  | 158     Request* request = Request::create(workerGlobalScope(), webRequest); | 
|  | 159     request->getHeaders()->setGuard(Headers::ImmutableGuard); | 
|  | 160     ForeignFetchEventInit eventInit; | 
|  | 161     eventInit.setCancelable(true); | 
|  | 162     eventInit.setRequest(request); | 
|  | 163     ForeignFetchEvent* fetchEvent = ForeignFetchEvent::create(EventTypeNames::fo
     reignfetch, eventInit, observer); | 
|  | 164     DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc
     hEvent); | 
|  | 165     observer->didDispatchEvent(dispatchResult); | 
| 147 } | 166 } | 
| 148 | 167 | 
| 149 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof
     encingEventType eventType, const WebString& regionID, const WebCircularGeofencin
     gRegion& region) | 168 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof
     encingEventType eventType, const WebString& regionID, const WebCircularGeofencin
     gRegion& region) | 
| 150 { | 169 { | 
| 151     const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT
     ypeNames::geofenceenter : EventTypeNames::geofenceleave; | 170     const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT
     ypeNames::geofenceenter : EventTypeNames::geofenceleave; | 
| 152     workerGlobalScope()->dispatchEvent(GeofencingEvent::create(type, regionID, C
     ircularGeofencingRegion::create(regionID, region))); | 171     workerGlobalScope()->dispatchEvent(GeofencingEvent::create(type, regionID, C
     ircularGeofencingRegion::create(regionID, region))); | 
| 153 } | 172 } | 
| 154 | 173 | 
| 155 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) | 174 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) | 
| 156 { | 175 { | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 288     DCHECK(m_document); | 307     DCHECK(m_document); | 
| 289     return *m_document; | 308     return *m_document; | 
| 290 } | 309 } | 
| 291 | 310 | 
| 292 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con
     st | 311 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con
     st | 
| 293 { | 312 { | 
| 294     DCHECK(m_workerGlobalScope); | 313     DCHECK(m_workerGlobalScope); | 
| 295     return m_workerGlobalScope; | 314     return m_workerGlobalScope; | 
| 296 } | 315 } | 
| 297 | 316 | 
| 298 void ServiceWorkerGlobalScopeProxy::dispatchFetchEventImpl(int eventID, const We
     bServiceWorkerRequest& webRequest, const AtomicString& eventTypeName) |  | 
| 299 { |  | 
| 300     RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop
     e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe
     quest.requestContext()); |  | 
| 301     Request* request = Request::create(workerGlobalScope(), webRequest); |  | 
| 302     request->getHeaders()->setGuard(Headers::ImmutableGuard); |  | 
| 303     FetchEventInit eventInit; |  | 
| 304     eventInit.setCancelable(true); |  | 
| 305     eventInit.setRequest(request); |  | 
| 306     eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq
     uest.clientId()); |  | 
| 307     eventInit.setIsReload(webRequest.isReload()); |  | 
| 308     RawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, o
     bserver)); |  | 
| 309     DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc
     hEvent.release()); |  | 
| 310     observer->didDispatchEvent(dispatchResult); |  | 
| 311 } |  | 
| 312 |  | 
| 313 } // namespace blink | 317 } // namespace blink | 
| OLD | NEW | 
|---|