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

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

Issue 318413002: Push API: define push event on Service Worker. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | public/web/WebServiceWorkerContextProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "web/ServiceWorkerGlobalScopeProxy.h" 32 #include "web/ServiceWorkerGlobalScopeProxy.h"
33 33
34 #include "bindings/v8/WorkerScriptController.h" 34 #include "bindings/v8/WorkerScriptController.h"
35 #include "core/dom/ExecutionContext.h" 35 #include "core/dom/ExecutionContext.h"
36 #include "core/dom/MessagePort.h" 36 #include "core/dom/MessagePort.h"
37 #include "core/events/MessageEvent.h" 37 #include "core/events/MessageEvent.h"
38 #include "core/workers/WorkerGlobalScope.h" 38 #include "core/workers/WorkerGlobalScope.h"
39 #include "modules/push_messaging/PushEvent.h"
39 #include "modules/serviceworkers/FetchEvent.h" 40 #include "modules/serviceworkers/FetchEvent.h"
40 #include "modules/serviceworkers/InstallEvent.h" 41 #include "modules/serviceworkers/InstallEvent.h"
41 #include "modules/serviceworkers/InstallPhaseEvent.h" 42 #include "modules/serviceworkers/InstallPhaseEvent.h"
42 #include "modules/serviceworkers/WaitUntilObserver.h" 43 #include "modules/serviceworkers/WaitUntilObserver.h"
43 #include "platform/NotImplemented.h" 44 #include "platform/NotImplemented.h"
44 #include "public/web/WebSerializedScriptValue.h" 45 #include "public/web/WebSerializedScriptValue.h"
45 #include "public/web/WebServiceWorkerContextClient.h" 46 #include "public/web/WebServiceWorkerContextClient.h"
46 #include "web/WebEmbeddedWorkerImpl.h" 47 #include "web/WebEmbeddedWorkerImpl.h"
47 #include "wtf/Functional.h" 48 #include "wtf/Functional.h"
48 #include "wtf/PassOwnPtr.h" 49 #include "wtf/PassOwnPtr.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels) 91 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels)
91 { 92 {
92 ASSERT(m_workerGlobalScope); 93 ASSERT(m_workerGlobalScope);
93 94
94 OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(m_workerGlo balScope, webChannels); 95 OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(m_workerGlo balScope, webChannels);
95 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 96 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
96 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue)); 97 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue));
97 } 98 }
98 99
100 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
101 {
102 ASSERT(m_workerGlobalScope);
103 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata));
104 }
105
99 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) 106 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
100 { 107 {
101 ASSERT(m_workerGlobalScope); 108 ASSERT(m_workerGlobalScope);
102 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); 109 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync));
103 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID); 110 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID);
104 } 111 }
105 112
106 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) 113 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
107 { 114 {
108 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); 115 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 155
149 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client) 156 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client)
150 : m_embeddedWorker(embeddedWorker) 157 : m_embeddedWorker(embeddedWorker)
151 , m_executionContext(executionContext) 158 , m_executionContext(executionContext)
152 , m_client(client) 159 , m_client(client)
153 , m_workerGlobalScope(0) 160 , m_workerGlobalScope(0)
154 { 161 {
155 } 162 }
156 163
157 } // namespace blink 164 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | public/web/WebServiceWorkerContextProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698