| 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 "core/dom/CompositorProxyClient.h" | 10 #include "core/dom/CompositorProxyClient.h" |
| 11 #include "core/inspector/ConsoleMessage.h" | 11 #include "core/inspector/ConsoleMessage.h" |
| 12 #include "core/testing/DummyPageHolder.h" | 12 #include "core/testing/DummyPageHolder.h" |
| 13 #include "core/workers/InProcessWorkerObjectProxy.h" | 13 #include "core/workers/InProcessWorkerObjectProxy.h" |
| 14 #include "core/workers/WorkerBackingThread.h" | 14 #include "core/workers/WorkerBackingThread.h" |
| 15 #include "core/workers/WorkerLoaderProxy.h" | 15 #include "core/workers/WorkerLoaderProxy.h" |
| 16 #include "core/workers/WorkerThreadStartupData.h" | 16 #include "core/workers/WorkerThreadStartupData.h" |
| 17 #include "platform/ThreadSafeFunctional.h" | 17 #include "platform/CrossThreadFunctional.h" |
| 18 #include "platform/WaitableEvent.h" | 18 #include "platform/WaitableEvent.h" |
| 19 #include "platform/WebThreadSupportingGC.h" | 19 #include "platform/WebThreadSupportingGC.h" |
| 20 #include "platform/heap/Handle.h" | 20 #include "platform/heap/Handle.h" |
| 21 #include "platform/testing/TestingPlatformSupport.h" | 21 #include "platform/testing/TestingPlatformSupport.h" |
| 22 #include "platform/testing/UnitTestHelpers.h" | 22 #include "platform/testing/UnitTestHelpers.h" |
| 23 #include "public/platform/Platform.h" | 23 #include "public/platform/Platform.h" |
| 24 #include "public/platform/WebAddressSpace.h" | 24 #include "public/platform/WebAddressSpace.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "wtf/PtrUtil.h" | 26 #include "wtf/PtrUtil.h" |
| 27 #include <memory> | 27 #include <memory> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 WebAddressSpaceLocal, | 129 WebAddressSpaceLocal, |
| 130 nullptr, | 130 nullptr, |
| 131 V8CacheOptionsDefault)); | 131 V8CacheOptionsDefault)); |
| 132 return workerThread; | 132 return workerThread; |
| 133 } | 133 } |
| 134 | 134 |
| 135 // Attempts to run some simple script for |worker|. | 135 // Attempts to run some simple script for |worker|. |
| 136 void checkWorkerCanExecuteScript(WorkerThread* worker) | 136 void checkWorkerCanExecuteScript(WorkerThread* worker) |
| 137 { | 137 { |
| 138 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); | 138 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); |
| 139 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
threadSafeBind(&CompositorWorkerThreadTest::executeScriptInWorker, crossThreadUn
retained(this), | 139 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, crossThreadU
nretained(this), |
| 140 crossThreadUnretained(worker), crossThreadUnretained(waitEvent.get()
))); | 140 crossThreadUnretained(worker), crossThreadUnretained(waitEvent.get()
))); |
| 141 waitEvent->wait(); | 141 waitEvent->wait(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 private: | 144 private: |
| 145 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) | 145 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) |
| 146 { | 146 { |
| 147 WorkerOrWorkletScriptController* scriptController = worker->workerGlobal
Scope()->scriptController(); | 147 WorkerOrWorkletScriptController* scriptController = worker->workerGlobal
Scope()->scriptController(); |
| 148 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); | 148 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); |
| 149 ASSERT_UNUSED(evaluateResult, evaluateResult); | 149 ASSERT_UNUSED(evaluateResult, evaluateResult); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 v8::Isolate* secondIsolate = secondWorker->isolate(); | 235 v8::Isolate* secondIsolate = secondWorker->isolate(); |
| 236 ASSERT_TRUE(secondIsolate); | 236 ASSERT_TRUE(secondIsolate); |
| 237 EXPECT_EQ(firstIsolate, secondIsolate); | 237 EXPECT_EQ(firstIsolate, secondIsolate); |
| 238 | 238 |
| 239 // Verify that the isolate can run some scripts correctly in the second work
er. | 239 // Verify that the isolate can run some scripts correctly in the second work
er. |
| 240 checkWorkerCanExecuteScript(secondWorker.get()); | 240 checkWorkerCanExecuteScript(secondWorker.get()); |
| 241 secondWorker->terminateAndWait(); | 241 secondWorker->terminateAndWait(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace blink | 244 } // namespace blink |
| OLD | NEW |