Chromium Code Reviews| 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..d0f17fe3aff94a86f3073cc5b50ca343c2fd7cdf |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.cpp |
| @@ -0,0 +1,50 @@ |
| +// 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 |
|
Raymond Toy
2017/03/17 16:45:32
How is it called "implicitly"?
hongchan
2017/03/20 17:03:32
I tried to explain the procedure in he design doc:
|
| +// |AudioWorkletNode| gets created by user-supplied JS code in the main thread. |
| +// This factory must not be called by user in |AudioWorkletGlobalScope|. |
|
Raymond Toy
2017/03/17 16:45:32
Anyway to check that it's being called the user in
hongchan
2017/03/20 17:03:32
DCHECK(globalScope) is the best I can do here.
|
| +AudioWorkletProcessor* AudioWorkletProcessor::create( |
| + AudioWorkletGlobalScope* globalScope, |
| + const String& name) { |
| + DCHECK(!isMainThread()); |
|
Raymond Toy
2017/03/17 16:45:32
CHECK(globalScope)?
hongchan
2017/03/20 17:03:32
Done.
|
| + return new AudioWorkletProcessor(globalScope, name); |
|
Raymond Toy
2017/03/17 16:45:32
Is it an error to return nullptr? Is it up to the
hongchan
2017/03/20 17:03:32
Checks are done by AudioWorkletGlobalScope. This A
|
| +} |
| + |
| +AudioWorkletProcessor::AudioWorkletProcessor( |
| + AudioWorkletGlobalScope* globalScope, |
| + const String& name) |
| + : m_globalScope(globalScope), m_name(name) {} |
|
Raymond Toy
2017/03/17 16:45:32
CHECK(globalScope)? I assume things aren't going t
hongchan
2017/03/20 17:03:32
The static factory already checks |globalScope| an
|
| + |
| +AudioWorkletProcessor::~AudioWorkletProcessor() {} |
| + |
| +void AudioWorkletProcessor::setInstance(v8::Isolate* isolate, |
| + v8::Local<v8::Object> instance) { |
| + DCHECK(m_globalScope->isContextThread()); |
| + m_instance.set(isolate, instance); |
| +} |
| + |
| +v8::Local<v8::Object> AudioWorkletProcessor::instanceLocal( |
| + v8::Isolate* isolate) { |
| + DCHECK(m_globalScope->isContextThread()); |
| + return m_instance.newLocal(isolate); |
| +} |
| + |
| +void AudioWorkletProcessor::process(AudioBuffer* inputBuffer, |
| + AudioBuffer* outputBuffer) { |
| + DCHECK(m_globalScope->isContextThread()); |
| + m_globalScope->process(this, inputBuffer, outputBuffer); |
| +} |
| + |
| +DEFINE_TRACE(AudioWorkletProcessor) { |
| + visitor->trace(m_globalScope); |
| +} |
| + |
| +} // namespace blink |