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

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

Issue 709103002: Allow Blink to respond asynchronously to SW Push events (side 2/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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 30 matching lines...) Expand all
41 #include "core/workers/WorkerGlobalScope.h" 41 #include "core/workers/WorkerGlobalScope.h"
42 #include "modules/geofencing/CircularGeofencingRegion.h" 42 #include "modules/geofencing/CircularGeofencingRegion.h"
43 #include "modules/geofencing/GeofencingEvent.h" 43 #include "modules/geofencing/GeofencingEvent.h"
44 #include "modules/push_messaging/PushEvent.h" 44 #include "modules/push_messaging/PushEvent.h"
45 #include "modules/serviceworkers/ExtendableEvent.h" 45 #include "modules/serviceworkers/ExtendableEvent.h"
46 #include "modules/serviceworkers/FetchEvent.h" 46 #include "modules/serviceworkers/FetchEvent.h"
47 #include "modules/serviceworkers/InstallEvent.h" 47 #include "modules/serviceworkers/InstallEvent.h"
48 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 48 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
49 #include "modules/serviceworkers/WaitUntilObserver.h" 49 #include "modules/serviceworkers/WaitUntilObserver.h"
50 #include "platform/RuntimeEnabledFeatures.h" 50 #include "platform/RuntimeEnabledFeatures.h"
51 #include "public/platform/WebServiceWorkerEventResult.h"
51 #include "public/platform/WebServiceWorkerRequest.h" 52 #include "public/platform/WebServiceWorkerRequest.h"
52 #include "public/web/WebSerializedScriptValue.h" 53 #include "public/web/WebSerializedScriptValue.h"
53 #include "public/web/WebServiceWorkerContextClient.h" 54 #include "public/web/WebServiceWorkerContextClient.h"
54 #include "web/WebEmbeddedWorkerImpl.h" 55 #include "web/WebEmbeddedWorkerImpl.h"
55 #include "wtf/Functional.h" 56 #include "wtf/Functional.h"
56 #include "wtf/PassOwnPtr.h" 57 #include "wtf/PassOwnPtr.h"
57 58
58 namespace blink { 59 namespace blink {
59 60
60 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerConte xtClient& client) 61 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerConte xtClient& client)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (m_workerGlobalScope, webChannels); 113 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (m_workerGlobalScope, webChannels);
113 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 114 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
114 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue)); 115 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue));
115 } 116 }
116 117
117 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 118 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
118 { 119 {
119 ASSERT(m_workerGlobalScope); 120 ASSERT(m_workerGlobalScope);
120 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata)); 121 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata));
122 // TODO(mvanouwerkerk): Instead of calling didHandlePushEvent here, it
123 // should get called from WaitUntilObserver::decrementPendingActivity once
124 // the push event is hooked up to event.waitUntil (crbug.com/430888).
125 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandlePushEven t(eventID, WebServiceWorkerEventResultCompleted);
121 } 126 }
122 127
123 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) 128 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
124 { 129 {
125 ASSERT(m_workerGlobalScope); 130 ASSERT(m_workerGlobalScope);
126 if (RuntimeEnabledFeatures::backgroundSyncEnabled()) 131 if (RuntimeEnabledFeatures::backgroundSyncEnabled())
127 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); 132 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync));
128 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID); 133 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID);
129 } 134 }
130 135
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 178
174 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 179 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
175 : m_embeddedWorker(embeddedWorker) 180 : m_embeddedWorker(embeddedWorker)
176 , m_document(document) 181 , m_document(document)
177 , m_client(client) 182 , m_client(client)
178 , m_workerGlobalScope(0) 183 , m_workerGlobalScope(0)
179 { 184 {
180 } 185 }
181 186
182 } // namespace blink 187 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/ServiceWorkerGlobalScopeClientImpl.cpp ('k') | public/web/WebServiceWorkerContextClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698