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 17 matching lines...) Expand all Loading... | |
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 "web/ServiceWorkerGlobalScopeProxy.h" | 32 #include "web/ServiceWorkerGlobalScopeProxy.h" |
33 | 33 |
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/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/dom/MessagePort.h" | 37 #include "core/dom/MessagePort.h" |
38 #include "core/events/ErrorEvent.h" | |
38 #include "core/events/MessageEvent.h" | 39 #include "core/events/MessageEvent.h" |
39 #include "core/workers/WorkerGlobalScope.h" | 40 #include "core/workers/WorkerGlobalScope.h" |
40 #include "modules/push_messaging/PushEvent.h" | 41 #include "modules/push_messaging/PushEvent.h" |
41 #include "modules/serviceworkers/FetchEvent.h" | 42 #include "modules/serviceworkers/FetchEvent.h" |
42 #include "modules/serviceworkers/InstallEvent.h" | 43 #include "modules/serviceworkers/InstallEvent.h" |
43 #include "modules/serviceworkers/InstallPhaseEvent.h" | 44 #include "modules/serviceworkers/InstallPhaseEvent.h" |
44 #include "modules/serviceworkers/WaitUntilObserver.h" | 45 #include "modules/serviceworkers/WaitUntilObserver.h" |
45 #include "platform/NotImplemented.h" | 46 #include "platform/NotImplemented.h" |
46 #include "public/platform/WebServiceWorkerRequest.h" | 47 #include "public/platform/WebServiceWorkerRequest.h" |
47 #include "public/web/WebSerializedScriptValue.h" | 48 #include "public/web/WebSerializedScriptValue.h" |
48 #include "public/web/WebServiceWorkerContextClient.h" | 49 #include "public/web/WebServiceWorkerContextClient.h" |
49 #include "web/WebEmbeddedWorkerImpl.h" | 50 #include "web/WebEmbeddedWorkerImpl.h" |
50 #include "wtf/Functional.h" | 51 #include "wtf/Functional.h" |
51 #include "wtf/PassOwnPtr.h" | 52 #include "wtf/PassOwnPtr.h" |
52 | 53 |
53 using namespace WebCore; | 54 using namespace WebCore; |
54 | 55 |
55 namespace blink { | 56 namespace blink { |
56 | 57 |
57 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, ExecutionContext& executionContext, WebSe rviceWorkerContextClient& client) | 58 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, ExecutionContext& executionContext, WebSe rviceWorkerContextClient& client) |
58 { | 59 { |
59 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, executionC ontext, client)); | 60 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, executionC ontext, client)); |
60 } | 61 } |
61 | 62 |
62 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() | 63 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() |
63 { | 64 { |
64 } | 65 } |
65 | 66 |
67 void ServiceWorkerGlobalScopeProxy::evaluate(const ScriptSourceCode& javascript) | |
Jeffrey Yasskin
2014/07/16 23:14:58
This is used in the test, but doesn't currently ne
| |
68 { | |
69 RefPtrWillBeRawPtr<ErrorEvent> error; | |
70 m_workerGlobalScope->script()->evaluate(javascript, &error); | |
71 if (error) | |
72 m_client.reportException(error->message(), error->lineno(), error->colno (), error->filename()); | |
73 } | |
74 | |
66 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) | 75 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) |
67 { | 76 { |
68 ASSERT(m_workerGlobalScope); | 77 ASSERT(m_workerGlobalScope); |
69 RefPtr<WaitUntilObserver> observer = WaitUntilObserver::create(m_workerGloba lScope, WaitUntilObserver::Install, eventID); | 78 RefPtr<WaitUntilObserver> observer = WaitUntilObserver::create(m_workerGloba lScope, WaitUntilObserver::Install, eventID); |
70 observer->willDispatchEvent(); | 79 observer->willDispatchEvent(); |
71 m_workerGlobalScope->dispatchEvent(InstallEvent::create(EventTypeNames::inst all, EventInit(), observer)); | 80 m_workerGlobalScope->dispatchEvent(InstallEvent::create(EventTypeNames::inst all, EventInit(), observer)); |
72 observer->didDispatchEvent(); | 81 observer->didDispatchEvent(); |
73 } | 82 } |
74 | 83 |
75 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) | 84 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata)); | 116 m_workerGlobalScope->dispatchEvent(PushEvent::create(EventTypeNames::push, d ata)); |
108 } | 117 } |
109 | 118 |
110 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) | 119 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID) |
111 { | 120 { |
112 ASSERT(m_workerGlobalScope); | 121 ASSERT(m_workerGlobalScope); |
113 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); | 122 m_workerGlobalScope->dispatchEvent(Event::create(EventTypeNames::sync)); |
114 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID); | 123 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSyncEven t(eventID); |
115 } | 124 } |
116 | 125 |
126 v8::Handle<v8::Context> ServiceWorkerGlobalScopeProxy::v8Context() | |
127 { | |
128 return m_workerGlobalScope->script()->context(); | |
129 } | |
130 | |
117 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) | 131 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) |
118 { | 132 { |
119 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); | 133 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); |
120 } | 134 } |
121 | 135 |
122 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(MessageSource source, M essageLevel level, const String& message, int lineNumber, const String& sourceUR L) | 136 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(MessageSource source, M essageLevel level, const String& message, int lineNumber, const String& sourceUR L) |
123 { | 137 { |
124 m_client.reportConsoleMessage(source, level, message, lineNumber, sourceURL) ; | 138 m_client.reportConsoleMessage(source, level, message, lineNumber, sourceURL) ; |
125 } | 139 } |
126 | 140 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 | 173 |
160 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client) | 174 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, ExecutionContext& executionContext, WebServiceWorkerContextC lient& client) |
161 : m_embeddedWorker(embeddedWorker) | 175 : m_embeddedWorker(embeddedWorker) |
162 , m_executionContext(executionContext) | 176 , m_executionContext(executionContext) |
163 , m_client(client) | 177 , m_client(client) |
164 , m_workerGlobalScope(0) | 178 , m_workerGlobalScope(0) |
165 { | 179 { |
166 } | 180 } |
167 | 181 |
168 } // namespace blink | 182 } // namespace blink |
OLD | NEW |