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 #ifndef AudioWorkletProcessorDefinition_h |
| 6 #define AudioWorkletProcessorDefinition_h |
| 7 |
| 8 #include "bindings/core/v8/ScopedPersistent.h" |
| 9 #include "platform/heap/Handle.h" |
| 10 #include <v8.h> |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class ScriptState; |
| 15 |
| 16 class AudioWorkletProcessorDefinition final : public GarbageCollectedFinalized<A
udioWorkletProcessorDefinition> { |
| 17 public: |
| 18 static AudioWorkletProcessorDefinition* create(ScriptState*, v8::Local<v8::F
unction> constructor, v8::Local<v8::Function> process); |
| 19 virtual ~AudioWorkletProcessorDefinition(); |
| 20 |
| 21 // TODO: connect this to WebAudio render callback. |
| 22 void process(); |
| 23 |
| 24 ScriptState* getScriptState() const { return m_scriptState.get(); } |
| 25 |
| 26 v8::Local<v8::Function> processFunctionForTesting(v8::Isolate* isolate) { re
turn m_process.newLocal(isolate); } |
| 27 |
| 28 DEFINE_INLINE_TRACE() {}; |
| 29 |
| 30 private: |
| 31 AudioWorkletProcessorDefinition(ScriptState*, v8::Local<v8::Function> constr
uctor, v8::Local<v8::Function> process); |
| 32 |
| 33 void maybeCreateProcessInstance(); |
| 34 |
| 35 RefPtr<ScriptState> m_scriptState; |
| 36 |
| 37 // This object keeps the class instance object, constructor function and |
| 38 // process function alive. This object needs to be destroyed to break a |
| 39 // reference cycle between it and the AudioWorkletGlobalScope. |
| 40 ScopedPersistent<v8::Function> m_constructor; |
| 41 ScopedPersistent<v8::Function> m_process; |
| 42 |
| 43 bool m_didCallConstructor; |
| 44 }; |
| 45 |
| 46 } // namespace blink |
| 47 |
| 48 #endif // AudioWorkletProcessorDefinition_h |
OLD | NEW |