Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp

Issue 2727733002: Implement AudioWorkletProcessor interface (Closed)
Patch Set: Refactored AudioWorkletGlobalScope to centralize V8 operation Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp b/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e8012313de775685d66f10cc234a618ffb90fa00
--- /dev/null
+++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp
@@ -0,0 +1,46 @@
+// 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.
+
+#include "modules/webaudio/AudioWorkletProcessor.h"
+
+#include "modules/webaudio/AudioWorkletGlobalScope.h"
+
+namespace blink {
+
+// This static factory should be called implicitly when an instance of
+// |AudioWorkletNode| gets created by user-supplied JS code in the main thread.
+// This factory must not be called by user in |AudioWorkletGlobalScope|.
+AudioWorkletProcessor* AudioWorkletProcessor::create(
+ AudioWorkletGlobalScope* globalScope,
+ const String& name) {
+ return new AudioWorkletProcessor(globalScope, name);
+}
+
+AudioWorkletProcessor::AudioWorkletProcessor(
+ AudioWorkletGlobalScope* globalScope,
+ const String& name)
+ : m_globalScope(globalScope), m_name(name) {}
+
+AudioWorkletProcessor::~AudioWorkletProcessor() {}
+
+void AudioWorkletProcessor::setInstance(v8::Isolate* isolate,
+ v8::Local<v8::Object> instance) {
+ m_instance.set(isolate, instance);
+}
+
+v8::Local<v8::Object> AudioWorkletProcessor::instanceLocal(
+ v8::Isolate* isolate) {
+ return m_instance.newLocal(isolate);
+}
+
+void AudioWorkletProcessor::process(AudioBuffer* inputBuffer,
+ AudioBuffer* outputBuffer) {
+ m_globalScope->process(this, inputBuffer, outputBuffer);
+}
+
+DEFINE_TRACE(AudioWorkletProcessor) {
+ visitor->trace(m_globalScope);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698