Chromium Code Reviews| Index: third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessorDefinition.h |
| diff --git a/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessorDefinition.h b/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessorDefinition.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..314ff3268a7b82c4dcaefa9713a4930a47d9b1bd |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessorDefinition.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef AudioWorkletProcessorDefinition_h |
| +#define AudioWorkletProcessorDefinition_h |
| + |
| +#include "bindings/core/v8/ScopedPersistent.h" |
| +#include "platform/heap/Handle.h" |
| +#include "v8/include/v8.h" |
| + |
| +namespace blink { |
| + |
| +class AudioBuffer; |
| +class ScriptState; |
| + |
| +// Represents a JavaScript class definition registered in the |
| +// AudioWorkletGlobalScope. After the registration, a definition class contains |
| +// the V8 representation of class components (constructor, process callback, |
| +// prototypes and parameter descriptors). |
| +// |
| +// This is constructed and destroyed on a worker thread, and all methods also |
| +// must be called on the worker thread. |
| +class AudioWorkletProcessorDefinition final |
| + : public GarbageCollectedFinalized<AudioWorkletProcessorDefinition> { |
| + public: |
| + static AudioWorkletProcessorDefinition* create( |
| + ScriptState*, |
| + v8::Local<v8::Function> constructor, |
| + v8::Local<v8::Function> process); |
| + |
| + virtual ~AudioWorkletProcessorDefinition(); |
| + |
| + // Create a V8 object instance of |AudioWorkletProcessor| from the definition. |
| + void createInstance(ScopedPersistent<v8::Object>& instance); |
| + |
| + // Perform process() call with an |AudioWorkletProcessor| instance. |
| + bool process(ScopedPersistent<v8::Object>& instance, |
| + AudioBuffer* inputBuffer, |
| + AudioBuffer* outputBuffer); |
| + |
| + ScriptState* getScriptState() const { return m_scriptState.get(); } |
| + |
| + DEFINE_INLINE_TRACE(){}; |
| + |
| + private: |
| + AudioWorkletProcessorDefinition(ScriptState*, |
| + v8::Local<v8::Function> constructor, |
| + v8::Local<v8::Function> process); |
| + |
| + RefPtr<ScriptState> m_scriptState; |
| + |
| + // The definition is per global scope. The active instance of |
| + // |AudioProcessorWorklet| should be passed into these to perform JS function. |
| + ScopedPersistent<v8::Function> m_constructor; |
| + ScopedPersistent<v8::Function> m_process; |
|
haraken
2017/03/08 09:57:19
Just to confirm: You're intending to keep these ob
hongchan
2017/03/08 19:38:46
Correct. This definition is owned by AWGS and it i
|
| + |
| + // TODO(hongchan): A container for AudioParamDescriptor objects. |
| + // ScopedPersistent<v8::Array> m_parameterDescriptors; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // AudioWorkletProcessorDefinition_h |