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

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

Issue 1156703003: ServiceWorker: Introduce ExtendableMessageEvent to replace MessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update Created 5 years, 5 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
« no previous file with comments | « Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | public/web/WebServiceWorkerContextClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/navigatorconnect/AcceptConnectionObserver.h" 46 #include "modules/navigatorconnect/AcceptConnectionObserver.h"
47 #include "modules/navigatorconnect/CrossOriginConnectEvent.h" 47 #include "modules/navigatorconnect/CrossOriginConnectEvent.h"
48 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h" 48 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h"
49 #include "modules/notifications/Notification.h" 49 #include "modules/notifications/Notification.h"
50 #include "modules/notifications/NotificationEvent.h" 50 #include "modules/notifications/NotificationEvent.h"
51 #include "modules/push_messaging/PushEvent.h" 51 #include "modules/push_messaging/PushEvent.h"
52 #include "modules/push_messaging/PushMessageData.h" 52 #include "modules/push_messaging/PushMessageData.h"
53 #include "modules/serviceworkers/ExtendableEvent.h" 53 #include "modules/serviceworkers/ExtendableEvent.h"
54 #include "modules/serviceworkers/ExtendableMessageEvent.h"
54 #include "modules/serviceworkers/FetchEvent.h" 55 #include "modules/serviceworkers/FetchEvent.h"
56 #include "modules/serviceworkers/ServiceWorker.h"
55 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 57 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
58 #include "modules/serviceworkers/ServiceWorkerWindowClient.h"
56 #include "modules/serviceworkers/StashedMessagePort.h" 59 #include "modules/serviceworkers/StashedMessagePort.h"
57 #include "modules/serviceworkers/StashedPortCollection.h" 60 #include "modules/serviceworkers/StashedPortCollection.h"
58 #include "modules/serviceworkers/WaitUntilObserver.h" 61 #include "modules/serviceworkers/WaitUntilObserver.h"
59 #include "platform/RuntimeEnabledFeatures.h" 62 #include "platform/RuntimeEnabledFeatures.h"
60 #include "public/platform/WebCrossOriginServiceWorkerClient.h" 63 #include "public/platform/WebCrossOriginServiceWorkerClient.h"
61 #include "public/platform/WebServiceWorkerEventResult.h" 64 #include "public/platform/WebServiceWorkerEventResult.h"
62 #include "public/platform/WebServiceWorkerRequest.h" 65 #include "public/platform/WebServiceWorkerRequest.h"
63 #include "public/platform/modules/notifications/WebNotificationData.h" 66 #include "public/platform/modules/notifications/WebNotificationData.h"
64 #include "public/web/WebSerializedScriptValue.h" 67 #include "public/web/WebSerializedScriptValue.h"
65 #include "public/web/WebServiceWorkerContextClient.h" 68 #include "public/web/WebServiceWorkerContextClient.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 124 }
122 125
123 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) 126 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID)
124 { 127 {
125 ASSERT(m_workerGlobalScope); 128 ASSERT(m_workerGlobalScope);
126 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Install, eventID); 129 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Install, eventID);
127 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::inst all, ExtendableEventInit(), observer)); 130 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::inst all, ExtendableEventInit(), observer));
128 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 131 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
129 } 132 }
130 133
131 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels) 134 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(int eventID, const WebS erviceWorkerClientInfo& info, const WebString& message, const WebMessagePortChan nelArray& webChannels)
132 { 135 {
133 ASSERT(m_workerGlobalScope); 136 ASSERT(m_workerGlobalScope);
134 137 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Message, eventID);
135 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (m_workerGlobalScope, webChannels); 138 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (m_workerGlobalScope, webChannels);
136 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 139 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
137 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue)); 140 ServiceWorkerClient* source = ServiceWorkerWindowClient::create(info);
141 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(ports.release (), value, source, observer));
142 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
143 }
144
145 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(int eventID, WebService Worker* serviceWorker, const WebString& message, const WebMessagePortChannelArra y& webChannels)
146 {
147 ASSERT(m_workerGlobalScope);
148 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Message, eventID);
149 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (m_workerGlobalScope, webChannels);
150 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
151 RefPtrWillBeRawPtr<ServiceWorker> source = ServiceWorker::from(m_workerGloba lScope->executionContext(), serviceWorker);
152 RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(ports.release (), value, source.release(), observer));
153 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
138 } 154 }
139 155
140 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data) 156 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data)
141 { 157 {
142 ASSERT(m_workerGlobalScope); 158 ASSERT(m_workerGlobalScope);
143 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::NotificationClick, eventID); 159 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::NotificationClick, eventID);
144 NotificationEventInit eventInit; 160 NotificationEventInit eventInit;
145 eventInit.setNotification(Notification::create(m_workerGlobalScope, notifica tionID, data)); 161 eventInit.setNotification(Notification::create(m_workerGlobalScope, notifica tionID, data));
146 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); 162 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer));
147 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 163 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 256
241 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 257 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
242 : m_embeddedWorker(embeddedWorker) 258 : m_embeddedWorker(embeddedWorker)
243 , m_document(document) 259 , m_document(document)
244 , m_client(client) 260 , m_client(client)
245 , m_workerGlobalScope(0) 261 , m_workerGlobalScope(0)
246 { 262 {
247 } 263 }
248 264
249 } // namespace blink 265 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | public/web/WebServiceWorkerContextClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698