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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 { | 138 { |
137 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); | 139 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); |
138 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, crossThreadU
nretained(this), | 140 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, crossThreadU
nretained(this), |
139 crossThreadUnretained(worker), crossThreadUnretained(waitEvent.get()
))); | 141 crossThreadUnretained(worker), crossThreadUnretained(waitEvent.get()
))); |
140 waitEvent->wait(); | 142 waitEvent->wait(); |
141 } | 143 } |
142 | 144 |
143 private: | 145 private: |
144 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) | 146 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) |
145 { | 147 { |
146 WorkerOrWorkletScriptController* scriptController = worker->workerGlobal
Scope()->scriptController(); | 148 WorkerOrWorkletScriptController* scriptController = worker->globalScope(
)->scriptController(); |
147 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); | 149 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); |
148 ASSERT_UNUSED(evaluateResult, evaluateResult); | 150 ASSERT_UNUSED(evaluateResult, evaluateResult); |
149 waitEvent->signal(); | 151 waitEvent->signal(); |
150 } | 152 } |
151 | 153 |
152 std::unique_ptr<DummyPageHolder> m_page; | 154 std::unique_ptr<DummyPageHolder> m_page; |
153 RefPtr<SecurityOrigin> m_securityOrigin; | 155 RefPtr<SecurityOrigin> m_securityOrigin; |
154 std::unique_ptr<InProcessWorkerObjectProxy> m_objectProxy; | 156 std::unique_ptr<InProcessWorkerObjectProxy> m_objectProxy; |
155 CompositorWorkerTestPlatform m_testPlatform; | 157 CompositorWorkerTestPlatform m_testPlatform; |
156 }; | 158 }; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 v8::Isolate* secondIsolate = secondWorker->isolate(); | 236 v8::Isolate* secondIsolate = secondWorker->isolate(); |
235 ASSERT_TRUE(secondIsolate); | 237 ASSERT_TRUE(secondIsolate); |
236 EXPECT_EQ(firstIsolate, secondIsolate); | 238 EXPECT_EQ(firstIsolate, secondIsolate); |
237 | 239 |
238 // Verify that the isolate can run some scripts correctly in the second work
er. | 240 // Verify that the isolate can run some scripts correctly in the second work
er. |
239 checkWorkerCanExecuteScript(secondWorker.get()); | 241 checkWorkerCanExecuteScript(secondWorker.get()); |
240 secondWorker->terminateAndWait(); | 242 secondWorker->terminateAndWait(); |
241 } | 243 } |
242 | 244 |
243 } // namespace blink | 245 } // namespace blink |
OLD | NEW |