Chromium Code Reviews| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 origin = sourceOrigin.toString(); | 130 origin = sourceOrigin.toString(); |
| 130 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio nContext(), handle.release()); | 131 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio nContext(), handle.release()); |
| 131 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); | 132 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); |
| 132 | 133 |
| 133 RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou rce, observer)); | 134 RawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, sou rce, observer)); |
| 134 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | 135 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) | 138 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) |
| 138 { | 139 { |
| 139 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); | 140 RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext()); |
| 141 Request* request = Request::create(workerGlobalScope(), webRequest); | |
| 142 request->getHeaders()->setGuard(Headers::ImmutableGuard); | |
| 143 FetchEventInit eventInit; | |
| 144 eventInit.setCancelable(true); | |
| 145 eventInit.setRequest(request); | |
| 146 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); | |
| 147 eventInit.setIsReload(webRequest.isReload()); | |
| 148 FetchEvent* fetchEvent = FetchEvent::create(EventTypeNames::fetch, eventInit , observer); | |
| 149 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc hEvent); | |
| 150 observer->didDispatchEvent(dispatchResult); | |
| 140 } | 151 } |
| 141 | 152 |
| 142 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest) | 153 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const WebServiceWorkerRequest& webRequest) |
| 143 { | 154 { |
| 144 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch); | 155 ForeignFetchRespondWithObserver* observer = ForeignFetchRespondWithObserver: :create(workerGlobalScope(), eventID, webRequest.url(), webRequest.mode(), webRe quest.frameType(), webRequest.requestContext()); |
| 156 Request* request = Request::create(workerGlobalScope(), webRequest); | |
| 157 request->getHeaders()->setGuard(Headers::ImmutableGuard); | |
| 158 ForeignFetchEventInit eventInit; | |
| 159 eventInit.setCancelable(true); | |
| 160 eventInit.setRequest(request); | |
| 161 ForeignFetchEvent* fetchEvent = ForeignFetchEvent::create(EventTypeNames::fo reignfetch, eventInit, observer); | |
| 162 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc hEvent); | |
| 163 observer->didDispatchEvent(dispatchResult); | |
| 145 } | 164 } |
| 146 | 165 |
| 147 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof encingEventType eventType, const WebString& regionID, const WebCircularGeofencin gRegion& region) | 166 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof encingEventType eventType, const WebString& regionID, const WebCircularGeofencin gRegion& region) |
| 148 { | 167 { |
| 149 const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT ypeNames::geofenceenter : EventTypeNames::geofenceleave; | 168 const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT ypeNames::geofenceenter : EventTypeNames::geofenceleave; |
| 150 workerGlobalScope()->dispatchEvent(GeofencingEvent::create(type, regionID, C ircularGeofencingRegion::create(regionID, region))); | 169 workerGlobalScope()->dispatchEvent(GeofencingEvent::create(type, regionID, C ircularGeofencingRegion::create(regionID, region))); |
| 151 } | 170 } |
| 152 | 171 |
| 153 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) | 172 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) |
| 154 { | 173 { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 DCHECK(m_document); | 305 DCHECK(m_document); |
| 287 return *m_document; | 306 return *m_document; |
| 288 } | 307 } |
| 289 | 308 |
| 290 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st | 309 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st |
| 291 { | 310 { |
| 292 DCHECK(m_workerGlobalScope); | 311 DCHECK(m_workerGlobalScope); |
| 293 return m_workerGlobalScope; | 312 return m_workerGlobalScope; |
| 294 } | 313 } |
| 295 | 314 |
| 296 void ServiceWorkerGlobalScopeProxy::dispatchFetchEventImpl(int eventID, const We bServiceWorkerRequest& webRequest, const AtomicString& eventTypeName) | |
|
Nate Chapin
2016/04/07 20:51:04
I would be inclined to keep the common logic in a
Marijn Kruisselbrink
2016/04/07 21:00:06
Yeah, pretty much the last three lines are the onl
| |
| 297 { | |
| 298 RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext()); | |
| 299 Request* request = Request::create(workerGlobalScope(), webRequest); | |
| 300 request->getHeaders()->setGuard(Headers::ImmutableGuard); | |
| 301 FetchEventInit eventInit; | |
| 302 eventInit.setCancelable(true); | |
| 303 eventInit.setRequest(request); | |
| 304 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); | |
| 305 eventInit.setIsReload(webRequest.isReload()); | |
| 306 RawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, o bserver)); | |
| 307 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc hEvent.release()); | |
| 308 observer->didDispatchEvent(dispatchResult); | |
| 309 } | |
| 310 | |
| 311 } // namespace blink | 315 } // namespace blink |
| OLD | NEW |