OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/webaudio/AudioWorkletProcessorDefinition.h" |
| 6 |
| 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/V8BindingMacros.h" |
| 10 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 11 #include "core/dom/ExecutionContext.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 AudioWorkletProcessorDefinition* AudioWorkletProcessorDefinition::create(ScriptS
tate* scriptState, v8::Local<v8::Function> constructor, v8::Local<v8::Function>
process) |
| 16 { |
| 17 return new AudioWorkletProcessorDefinition(scriptState, constructor, process
); |
| 18 } |
| 19 |
| 20 AudioWorkletProcessorDefinition::AudioWorkletProcessorDefinition(ScriptState* sc
riptState, v8::Local<v8::Function> constructor, v8::Local<v8::Function> process) |
| 21 : m_scriptState(scriptState) |
| 22 , m_constructor(scriptState->isolate(), constructor) |
| 23 , m_process(scriptState->isolate(), process) |
| 24 { |
| 25 } |
| 26 |
| 27 AudioWorkletProcessorDefinition::~AudioWorkletProcessorDefinition() |
| 28 { |
| 29 } |
| 30 |
| 31 void AudioWorkletProcessorDefinition::process() |
| 32 { |
| 33 // TODO: currently this happens in the main thread!!! |
| 34 |
| 35 // ScriptState::Scope scope(m_scriptState.get()); |
| 36 |
| 37 // maybeCreateProcessInstance(); |
| 38 |
| 39 // v8::Isolate* isolate = m_scriptState->isolate(); |
| 40 |
| 41 // We may have failed to create an instance class, in which case produce an |
| 42 // invalid image. |
| 43 // if (isUndefinedOrNull(instance)) |
| 44 // return nullptr; |
| 45 |
| 46 // TODO: do some audio stuff. |
| 47 // v8::Local<v8::Value> argv[] = { |
| 48 // toV8(someAudioStuff, m_scriptState->context()->Global(), isolate), |
| 49 // }; |
| 50 |
| 51 // v8::Local<v8::Function> process = m_process.newLocal(isolate); |
| 52 |
| 53 // v8::TryCatch block(isolate); |
| 54 // block.SetVerbose(true); |
| 55 |
| 56 // V8ScriptRunner::callFunction(process, m_scriptState->getExecutionContext(
), instance, 2, argv, isolate); |
| 57 |
| 58 // The paint function may have produced an error, in which case produce an |
| 59 // invalid image. |
| 60 // if (block.HasCaught()) { |
| 61 // return; |
| 62 // } |
| 63 |
| 64 return; |
| 65 } |
| 66 |
| 67 void AudioWorkletProcessorDefinition::maybeCreateProcessInstance() |
| 68 { |
| 69 if (m_didCallConstructor) |
| 70 return; |
| 71 |
| 72 // DCHECK(m_instance.isEmpty()); |
| 73 |
| 74 // v8::Isolate* isolate = m_scriptState->isolate(); |
| 75 // v8::Local<v8::Function> constructor = m_constructor.newLocal(isolate); |
| 76 // DCHECK(!isUndefinedOrNull(constructor)); |
| 77 |
| 78 // v8::Local<v8::Object> processInstance; |
| 79 // if (V8ObjectConstructor::newInstance(isolate, constructor).ToLocal(&proce
ssInstance)) { |
| 80 // m_instance.set(isolate, processInstance); |
| 81 // } |
| 82 |
| 83 m_didCallConstructor = true; |
| 84 } |
| 85 |
| 86 } // namespace blink |
OLD | NEW |