OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/AudioWorkletGlobalScope.h" | 5 #include "modules/webaudio/AudioWorkletGlobalScope.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "bindings/core/v8/SourceLocation.h" | 10 #include "bindings/core/v8/SourceLocation.h" |
11 #include "bindings/core/v8/ToV8.h" | 11 #include "bindings/core/v8/ToV8.h" |
12 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.h" |
13 #include "bindings/core/v8/V8BindingForTesting.h" | 13 #include "bindings/core/v8/V8BindingForTesting.h" |
14 #include "bindings/core/v8/V8BindingMacros.h" | 14 #include "bindings/core/v8/V8BindingMacros.h" |
15 #include "bindings/core/v8/V8GCController.h" | 15 #include "bindings/core/v8/V8GCController.h" |
16 #include "bindings/core/v8/V8ObjectConstructor.h" | 16 #include "bindings/core/v8/V8ObjectConstructor.h" |
17 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 17 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
18 #include "core/workers/WorkerBackingThread.h" | 18 #include "core/workers/WorkerBackingThread.h" |
19 #include "core/workers/WorkerReportingProxy.h" | 19 #include "core/workers/WorkerReportingProxy.h" |
| 20 #include "core/workers/WorkerTaskRunners.h" |
20 #include "core/workers/WorkerThreadStartupData.h" | 21 #include "core/workers/WorkerThreadStartupData.h" |
21 #include "modules/webaudio/AudioBuffer.h" | 22 #include "modules/webaudio/AudioBuffer.h" |
22 #include "modules/webaudio/AudioWorkletProcessor.h" | 23 #include "modules/webaudio/AudioWorkletProcessor.h" |
23 #include "modules/webaudio/AudioWorkletProcessorDefinition.h" | 24 #include "modules/webaudio/AudioWorkletProcessorDefinition.h" |
24 #include "modules/webaudio/AudioWorkletThread.h" | 25 #include "modules/webaudio/AudioWorkletThread.h" |
25 #include "platform/weborigin/SecurityOrigin.h" | 26 #include "platform/weborigin/SecurityOrigin.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 namespace blink { | 29 namespace blink { |
29 | 30 |
(...skipping 25 matching lines...) Expand all Loading... |
55 KURL(kParsedURLString, "http://fake.url/"), "fake user agent", "", | 56 KURL(kParsedURLString, "http://fake.url/"), "fake user agent", "", |
56 nullptr, kDontPauseWorkerGlobalScopeOnStart, nullptr, "", | 57 nullptr, kDontPauseWorkerGlobalScopeOnStart, nullptr, "", |
57 security_origin_.Get(), nullptr, kWebAddressSpaceLocal, nullptr, | 58 security_origin_.Get(), nullptr, kWebAddressSpaceLocal, nullptr, |
58 nullptr, WorkerV8Settings::Default()), | 59 nullptr, WorkerV8Settings::Default()), |
59 ParentFrameTaskRunners::Create(nullptr)); | 60 ParentFrameTaskRunners::Create(nullptr)); |
60 return thread; | 61 return thread; |
61 } | 62 } |
62 | 63 |
63 void RunBasicTest(WorkerThread* thread) { | 64 void RunBasicTest(WorkerThread* thread) { |
64 WaitableEvent waitable_event; | 65 WaitableEvent waitable_event; |
65 thread->PostTask( | 66 thread->GetWorkerTaskRunners() |
66 BLINK_FROM_HERE, | 67 ->Get(TaskType::kUnthrottled) |
67 CrossThreadBind( | 68 ->PostTask( |
68 &AudioWorkletGlobalScopeTest::RunBasicTestOnWorkletThread, | 69 BLINK_FROM_HERE, |
69 CrossThreadUnretained(this), CrossThreadUnretained(thread), | 70 CrossThreadBind( |
70 CrossThreadUnretained(&waitable_event))); | 71 &AudioWorkletGlobalScopeTest::RunBasicTestOnWorkletThread, |
| 72 CrossThreadUnretained(this), CrossThreadUnretained(thread), |
| 73 CrossThreadUnretained(&waitable_event))); |
71 waitable_event.Wait(); | 74 waitable_event.Wait(); |
72 } | 75 } |
73 | 76 |
74 void RunSimpleProcessTest(WorkerThread* thread) { | 77 void RunSimpleProcessTest(WorkerThread* thread) { |
75 WaitableEvent waitable_event; | 78 WaitableEvent waitable_event; |
76 thread->PostTask( | 79 thread->GetWorkerTaskRunners() |
77 BLINK_FROM_HERE, | 80 ->Get(TaskType::kUnthrottled) |
78 CrossThreadBind( | 81 ->PostTask(BLINK_FROM_HERE, |
79 &AudioWorkletGlobalScopeTest::RunSimpleProcessTestOnWorkletThread, | 82 CrossThreadBind(&AudioWorkletGlobalScopeTest:: |
80 CrossThreadUnretained(this), CrossThreadUnretained(thread), | 83 RunSimpleProcessTestOnWorkletThread, |
81 CrossThreadUnretained(&waitable_event))); | 84 CrossThreadUnretained(this), |
| 85 CrossThreadUnretained(thread), |
| 86 CrossThreadUnretained(&waitable_event))); |
82 waitable_event.Wait(); | 87 waitable_event.Wait(); |
83 } | 88 } |
84 | 89 |
85 void RunParsingTest(WorkerThread* thread) { | 90 void RunParsingTest(WorkerThread* thread) { |
86 WaitableEvent waitable_event; | 91 WaitableEvent waitable_event; |
87 thread->PostTask( | 92 thread->GetWorkerTaskRunners() |
88 BLINK_FROM_HERE, | 93 ->Get(TaskType::kUnthrottled) |
89 CrossThreadBind( | 94 ->PostTask( |
90 &AudioWorkletGlobalScopeTest::RunParsingTestOnWorkletThread, | 95 BLINK_FROM_HERE, |
91 CrossThreadUnretained(this), CrossThreadUnretained(thread), | 96 CrossThreadBind( |
92 CrossThreadUnretained(&waitable_event))); | 97 &AudioWorkletGlobalScopeTest::RunParsingTestOnWorkletThread, |
| 98 CrossThreadUnretained(this), CrossThreadUnretained(thread), |
| 99 CrossThreadUnretained(&waitable_event))); |
93 waitable_event.Wait(); | 100 waitable_event.Wait(); |
94 } | 101 } |
95 | 102 |
96 private: | 103 private: |
97 // Test if AudioWorkletGlobalScope and V8 components (ScriptState, Isolate) | 104 // Test if AudioWorkletGlobalScope and V8 components (ScriptState, Isolate) |
98 // are properly instantiated. Runs a simple processor registration and check | 105 // are properly instantiated. Runs a simple processor registration and check |
99 // if the class definition is correctly registered, then instantiate an | 106 // if the class definition is correctly registered, then instantiate an |
100 // AudioWorkletProcessor instance from the definition. | 107 // AudioWorkletProcessor instance from the definition. |
101 void RunBasicTestOnWorkletThread(WorkerThread* thread, | 108 void RunBasicTestOnWorkletThread(WorkerThread* thread, |
102 WaitableEvent* wait_event) { | 109 WaitableEvent* wait_event) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 thread->TerminateAndWait(); | 264 thread->TerminateAndWait(); |
258 } | 265 } |
259 | 266 |
260 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { | 267 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { |
261 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); | 268 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); |
262 RunSimpleProcessTest(thread.get()); | 269 RunSimpleProcessTest(thread.get()); |
263 thread->TerminateAndWait(); | 270 thread->TerminateAndWait(); |
264 } | 271 } |
265 | 272 |
266 } // namespace blink | 273 } // namespace blink |
OLD | NEW |