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

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

Issue 285403002: Push API: define push event on Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Avoid modifying modules/serviceworkers/. Created 6 years, 7 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 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"
47 #include "public/web/WebServiceWorkerPushEventCallback.h"
46 #include "web/WebEmbeddedWorkerImpl.h" 48 #include "web/WebEmbeddedWorkerImpl.h"
47 #include "wtf/Functional.h" 49 #include "wtf/Functional.h"
48 #include "wtf/PassOwnPtr.h" 50 #include "wtf/PassOwnPtr.h"
49 51
50 using namespace WebCore; 52 using namespace WebCore;
51 53
52 namespace blink { 54 namespace blink {
53 55
54 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, ExecutionContext& executionContext, WebSe rviceWorkerContextClient& client) 56 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, ExecutionContext& executionContext, WebSe rviceWorkerContextClient& client)
55 { 57 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue)); 97 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue));
96 } 98 }
97 99
98 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) 100 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID)
99 { 101 {
100 ASSERT(m_workerGlobalScope); 102 ASSERT(m_workerGlobalScope);
101 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); 103 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync));
102 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID); 104 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID);
103 } 105 }
104 106
107 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data, const WebServiceWorkerPushEventCallback& callback)
108 {
109 ASSERT(m_workerGlobalScope);
110 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata));
111 callback.didHandlePushEvent(eventID);
112 }
113
105 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) 114 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
106 { 115 {
107 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); 116 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL);
108 } 117 }
109 118
110 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(MessageSource source, M essageLevel level, const String& message, int lineNumber, const String& sourceUR L) 119 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(MessageSource source, M essageLevel level, const String& message, int lineNumber, const String& sourceUR L)
111 { 120 {
112 m_client.reportConsoleMessage(source, level, message, lineNumber, sourceURL) ; 121 m_client.reportConsoleMessage(source, level, message, lineNumber, sourceURL) ;
113 } 122 }
114 123
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 156
148 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client) 157 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client)
149 : m_embeddedWorker(embeddedWorker) 158 : m_embeddedWorker(embeddedWorker)
150 , m_executionContext(executionContext) 159 , m_executionContext(executionContext)
151 , m_client(client) 160 , m_client(client)
152 , m_workerGlobalScope(0) 161 , m_workerGlobalScope(0)
153 { 162 {
154 } 163 }
155 164
156 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698