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

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

Issue 1210633002: Update navigator.services API to use the new services.onconnect event [1/3]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@serviceport-part3
Patch Set: rebase 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 28 matching lines...) Expand all
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/fetch/Headers.h" 43 #include "modules/fetch/Headers.h"
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/navigatorconnect/ServicePortCollection.h"
50 #include "modules/navigatorconnect/WorkerNavigatorServices.h"
49 #include "modules/notifications/Notification.h" 51 #include "modules/notifications/Notification.h"
50 #include "modules/notifications/NotificationEvent.h" 52 #include "modules/notifications/NotificationEvent.h"
51 #include "modules/push_messaging/PushEvent.h" 53 #include "modules/push_messaging/PushEvent.h"
52 #include "modules/push_messaging/PushMessageData.h" 54 #include "modules/push_messaging/PushMessageData.h"
53 #include "modules/serviceworkers/ExtendableEvent.h" 55 #include "modules/serviceworkers/ExtendableEvent.h"
54 #include "modules/serviceworkers/FetchEvent.h" 56 #include "modules/serviceworkers/FetchEvent.h"
55 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 57 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
56 #include "modules/serviceworkers/StashedMessagePort.h" 58 #include "modules/serviceworkers/StashedMessagePort.h"
57 #include "modules/serviceworkers/StashedPortCollection.h" 59 #include "modules/serviceworkers/StashedPortCollection.h"
58 #include "modules/serviceworkers/WaitUntilObserver.h" 60 #include "modules/serviceworkers/WaitUntilObserver.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 145 }
144 146
145 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 147 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
146 { 148 {
147 ASSERT(m_workerGlobalScope); 149 ASSERT(m_workerGlobalScope);
148 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID); 150 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID);
149 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); 151 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer));
150 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 152 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
151 } 153 }
152 154
155 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID)
156 {
157 ASSERT(m_workerGlobalScope);
158 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s);
159 ServicePortCollection* collection = WorkerNavigatorServices::services(m_work erGlobalScope, *m_workerGlobalScope->navigator());
160 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por tID);
161 }
162
153 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) 163 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
154 { 164 {
155 ASSERT(m_workerGlobalScope); 165 ASSERT(m_workerGlobalScope);
156 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { 166 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) {
157 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted); 167 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted);
158 return; 168 return;
159 } 169 }
160 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID); 170 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID);
161 // TODO(chasej) - Send registration as in crbug.com/482066 171 // TODO(chasej) - Send registration as in crbug.com/482066
162 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null ptr /* registration */, observer)); 172 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null ptr /* registration */, observer));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 245
236 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 246 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
237 : m_embeddedWorker(embeddedWorker) 247 : m_embeddedWorker(embeddedWorker)
238 , m_document(document) 248 , m_document(document)
239 , m_client(client) 249 , m_client(client)
240 , m_workerGlobalScope(0) 250 , m_workerGlobalScope(0)
241 { 251 {
242 } 252 }
243 253
244 } // namespace blink 254 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | public/platform/modules/navigator_services/WebServicePortCallbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698