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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "modules/navigatorconnect/WorkerNavigatorServices.h" | 49 #include "modules/navigatorconnect/WorkerNavigatorServices.h" |
50 #include "modules/notifications/Notification.h" | 50 #include "modules/notifications/Notification.h" |
51 #include "modules/notifications/NotificationEvent.h" | 51 #include "modules/notifications/NotificationEvent.h" |
52 #include "modules/notifications/NotificationEventInit.h" | 52 #include "modules/notifications/NotificationEventInit.h" |
53 #include "modules/push_messaging/PushEvent.h" | 53 #include "modules/push_messaging/PushEvent.h" |
54 #include "modules/push_messaging/PushMessageData.h" | 54 #include "modules/push_messaging/PushMessageData.h" |
55 #include "modules/serviceworkers/ExtendableEvent.h" | 55 #include "modules/serviceworkers/ExtendableEvent.h" |
56 #include "modules/serviceworkers/ExtendableMessageEvent.h" | 56 #include "modules/serviceworkers/ExtendableMessageEvent.h" |
57 #include "modules/serviceworkers/FetchEvent.h" | 57 #include "modules/serviceworkers/FetchEvent.h" |
58 #include "modules/serviceworkers/InstallEvent.h" | 58 #include "modules/serviceworkers/InstallEvent.h" |
| 59 #include "modules/serviceworkers/ServiceWorkerClient.h" |
59 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" | 60 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" |
| 61 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
60 #include "modules/serviceworkers/WaitUntilObserver.h" | 62 #include "modules/serviceworkers/WaitUntilObserver.h" |
61 #include "platform/RuntimeEnabledFeatures.h" | 63 #include "platform/RuntimeEnabledFeatures.h" |
62 #include "public/platform/WebCrossOriginServiceWorkerClient.h" | 64 #include "public/platform/WebCrossOriginServiceWorkerClient.h" |
63 #include "public/platform/modules/background_sync/WebSyncRegistration.h" | 65 #include "public/platform/modules/background_sync/WebSyncRegistration.h" |
64 #include "public/platform/modules/notifications/WebNotificationData.h" | 66 #include "public/platform/modules/notifications/WebNotificationData.h" |
65 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" | 67 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" |
66 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" | 68 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" |
67 #include "public/web/WebSerializedScriptValue.h" | 69 #include "public/web/WebSerializedScriptValue.h" |
68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" | 70 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" |
69 #include "web/WebEmbeddedWorkerImpl.h" | 71 #include "web/WebEmbeddedWorkerImpl.h" |
(...skipping 25 matching lines...) Expand all Loading... |
95 workerGlobalScope()->setRegistration(handle); | 97 workerGlobalScope()->setRegistration(handle); |
96 } | 98 } |
97 | 99 |
98 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) | 100 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) |
99 { | 101 { |
100 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(),
WaitUntilObserver::Activate, eventID); | 102 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(),
WaitUntilObserver::Activate, eventID); |
101 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti
vate, ExtendableEventInit(), observer)); | 103 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti
vate, ExtendableEventInit(), observer)); |
102 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | 104 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
103 } | 105 } |
104 | 106 |
105 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID,
const WebString& message, const WebMessagePortChannelArray& webChannels) | 107 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID,
const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag
ePortChannelArray& webChannels, const WebServiceWorkerClientInfo& client) |
106 { | 108 { |
107 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled())
; | 109 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled())
; |
108 | 110 |
109 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag
e); | 111 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag
e); |
110 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop
e, webChannels); | 112 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop
e, webChannels); |
111 // TODO(nhiroki): Support |origin| and |source| attributes. | 113 String origin; |
112 // (http://crbug.com/543198) | 114 if (!sourceOrigin.isUnique()) |
113 | 115 origin = sourceOrigin.toString(); |
| 116 ServiceWorkerClient* source = nullptr; |
| 117 if (client.clientType == WebServiceWorkerClientTypeWindow) |
| 118 source = ServiceWorkerWindowClient::create(client); |
| 119 else |
| 120 source = ServiceWorkerClient::create(client); |
114 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(),
WaitUntilObserver::Message, eventID); | 121 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(),
WaitUntilObserver::Message, eventID); |
115 | 122 |
116 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, String
(), ports, observer)); | 123 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin
, ports, source, observer)); |
117 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | 124 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
118 } | 125 } |
119 | 126 |
| 127 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID,
const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag
ePortChannelArray& webChannels, WebPassOwnPtr<WebServiceWorker::Handle> handle) |
| 128 { |
| 129 ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled())
; |
| 130 |
| 131 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag
e); |
| 132 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop
e, webChannels); |
| 133 String origin; |
| 134 if (!sourceOrigin.isUnique()) |
| 135 origin = sourceOrigin.toString(); |
| 136 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio
nContext(), handle.release()); |
| 137 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(),
WaitUntilObserver::Message, eventID); |
| 138 |
| 139 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin
, ports, source, observer)); |
| 140 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 141 } |
| 142 |
120 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer
viceWorkerRequest& webRequest) | 143 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer
viceWorkerRequest& webRequest) |
121 { | 144 { |
122 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); | 145 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::fetch); |
123 } | 146 } |
124 | 147 |
125 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const
WebServiceWorkerRequest& webRequest) | 148 void ServiceWorkerGlobalScopeProxy::dispatchForeignFetchEvent(int eventID, const
WebServiceWorkerRequest& webRequest) |
126 { | 149 { |
127 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch); | 150 dispatchFetchEventImpl(eventID, webRequest, EventTypeNames::foreignfetch); |
128 } | 151 } |
129 | 152 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 eventInit.setCancelable(true); | 325 eventInit.setCancelable(true); |
303 eventInit.setRequest(request); | 326 eventInit.setRequest(request); |
304 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq
uest.clientId()); | 327 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq
uest.clientId()); |
305 eventInit.setIsReload(webRequest.isReload()); | 328 eventInit.setIsReload(webRequest.isReload()); |
306 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName,
eventInit, observer)); | 329 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName,
eventInit, observer)); |
307 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc
hEvent.release()); | 330 DispatchEventResult dispatchResult = workerGlobalScope()->dispatchEvent(fetc
hEvent.release()); |
308 observer->didDispatchEvent(dispatchResult); | 331 observer->didDispatchEvent(dispatchResult); |
309 } | 332 } |
310 | 333 |
311 } // namespace blink | 334 } // namespace blink |
OLD | NEW |