OLD | NEW |
---|---|
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 14 matching lines...) Expand all Loading... | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "ServiceWorkerGlobalScopeProxy.h" | 32 #include "ServiceWorkerGlobalScopeProxy.h" |
33 | 33 |
34 #include "WebEmbeddedWorkerImpl.h" | 34 #include "WebEmbeddedWorkerImpl.h" |
35 #include "WebSerializedScriptValue.h" | |
35 #include "WebServiceWorkerContextClient.h" | 36 #include "WebServiceWorkerContextClient.h" |
36 #include "bindings/v8/WorkerScriptController.h" | 37 #include "bindings/v8/WorkerScriptController.h" |
37 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.h" |
39 #include "core/dom/MessagePort.h" | |
40 #include "core/events/MessageEvent.h" | |
38 #include "core/events/ThreadLocalEventNames.h" | 41 #include "core/events/ThreadLocalEventNames.h" |
39 #include "core/workers/WorkerGlobalScope.h" | 42 #include "core/workers/WorkerGlobalScope.h" |
40 #include "modules/serviceworkers/FetchEvent.h" | 43 #include "modules/serviceworkers/FetchEvent.h" |
41 #include "modules/serviceworkers/InstallEvent.h" | 44 #include "modules/serviceworkers/InstallEvent.h" |
42 #include "modules/serviceworkers/WaitUntilObserver.h" | 45 #include "modules/serviceworkers/WaitUntilObserver.h" |
43 #include "platform/NotImplemented.h" | 46 #include "platform/NotImplemented.h" |
44 #include "wtf/Functional.h" | 47 #include "wtf/Functional.h" |
45 #include "wtf/PassOwnPtr.h" | 48 #include "wtf/PassOwnPtr.h" |
46 | 49 |
47 using namespace WebCore; | 50 using namespace WebCore; |
(...skipping 19 matching lines...) Expand all Loading... | |
67 } | 70 } |
68 | 71 |
69 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID) | 72 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID) |
70 { | 73 { |
71 ASSERT(m_workerGlobalScope); | 74 ASSERT(m_workerGlobalScope); |
72 RefPtr<RespondWithObserver> observer = RespondWithObserver::create(m_workerG lobalScope, eventID); | 75 RefPtr<RespondWithObserver> observer = RespondWithObserver::create(m_workerG lobalScope, eventID); |
73 m_workerGlobalScope->dispatchEvent(FetchEvent::create(observer)); | 76 m_workerGlobalScope->dispatchEvent(FetchEvent::create(observer)); |
74 observer->didDispatchEvent(); | 77 observer->didDispatchEvent(); |
75 } | 78 } |
76 | 79 |
80 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels) | |
81 { | |
82 ASSERT(m_workerGlobalScope); | |
83 | |
84 OwnPtr<MessagePortArray> ports; | |
85 if (!webChannels.isEmpty()) { | |
86 OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChann elArray(webChannels.size())); | |
87 for (size_t i = 0; i < webChannels.size(); ++i) | |
adamk
2014/03/19 17:48:58
This loop, too, it would be nice to share, again s
jsbell
2014/03/19 21:06:47
And ditto for this one.
| |
88 (*channels)[i] = adoptPtr(webChannels[i]); | |
89 ports = MessagePort::entanglePorts(*m_workerGlobalScope, channels.releas e()); | |
90 } | |
91 | |
92 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); | |
93 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports.release(), val ue)); | |
94 } | |
95 | |
77 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) | 96 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) |
78 { | 97 { |
79 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); | 98 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); |
80 } | 99 } |
81 | 100 |
82 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(MessageSource, MessageL evel, const String& message, int lineNumber, const String& sourceURL) | 101 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(MessageSource, MessageL evel, const String& message, int lineNumber, const String& sourceURL) |
83 { | 102 { |
84 notImplemented(); | 103 notImplemented(); |
85 } | 104 } |
86 | 105 |
(...skipping 27 matching lines...) Expand all Loading... | |
114 | 133 |
115 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client) | 134 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client) |
116 : m_embeddedWorker(embeddedWorker) | 135 : m_embeddedWorker(embeddedWorker) |
117 , m_executionContext(executionContext) | 136 , m_executionContext(executionContext) |
118 , m_client(client) | 137 , m_client(client) |
119 , m_workerGlobalScope(0) | 138 , m_workerGlobalScope(0) |
120 { | 139 { |
121 } | 140 } |
122 | 141 |
123 } // namespace blink | 142 } // namespace blink |
OLD | NEW |