Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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/AudioWorkletProcessor.h" | |
| 6 | |
| 7 #include "modules/webaudio/AudioWorkletGlobalScope.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 // 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:
| |
| 12 // |AudioWorkletNode| gets created by user-supplied JS code in the main thread. | |
| 13 // 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.
| |
| 14 AudioWorkletProcessor* AudioWorkletProcessor::create( | |
| 15 AudioWorkletGlobalScope* globalScope, | |
| 16 const String& name) { | |
| 17 DCHECK(!isMainThread()); | |
|
Raymond Toy
2017/03/17 16:45:32
CHECK(globalScope)?
hongchan
2017/03/20 17:03:32
Done.
| |
| 18 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
| |
| 19 } | |
| 20 | |
| 21 AudioWorkletProcessor::AudioWorkletProcessor( | |
| 22 AudioWorkletGlobalScope* globalScope, | |
| 23 const String& name) | |
| 24 : 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
| |
| 25 | |
| 26 AudioWorkletProcessor::~AudioWorkletProcessor() {} | |
| 27 | |
| 28 void AudioWorkletProcessor::setInstance(v8::Isolate* isolate, | |
| 29 v8::Local<v8::Object> instance) { | |
| 30 DCHECK(m_globalScope->isContextThread()); | |
| 31 m_instance.set(isolate, instance); | |
| 32 } | |
| 33 | |
| 34 v8::Local<v8::Object> AudioWorkletProcessor::instanceLocal( | |
| 35 v8::Isolate* isolate) { | |
| 36 DCHECK(m_globalScope->isContextThread()); | |
| 37 return m_instance.newLocal(isolate); | |
| 38 } | |
| 39 | |
| 40 void AudioWorkletProcessor::process(AudioBuffer* inputBuffer, | |
| 41 AudioBuffer* outputBuffer) { | |
| 42 DCHECK(m_globalScope->isContextThread()); | |
| 43 m_globalScope->process(this, inputBuffer, outputBuffer); | |
| 44 } | |
| 45 | |
| 46 DEFINE_TRACE(AudioWorkletProcessor) { | |
| 47 visitor->trace(m_globalScope); | |
| 48 } | |
| 49 | |
| 50 } // namespace blink | |
| OLD | NEW |