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

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

Issue 1205783004: Update navigator.services API to use the new services.onconnect event [3/3]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@serviceport-serviceside
Patch Set: fix webexposed layout test 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
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 27 matching lines...) Expand all
38 #include "core/dom/MessagePort.h" 38 #include "core/dom/MessagePort.h"
39 #include "core/events/MessageEvent.h" 39 #include "core/events/MessageEvent.h"
40 #include "core/inspector/ConsoleMessage.h" 40 #include "core/inspector/ConsoleMessage.h"
41 #include "core/workers/WorkerGlobalScope.h" 41 #include "core/workers/WorkerGlobalScope.h"
42 #include "modules/background_sync/SyncEvent.h" 42 #include "modules/background_sync/SyncEvent.h"
43 #include "modules/background_sync/SyncRegistration.h" 43 #include "modules/background_sync/SyncRegistration.h"
44 #include "modules/fetch/Headers.h" 44 #include "modules/fetch/Headers.h"
45 #include "modules/geofencing/CircularGeofencingRegion.h" 45 #include "modules/geofencing/CircularGeofencingRegion.h"
46 #include "modules/geofencing/GeofencingEvent.h" 46 #include "modules/geofencing/GeofencingEvent.h"
47 #include "modules/navigatorconnect/AcceptConnectionObserver.h" 47 #include "modules/navigatorconnect/AcceptConnectionObserver.h"
48 #include "modules/navigatorconnect/CrossOriginConnectEvent.h"
49 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h" 48 #include "modules/navigatorconnect/CrossOriginServiceWorkerClient.h"
50 #include "modules/navigatorconnect/ServicePortCollection.h" 49 #include "modules/navigatorconnect/ServicePortCollection.h"
51 #include "modules/navigatorconnect/WorkerNavigatorServices.h" 50 #include "modules/navigatorconnect/WorkerNavigatorServices.h"
52 #include "modules/notifications/Notification.h" 51 #include "modules/notifications/Notification.h"
53 #include "modules/notifications/NotificationEvent.h" 52 #include "modules/notifications/NotificationEvent.h"
54 #include "modules/push_messaging/PushEvent.h" 53 #include "modules/push_messaging/PushEvent.h"
55 #include "modules/push_messaging/PushMessageData.h" 54 #include "modules/push_messaging/PushMessageData.h"
56 #include "modules/serviceworkers/ExtendableEvent.h" 55 #include "modules/serviceworkers/ExtendableEvent.h"
57 #include "modules/serviceworkers/FetchEvent.h" 56 #include "modules/serviceworkers/FetchEvent.h"
58 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 57 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 ASSERT(m_workerGlobalScope); 180 ASSERT(m_workerGlobalScope);
182 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { 181 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) {
183 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted); 182 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted);
184 return; 183 return;
185 } 184 }
186 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID); 185 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID);
187 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, Sync Registration::create(registration, m_workerGlobalScope->registration()), observe r)); 186 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, Sync Registration::create(registration, m_workerGlobalScope->registration()), observe r));
188 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 187 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
189 } 188 }
190 189
191 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginConnectEvent(int eventID, const WebCrossOriginServiceWorkerClient& webClient)
192 {
193 ASSERT(m_workerGlobalScope);
194 AcceptConnectionObserver* observer = AcceptConnectionObserver::create(m_work erGlobalScope, eventID);
195 CrossOriginServiceWorkerClient* client = CrossOriginServiceWorkerClient::cre ate(webClient);
196 m_workerGlobalScope->dispatchEvent(CrossOriginConnectEvent::create(observer, client));
197 observer->didDispatchEvent();
198 }
199
200 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa gePortChannelArray& webChannels) 190 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa gePortChannelArray& webChannels)
201 { 191 {
202 ASSERT(m_workerGlobalScope); 192 ASSERT(m_workerGlobalScope);
203 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); 193 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
204 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 194 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
205 // FIXME: Have proper source for this MessageEvent. 195 // FIXME: Have proper source for this MessageEvent.
206 RefPtrWillBeRawPtr<MessageEvent> event = MessageEvent::create(ports, value, webClient.origin.string()); 196 RefPtrWillBeRawPtr<MessageEvent> event = MessageEvent::create(ports, value, webClient.origin.string());
207 event->setType(EventTypeNames::crossoriginmessage); 197 event->setType(EventTypeNames::crossoriginmessage);
208 m_workerGlobalScope->dispatchEvent(event); 198 m_workerGlobalScope->dispatchEvent(event);
209 } 199 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 250
261 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 251 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
262 : m_embeddedWorker(embeddedWorker) 252 : m_embeddedWorker(embeddedWorker)
263 , m_document(document) 253 , m_document(document)
264 , m_client(client) 254 , m_client(client)
265 , m_workerGlobalScope(0) 255 , m_workerGlobalScope(0)
266 { 256 {
267 } 257 }
268 258
269 } // namespace blink 259 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698