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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 270303004: Revert of Add blink-side plumbing for ServiceWorker -> Document postMessage (1/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 #include "config.h" 30 #include "config.h"
31 #include "modules/serviceworkers/ServiceWorkerContainer.h" 31 #include "modules/serviceworkers/ServiceWorkerContainer.h"
32 32
33 #include "RuntimeEnabledFeatures.h" 33 #include "RuntimeEnabledFeatures.h"
34 #include "bindings/v8/CallbackPromiseAdapter.h" 34 #include "bindings/v8/CallbackPromiseAdapter.h"
35 #include "bindings/v8/ScriptPromiseResolverWithContext.h" 35 #include "bindings/v8/ScriptPromiseResolverWithContext.h"
36 #include "bindings/v8/ScriptState.h" 36 #include "bindings/v8/ScriptState.h"
37 #include "bindings/v8/SerializedScriptValue.h"
38 #include "core/dom/DOMException.h" 37 #include "core/dom/DOMException.h"
39 #include "core/dom/Document.h"
40 #include "core/dom/ExceptionCode.h" 38 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/ExecutionContext.h" 39 #include "core/dom/ExecutionContext.h"
42 #include "core/dom/MessagePort.h"
43 #include "core/events/MessageEvent.h"
44 #include "modules/serviceworkers/RegistrationOptionList.h" 40 #include "modules/serviceworkers/RegistrationOptionList.h"
45 #include "modules/serviceworkers/ServiceWorker.h" 41 #include "modules/serviceworkers/ServiceWorker.h"
46 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 42 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
47 #include "modules/serviceworkers/ServiceWorkerError.h" 43 #include "modules/serviceworkers/ServiceWorkerError.h"
48 #include "public/platform/WebServiceWorker.h" 44 #include "public/platform/WebServiceWorker.h"
49 #include "public/platform/WebServiceWorkerProvider.h" 45 #include "public/platform/WebServiceWorkerProvider.h"
50 #include "public/platform/WebString.h" 46 #include "public/platform/WebString.h"
51 #include "public/platform/WebURL.h" 47 #include "public/platform/WebURL.h"
52 #include "v8.h" 48 #include "v8.h"
53 49
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return promise; 133 return promise;
138 } 134 }
139 135
140 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se rviceWorker) 136 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se rviceWorker)
141 { 137 {
142 if (!executionContext()) 138 if (!executionContext())
143 return; 139 return;
144 m_current = ServiceWorker::create(executionContext(), adoptPtr(serviceWorker )); 140 m_current = ServiceWorker::create(executionContext(), adoptPtr(serviceWorker ));
145 } 141 }
146 142
147 void ServiceWorkerContainer::dispatchMessageEvent(const blink::WebString& messag e, const blink::WebMessagePortChannelArray& webChannels)
148 {
149 if (!executionContext() || !window())
150 return;
151
152 OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(executionCo ntext(), webChannels);
153 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire( message);
154 window()->dispatchEvent(MessageEvent::create(ports.release(), value));
155 }
156
157 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) 143 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t)
158 : ContextLifecycleObserver(executionContext) 144 : ContextLifecycleObserver(executionContext)
159 , DOMWindowLifecycleObserver(executionContext->isDocument() ? toDocument(exe cutionContext)->domWindow() : 0)
160 , m_provider(0) 145 , m_provider(0)
161 { 146 {
162 ScriptWrappable::init(this); 147 ScriptWrappable::init(this);
163 148
164 if (!executionContext) 149 if (!executionContext)
165 return; 150 return;
166 151
167 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 152 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
168 m_provider = client->provider(); 153 m_provider = client->provider();
169 if (m_provider) 154 if (m_provider)
170 m_provider->setClient(this); 155 m_provider->setClient(this);
171 } 156 }
172 } 157 }
173 158
174 } // namespace WebCore 159 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | Source/web/FrameLoaderClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698