OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/compositorworker/CompositorWorkerThread.h" | 5 #include "modules/compositorworker/CompositorWorkerThread.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
8 #include "bindings/core/v8/SourceLocation.h" | 8 #include "bindings/core/v8/SourceLocation.h" |
9 #include "bindings/core/v8/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
| 10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
10 #include "core/dom/CompositorProxyClient.h" | 11 #include "core/dom/CompositorProxyClient.h" |
11 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
12 #include "core/testing/DummyPageHolder.h" | 13 #include "core/testing/DummyPageHolder.h" |
13 #include "core/workers/InProcessWorkerObjectProxy.h" | 14 #include "core/workers/InProcessWorkerObjectProxy.h" |
14 #include "core/workers/WorkerBackingThread.h" | 15 #include "core/workers/WorkerBackingThread.h" |
15 #include "core/workers/WorkerLoaderProxy.h" | 16 #include "core/workers/WorkerLoaderProxy.h" |
| 17 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
16 #include "core/workers/WorkerThreadStartupData.h" | 18 #include "core/workers/WorkerThreadStartupData.h" |
17 #include "platform/CrossThreadFunctional.h" | 19 #include "platform/CrossThreadFunctional.h" |
18 #include "platform/WaitableEvent.h" | 20 #include "platform/WaitableEvent.h" |
19 #include "platform/WebThreadSupportingGC.h" | 21 #include "platform/WebThreadSupportingGC.h" |
20 #include "platform/heap/Handle.h" | 22 #include "platform/heap/Handle.h" |
21 #include "platform/testing/TestingPlatformSupport.h" | 23 #include "platform/testing/TestingPlatformSupport.h" |
22 #include "platform/testing/UnitTestHelpers.h" | 24 #include "platform/testing/UnitTestHelpers.h" |
23 #include "public/platform/Platform.h" | 25 #include "public/platform/Platform.h" |
24 #include "public/platform/WebAddressSpace.h" | 26 #include "public/platform/WebAddressSpace.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 10 matching lines...) Expand all Loading... |
36 { | 38 { |
37 return wrapUnique(new TestCompositorWorkerObjectProxy(context)); | 39 return wrapUnique(new TestCompositorWorkerObjectProxy(context)); |
38 } | 40 } |
39 | 41 |
40 // (Empty) WorkerReportingProxy implementation: | 42 // (Empty) WorkerReportingProxy implementation: |
41 virtual void reportException(const String& errorMessage, std::unique_ptr<Sou
rceLocation>) {} | 43 virtual void reportException(const String& errorMessage, std::unique_ptr<Sou
rceLocation>) {} |
42 void reportConsoleMessage(ConsoleMessage*) override {} | 44 void reportConsoleMessage(ConsoleMessage*) override {} |
43 void postMessageToPageInspector(const String&) override {} | 45 void postMessageToPageInspector(const String&) override {} |
44 | 46 |
45 void didEvaluateWorkerScript(bool success) override {} | 47 void didEvaluateWorkerScript(bool success) override {} |
46 void workerGlobalScopeStarted(WorkerGlobalScope*) override {} | 48 void workerGlobalScopeStarted(WorkerOrWorkletGlobalScope*) override {} |
47 void workerGlobalScopeClosed() override {} | 49 void workerGlobalScopeClosed() override {} |
48 void workerThreadTerminated() override {} | 50 void workerThreadTerminated() override {} |
49 void willDestroyWorkerGlobalScope() override {} | 51 void willDestroyWorkerGlobalScope() override {} |
50 | 52 |
51 ExecutionContext* getExecutionContext() override { return m_executionContext
.get(); } | 53 ExecutionContext* getExecutionContext() override { return m_executionContext
.get(); } |
52 | 54 |
53 private: | 55 private: |
54 TestCompositorWorkerObjectProxy(ExecutionContext* context) | 56 TestCompositorWorkerObjectProxy(ExecutionContext* context) |
55 : InProcessWorkerObjectProxy(nullptr) | 57 : InProcessWorkerObjectProxy(nullptr) |
56 , m_executionContext(context) | 58 , m_executionContext(context) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 { | 139 { |
138 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); | 140 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); |
139 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, crossThreadU
nretained(this), | 141 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, crossThreadU
nretained(this), |
140 crossThreadUnretained(worker), crossThreadUnretained(waitEvent.get()
))); | 142 crossThreadUnretained(worker), crossThreadUnretained(waitEvent.get()
))); |
141 waitEvent->wait(); | 143 waitEvent->wait(); |
142 } | 144 } |
143 | 145 |
144 private: | 146 private: |
145 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) | 147 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) |
146 { | 148 { |
147 WorkerOrWorkletScriptController* scriptController = worker->workerGlobal
Scope()->scriptController(); | 149 WorkerOrWorkletScriptController* scriptController = worker->globalScope(
)->scriptController(); |
148 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); | 150 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); |
149 ASSERT_UNUSED(evaluateResult, evaluateResult); | 151 ASSERT_UNUSED(evaluateResult, evaluateResult); |
150 waitEvent->signal(); | 152 waitEvent->signal(); |
151 } | 153 } |
152 | 154 |
153 std::unique_ptr<DummyPageHolder> m_page; | 155 std::unique_ptr<DummyPageHolder> m_page; |
154 RefPtr<SecurityOrigin> m_securityOrigin; | 156 RefPtr<SecurityOrigin> m_securityOrigin; |
155 std::unique_ptr<InProcessWorkerObjectProxy> m_objectProxy; | 157 std::unique_ptr<InProcessWorkerObjectProxy> m_objectProxy; |
156 CompositorWorkerTestPlatform m_testPlatform; | 158 CompositorWorkerTestPlatform m_testPlatform; |
157 }; | 159 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 v8::Isolate* secondIsolate = secondWorker->isolate(); | 237 v8::Isolate* secondIsolate = secondWorker->isolate(); |
236 ASSERT_TRUE(secondIsolate); | 238 ASSERT_TRUE(secondIsolate); |
237 EXPECT_EQ(firstIsolate, secondIsolate); | 239 EXPECT_EQ(firstIsolate, secondIsolate); |
238 | 240 |
239 // Verify that the isolate can run some scripts correctly in the second work
er. | 241 // Verify that the isolate can run some scripts correctly in the second work
er. |
240 checkWorkerCanExecuteScript(secondWorker.get()); | 242 checkWorkerCanExecuteScript(secondWorker.get()); |
241 secondWorker->terminateAndWait(); | 243 secondWorker->terminateAndWait(); |
242 } | 244 } |
243 | 245 |
244 } // namespace blink | 246 } // namespace blink |
OLD | NEW |