OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/webaudio/AudioWorkletThread.h" | 5 #include "modules/webaudio/AudioWorkletThread.h" |
6 | 6 |
| 7 #include <memory> |
7 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
8 #include "bindings/core/v8/SourceLocation.h" | 9 #include "bindings/core/v8/SourceLocation.h" |
9 #include "bindings/core/v8/V8GCController.h" | 10 #include "bindings/core/v8/V8GCController.h" |
10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 11 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 12 #include "core/dom/TaskRunnerHelper.h" |
11 #include "core/inspector/ConsoleMessage.h" | 13 #include "core/inspector/ConsoleMessage.h" |
12 #include "core/workers/WorkerBackingThread.h" | 14 #include "core/workers/WorkerBackingThread.h" |
13 #include "core/workers/WorkerLoaderProxy.h" | 15 #include "core/workers/WorkerLoaderProxy.h" |
14 #include "core/workers/WorkerOrWorkletGlobalScope.h" | 16 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
15 #include "core/workers/WorkerReportingProxy.h" | 17 #include "core/workers/WorkerReportingProxy.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" |
26 #include "wtf/PtrUtil.h" | 28 #include "wtf/PtrUtil.h" |
27 #include <memory> | |
28 | 29 |
29 namespace blink { | 30 namespace blink { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 // A null WorkerReportingProxy, supplied when creating AudioWorkletThreads. | 34 // A null WorkerReportingProxy, supplied when creating AudioWorkletThreads. |
34 class TestAudioWorkletReportingProxy : public WorkerReportingProxy { | 35 class TestAudioWorkletReportingProxy : public WorkerReportingProxy { |
35 public: | 36 public: |
36 static std::unique_ptr<TestAudioWorkletReportingProxy> create() { | 37 static std::unique_ptr<TestAudioWorkletReportingProxy> create() { |
37 return WTF::wrapUnique(new TestAudioWorkletReportingProxy()); | 38 return WTF::wrapUnique(new TestAudioWorkletReportingProxy()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 73 |
73 std::unique_ptr<AudioWorkletThread> createAudioWorkletThread() { | 74 std::unique_ptr<AudioWorkletThread> createAudioWorkletThread() { |
74 std::unique_ptr<AudioWorkletThread> thread = | 75 std::unique_ptr<AudioWorkletThread> thread = |
75 AudioWorkletThread::create(nullptr, *m_reportingProxy); | 76 AudioWorkletThread::create(nullptr, *m_reportingProxy); |
76 thread->start( | 77 thread->start( |
77 WorkerThreadStartupData::create( | 78 WorkerThreadStartupData::create( |
78 KURL(ParsedURLString, "http://fake.url/"), "fake user agent", "", | 79 KURL(ParsedURLString, "http://fake.url/"), "fake user agent", "", |
79 nullptr, DontPauseWorkerGlobalScopeOnStart, nullptr, "", | 80 nullptr, DontPauseWorkerGlobalScopeOnStart, nullptr, "", |
80 m_securityOrigin.get(), nullptr, WebAddressSpaceLocal, nullptr, | 81 m_securityOrigin.get(), nullptr, WebAddressSpaceLocal, nullptr, |
81 nullptr, WorkerV8Settings::Default()), | 82 nullptr, WorkerV8Settings::Default()), |
82 ParentFrameTaskRunners::create(nullptr)); | 83 FrameTaskRunnersHolder::create(nullptr)); |
83 return thread; | 84 return thread; |
84 } | 85 } |
85 | 86 |
86 // Attempts to run some simple script for |thread|. | 87 // Attempts to run some simple script for |thread|. |
87 void checkWorkletCanExecuteScript(WorkerThread* thread) { | 88 void checkWorkletCanExecuteScript(WorkerThread* thread) { |
88 WaitableEvent waitEvent; | 89 WaitableEvent waitEvent; |
89 thread->workerBackingThread().backingThread().postTask( | 90 thread->workerBackingThread().backingThread().postTask( |
90 BLINK_FROM_HERE, | 91 BLINK_FROM_HERE, |
91 crossThreadBind(&AudioWorkletThreadTest::executeScriptInWorklet, | 92 crossThreadBind(&AudioWorkletThreadTest::executeScriptInWorklet, |
92 crossThreadUnretained(this), | 93 crossThreadUnretained(this), |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ASSERT_TRUE(secondIsolate); | 191 ASSERT_TRUE(secondIsolate); |
191 EXPECT_EQ(firstIsolate, secondIsolate); | 192 EXPECT_EQ(firstIsolate, secondIsolate); |
192 | 193 |
193 // Verify that the isolate can run some scripts correctly in the second | 194 // Verify that the isolate can run some scripts correctly in the second |
194 // worklet. | 195 // worklet. |
195 checkWorkletCanExecuteScript(secondWorklet.get()); | 196 checkWorkletCanExecuteScript(secondWorklet.get()); |
196 secondWorklet->terminateAndWait(); | 197 secondWorklet->terminateAndWait(); |
197 } | 198 } |
198 | 199 |
199 } // namespace blink | 200 } // namespace blink |
OLD | NEW |