Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 1877283002: ServiceWorker: Remove unused MessageEvent implementation from ServiceWorkerGlobalScope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "web/ServiceWorkerGlobalScopeProxy.h" 31 #include "web/ServiceWorkerGlobalScopeProxy.h"
32 32
33 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 33 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
34 #include "core/dom/CrossThreadTask.h" 34 #include "core/dom/CrossThreadTask.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/ExecutionContext.h" 36 #include "core/dom/ExecutionContext.h"
37 #include "core/dom/MessagePort.h" 37 #include "core/dom/MessagePort.h"
38 #include "core/events/MessageEvent.h"
39 #include "core/inspector/ConsoleMessage.h" 38 #include "core/inspector/ConsoleMessage.h"
40 #include "core/workers/WorkerGlobalScope.h" 39 #include "core/workers/WorkerGlobalScope.h"
41 #include "core/workers/WorkerThread.h" 40 #include "core/workers/WorkerThread.h"
42 #include "modules/background_sync/SyncEvent.h" 41 #include "modules/background_sync/SyncEvent.h"
43 #include "modules/fetch/Headers.h" 42 #include "modules/fetch/Headers.h"
44 #include "modules/geofencing/CircularGeofencingRegion.h" 43 #include "modules/geofencing/CircularGeofencingRegion.h"
45 #include "modules/geofencing/GeofencingEvent.h" 44 #include "modules/geofencing/GeofencingEvent.h"
46 #include "modules/notifications/Notification.h" 45 #include "modules/notifications/Notification.h"
47 #include "modules/notifications/NotificationEvent.h" 46 #include "modules/notifications/NotificationEvent.h"
48 #include "modules/notifications/NotificationEventInit.h" 47 #include "modules/notifications/NotificationEventInit.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 95
97 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) 96 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID)
98 { 97 {
99 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID); 98 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID);
100 Event* event = ExtendableEvent::create(EventTypeNames::activate, ExtendableE ventInit(), observer); 99 Event* event = ExtendableEvent::create(EventTypeNames::activate, ExtendableE ventInit(), observer);
101 workerGlobalScope()->dispatchExtendableEvent(event, observer); 100 workerGlobalScope()->dispatchExtendableEvent(event, observer);
102 } 101 }
103 102
104 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, const WebServiceWorkerClientInfo& client) 103 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, const WebServiceWorkerClientInfo& client)
105 { 104 {
106 DCHECK(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
107
108 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 105 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
109 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); 106 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
110 String origin; 107 String origin;
111 if (!sourceOrigin.isUnique()) 108 if (!sourceOrigin.isUnique())
112 origin = sourceOrigin.toString(); 109 origin = sourceOrigin.toString();
113 ServiceWorkerClient* source = nullptr; 110 ServiceWorkerClient* source = nullptr;
114 if (client.clientType == WebServiceWorkerClientTypeWindow) 111 if (client.clientType == WebServiceWorkerClientTypeWindow)
115 source = ServiceWorkerWindowClient::create(client); 112 source = ServiceWorkerWindowClient::create(client);
116 else 113 else
117 source = ServiceWorkerClient::create(client); 114 source = ServiceWorkerClient::create(client);
118 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); 115 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
119 116
120 Event* event = ExtendableMessageEvent::create(value, origin, ports, source, observer); 117 Event* event = ExtendableMessageEvent::create(value, origin, ports, source, observer);
121 workerGlobalScope()->dispatchExtendableEvent(event, observer); 118 workerGlobalScope()->dispatchExtendableEvent(event, observer);
122 } 119 }
123 120
124 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, std::unique_ptr<WebServiceWorker::Handle> handle ) 121 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessag ePortChannelArray& webChannels, std::unique_ptr<WebServiceWorker::Handle> handle )
125 { 122 {
126 DCHECK(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled()) ;
127
128 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 123 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
129 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); 124 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
130 String origin; 125 String origin;
131 if (!sourceOrigin.isUnique()) 126 if (!sourceOrigin.isUnique())
132 origin = sourceOrigin.toString(); 127 origin = sourceOrigin.toString();
133 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio nContext(), adoptPtr(handle.release())); 128 ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutio nContext(), adoptPtr(handle.release()));
134 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID); 129 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
135 130
136 Event* event = ExtendableMessageEvent::create(value, origin, ports, source, observer); 131 Event* event = ExtendableMessageEvent::create(value, origin, ports, source, observer);
137 workerGlobalScope()->dispatchExtendableEvent(event, observer); 132 workerGlobalScope()->dispatchExtendableEvent(event, observer);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 { 170 {
176 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID); 171 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID);
177 Event* event; 172 Event* event;
178 if (RuntimeEnabledFeatures::foreignFetchEnabled()) 173 if (RuntimeEnabledFeatures::foreignFetchEnabled())
179 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer); 174 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer);
180 else 175 else
181 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer); 176 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer);
182 workerGlobalScope()->dispatchExtendableEvent(event, observer); 177 workerGlobalScope()->dispatchExtendableEvent(event, observer);
183 } 178 }
184 179
185 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels)
186 {
187 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels);
188 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
189 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value));
190 }
191
192 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) 180 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex)
193 { 181 {
194 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID); 182 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID);
195 NotificationEventInit eventInit; 183 NotificationEventInit eventInit;
196 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, true /* showing */)); 184 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, true /* showing */));
197 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) 185 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size()))
198 eventInit.setAction(data.actions[actionIndex].action); 186 eventInit.setAction(data.actions[actionIndex].action);
199 Event* event = NotificationEvent::create(EventTypeNames::notificationclick, eventInit, observer); 187 Event* event = NotificationEvent::create(EventTypeNames::notificationclick, eventInit, observer);
200 workerGlobalScope()->dispatchExtendableEvent(event, observer); 188 workerGlobalScope()->dispatchExtendableEvent(event, observer);
201 } 189 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return *m_document; 296 return *m_document;
309 } 297 }
310 298
311 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st 299 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st
312 { 300 {
313 DCHECK(m_workerGlobalScope); 301 DCHECK(m_workerGlobalScope);
314 return m_workerGlobalScope; 302 return m_workerGlobalScope;
315 } 303 }
316 304
317 } // namespace blink 305 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | third_party/WebKit/Source/web/WebRuntimeFeatures.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698