OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 11 matching lines...) Expand all Loading... | |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 * | 25 * |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/workers/Worker.h" | 29 #include "core/workers/Worker.h" |
30 | 30 |
31 #include "bindings/core/v8/ExceptionState.h" | 31 #include "bindings/core/v8/ExceptionState.h" |
32 #include "core/dom/CrossThreadTask.h" | |
32 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
33 #include "core/events/MessageEvent.h" | 34 #include "core/events/MessageEvent.h" |
34 #include "core/fetch/ResourceFetcher.h" | 35 #include "core/fetch/ResourceFetcher.h" |
35 #include "core/inspector/InspectorInstrumentation.h" | 36 #include "core/inspector/InspectorInstrumentation.h" |
36 #include "core/frame/LocalDOMWindow.h" | 37 #include "core/frame/LocalDOMWindow.h" |
37 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
39 #include "core/page/Page.h" | |
40 #include "core/workers/WorkerGlobalScope.h" | |
38 #include "core/workers/WorkerGlobalScopeProxy.h" | 41 #include "core/workers/WorkerGlobalScopeProxy.h" |
39 #include "core/workers/WorkerGlobalScopeProxyProvider.h" | 42 #include "core/workers/WorkerGlobalScopeProxyProvider.h" |
40 #include "core/workers/WorkerScriptLoader.h" | 43 #include "core/workers/WorkerScriptLoader.h" |
41 #include "core/workers/WorkerThread.h" | 44 #include "core/workers/WorkerThread.h" |
42 #include "wtf/MainThread.h" | 45 #include "wtf/MainThread.h" |
43 | 46 |
44 namespace blink { | 47 namespace blink { |
45 | 48 |
46 inline Worker::Worker(ExecutionContext* context) | 49 inline Worker::Worker(ExecutionContext* context) |
47 : AbstractWorker(context) | 50 : AbstractWorker(context) |
(...skipping 18 matching lines...) Expand all Loading... | |
66 | 69 |
67 worker->suspendIfNeeded(); | 70 worker->suspendIfNeeded(); |
68 | 71 |
69 KURL scriptURL = worker->resolveURL(url, exceptionState); | 72 KURL scriptURL = worker->resolveURL(url, exceptionState); |
70 if (scriptURL.isEmpty()) | 73 if (scriptURL.isEmpty()) |
71 return nullptr; | 74 return nullptr; |
72 | 75 |
73 worker->m_scriptLoader = WorkerScriptLoader::create(); | 76 worker->m_scriptLoader = WorkerScriptLoader::create(); |
74 worker->m_scriptLoader->loadAsynchronously(*context, scriptURL, DenyCrossOri ginRequests, worker.get()); | 77 worker->m_scriptLoader->loadAsynchronously(*context, scriptURL, DenyCrossOri ginRequests, worker.get()); |
75 worker->m_contextProxy = proxyProvider->createWorkerGlobalScopeProxy(worker. get()); | 78 worker->m_contextProxy = proxyProvider->createWorkerGlobalScopeProxy(worker. get()); |
79 worker->context = context; | |
80 | |
81 | |
76 return worker.release(); | 82 return worker.release(); |
77 } | 83 } |
78 | 84 |
85 | |
79 Worker::~Worker() | 86 Worker::~Worker() |
80 { | 87 { |
81 ASSERT(isMainThread()); | 88 ASSERT(isMainThread()); |
82 if (!m_contextProxy) | 89 if (!m_contextProxy) |
83 return; | 90 return; |
84 ASSERT(executionContext()); // The context is protected by worker context pr oxy, so it cannot be destroyed while a Worker exists. | 91 ASSERT(executionContext()); // The context is protected by worker context pr oxy, so it cannot be destroyed while a Worker exists. |
85 m_contextProxy->workerObjectDestroyed(); | 92 m_contextProxy->workerObjectDestroyed(); |
86 } | 93 } |
87 | 94 |
88 const AtomicString& Worker::interfaceName() const | 95 const AtomicString& Worker::interfaceName() const |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa der->identifier(), m_scriptLoader->script()); | 142 InspectorInstrumentation::scriptImported(executionContext(), m_scriptLoa der->identifier(), m_scriptLoader->script()); |
136 } | 143 } |
137 m_scriptLoader = nullptr; | 144 m_scriptLoader = nullptr; |
138 } | 145 } |
139 | 146 |
140 void Worker::trace(Visitor* visitor) | 147 void Worker::trace(Visitor* visitor) |
141 { | 148 { |
142 AbstractWorker::trace(visitor); | 149 AbstractWorker::trace(visitor); |
143 } | 150 } |
144 | 151 |
152 void Worker::processRAF(double monotonicAnimationStartTime) | |
dstockwell
2014/08/29 01:05:44
RAF -> RequestAnimationFrame
nainar1
2014/08/29 06:01:40
Acknowledged.
| |
153 { | |
154 WorkerMessagingProxy* mp = static_cast<WorkerMessagingProxy*>(m_contextProxy ); | |
155 WorkerGlobalScope* hold = mp->extractWorkerGlobalScope(); | |
156 if (hold) { | |
157 mp->postTaskToWorkerGlobalScope(createCrossThreadTask(&WorkerGlobalScope ::processRAF, AllowCrossThreadAccess(hold), monotonicAnimationStartTime)); | |
158 } | |
159 } | |
160 | |
145 } // namespace blink | 161 } // namespace blink |
OLD | NEW |