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

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: fix linking error 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 150 }
149 151
150 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 152 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
151 { 153 {
152 ASSERT(m_workerGlobalScope); 154 ASSERT(m_workerGlobalScope);
153 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID); 155 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID);
154 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); 156 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer));
155 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 157 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
156 } 158 }
157 159
160 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID)
161 {
162 ASSERT(m_workerGlobalScope);
163 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s);
164 ServicePortCollection* collection = WorkerNavigatorServices::services(m_work erGlobalScope, *m_workerGlobalScope->navigator());
165 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por tID);
166 }
167
158 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) 168 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
159 { 169 {
160 ASSERT(m_workerGlobalScope); 170 ASSERT(m_workerGlobalScope);
161 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { 171 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) {
162 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted); 172 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted);
163 return; 173 return;
164 } 174 }
165 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID); 175 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID);
166 // TODO(chasej) - Send registration as in crbug.com/482066 176 // TODO(chasej) - Send registration as in crbug.com/482066
167 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null ptr /* registration */, observer)); 177 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, null ptr /* registration */, observer));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 250
241 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 251 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
242 : m_embeddedWorker(embeddedWorker) 252 : m_embeddedWorker(embeddedWorker)
243 , m_document(document) 253 , m_document(document)
244 , m_client(client) 254 , m_client(client)
245 , m_workerGlobalScope(0) 255 , m_workerGlobalScope(0)
246 { 256 {
247 } 257 }
248 258
249 } // namespace blink 259 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698