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

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

Issue 720873002: Expose the notificationclick and notificationerror events on ServiceWorkerGlobalScope (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 23 matching lines...) Expand all
34 #include "bindings/core/v8/WorkerScriptController.h" 34 #include "bindings/core/v8/WorkerScriptController.h"
35 #include "core/dom/CrossThreadTask.h" 35 #include "core/dom/CrossThreadTask.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/ExecutionContext.h" 37 #include "core/dom/ExecutionContext.h"
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/geofencing/CircularGeofencingRegion.h" 42 #include "modules/geofencing/CircularGeofencingRegion.h"
43 #include "modules/geofencing/GeofencingEvent.h" 43 #include "modules/geofencing/GeofencingEvent.h"
44 #include "modules/notifications/NotificationEvent.h"
44 #include "modules/push_messaging/PushEvent.h" 45 #include "modules/push_messaging/PushEvent.h"
45 #include "modules/serviceworkers/ExtendableEvent.h" 46 #include "modules/serviceworkers/ExtendableEvent.h"
46 #include "modules/serviceworkers/FetchEvent.h" 47 #include "modules/serviceworkers/FetchEvent.h"
47 #include "modules/serviceworkers/InstallEvent.h" 48 #include "modules/serviceworkers/InstallEvent.h"
48 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 49 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
49 #include "modules/serviceworkers/WaitUntilObserver.h" 50 #include "modules/serviceworkers/WaitUntilObserver.h"
50 #include "platform/RuntimeEnabledFeatures.h" 51 #include "platform/RuntimeEnabledFeatures.h"
52 #include "public/platform/WebNotificationData.h"
51 #include "public/platform/WebServiceWorkerEventResult.h" 53 #include "public/platform/WebServiceWorkerEventResult.h"
52 #include "public/platform/WebServiceWorkerRequest.h" 54 #include "public/platform/WebServiceWorkerRequest.h"
53 #include "public/web/WebSerializedScriptValue.h" 55 #include "public/web/WebSerializedScriptValue.h"
54 #include "public/web/WebServiceWorkerContextClient.h" 56 #include "public/web/WebServiceWorkerContextClient.h"
55 #include "web/WebEmbeddedWorkerImpl.h" 57 #include "web/WebEmbeddedWorkerImpl.h"
56 #include "wtf/Functional.h" 58 #include "wtf/Functional.h"
57 #include "wtf/PassOwnPtr.h" 59 #include "wtf/PassOwnPtr.h"
58 60
59 namespace blink { 61 namespace blink {
60 62
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 120 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
119 { 121 {
120 ASSERT(m_workerGlobalScope); 122 ASSERT(m_workerGlobalScope);
121 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata)); 123 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata));
122 // TODO(mvanouwerkerk): Instead of calling didHandlePushEvent here, it 124 // TODO(mvanouwerkerk): Instead of calling didHandlePushEvent here, it
123 // should get called from WaitUntilObserver::decrementPendingActivity once 125 // should get called from WaitUntilObserver::decrementPendingActivity once
124 // the push event is hooked up to event.waitUntil (crbug.com/430888). 126 // the push event is hooked up to event.waitUntil (crbug.com/430888).
125 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandlePushEven t(eventID, WebServiceWorkerEventResultCompleted); 127 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandlePushEven t(eventID, WebServiceWorkerEventResultCompleted);
126 } 128 }
127 129
130 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, const WebNotificationData& data)
131 {
132 ASSERT(m_workerGlobalScope);
133 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::NotificationClick, eventID);
134 // FIXME: Initialize a Notification object based on |data|.
135 NotificationEventInit eventInit;
136 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer));
137 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
138 }
139
140 void ServiceWorkerGlobalScopeProxy::dispatchNotificationErrorEvent(int eventID, const WebNotificationData& data)
141 {
142 ASSERT(m_workerGlobalScope);
143 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::NotificationError, eventID);
144 // FIXME: Initialize a Notification object based on |data|.
145 NotificationEventInit eventInit;
146 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationerror, eventInit, observer));
147 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
148 }
149
128 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) 150 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
129 { 151 {
130 ASSERT(m_workerGlobalScope); 152 ASSERT(m_workerGlobalScope);
131 if (RuntimeEnabledFeatures::backgroundSyncEnabled()) 153 if (RuntimeEnabledFeatures::backgroundSyncEnabled())
132 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); 154 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync));
133 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID); 155 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID);
134 } 156 }
135 157
136 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) 158 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
137 { 159 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 200
179 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 201 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
180 : m_embeddedWorker(embeddedWorker) 202 : m_embeddedWorker(embeddedWorker)
181 , m_document(document) 203 , m_document(document)
182 , m_client(client) 204 , m_client(client)
183 , m_workerGlobalScope(0) 205 , m_workerGlobalScope(0)
184 { 206 {
185 } 207 }
186 208
187 } // namespace blink 209 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698