| 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" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 WebAddressSpaceLocal, | 128 WebAddressSpaceLocal, |
| 129 nullptr, | 129 nullptr, |
| 130 V8CacheOptionsDefault)); | 130 V8CacheOptionsDefault)); |
| 131 return workerThread; | 131 return workerThread; |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Attempts to run some simple script for |worker|. | 134 // Attempts to run some simple script for |worker|. |
| 135 void checkWorkerCanExecuteScript(WorkerThread* worker) | 135 void checkWorkerCanExecuteScript(WorkerThread* worker) |
| 136 { | 136 { |
| 137 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); | 137 std::unique_ptr<WaitableEvent> waitEvent = wrapUnique(new WaitableEvent(
)); |
| 138 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
threadSafeBind(&CompositorWorkerThreadTest::executeScriptInWorker, AllowCrossThr
eadAccess(this), | 138 worker->workerBackingThread().backingThread().postTask(BLINK_FROM_HERE,
threadSafeBind(&CompositorWorkerThreadTest::executeScriptInWorker, crossThreadUn
retained(this), |
| 139 AllowCrossThreadAccess(worker), AllowCrossThreadAccess(waitEvent.get
()))); | 139 crossThreadUnretained(worker), crossThreadUnretained(waitEvent.get()
))); |
| 140 waitEvent->wait(); | 140 waitEvent->wait(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 private: | 143 private: |
| 144 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) | 144 void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent) |
| 145 { | 145 { |
| 146 WorkerOrWorkletScriptController* scriptController = worker->workerGlobal
Scope()->scriptController(); | 146 WorkerOrWorkletScriptController* scriptController = worker->workerGlobal
Scope()->scriptController(); |
| 147 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); | 147 bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var c
ounter = 0; ++counter;")); |
| 148 ASSERT_UNUSED(evaluateResult, evaluateResult); | 148 ASSERT_UNUSED(evaluateResult, evaluateResult); |
| 149 waitEvent->signal(); | 149 waitEvent->signal(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 v8::Isolate* secondIsolate = secondWorker->isolate(); | 234 v8::Isolate* secondIsolate = secondWorker->isolate(); |
| 235 ASSERT_TRUE(secondIsolate); | 235 ASSERT_TRUE(secondIsolate); |
| 236 EXPECT_EQ(firstIsolate, secondIsolate); | 236 EXPECT_EQ(firstIsolate, secondIsolate); |
| 237 | 237 |
| 238 // Verify that the isolate can run some scripts correctly in the second work
er. | 238 // Verify that the isolate can run some scripts correctly in the second work
er. |
| 239 checkWorkerCanExecuteScript(secondWorker.get()); | 239 checkWorkerCanExecuteScript(secondWorker.get()); |
| 240 secondWorker->terminateAndWait(); | 240 secondWorker->terminateAndWait(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |