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

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

Issue 1952793002: Move the exception logic to the AudioNode creator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 7 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/AudioBufferSourceNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
index ed2437638e4ba271e2ff09c98190ed1da9b06a50..c1ff657683969e77b6d366583016fa35740e166f 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
@@ -581,17 +581,28 @@ void AudioBufferSourceHandler::handleStoppableSourceNode()
}
// ----------------------------------------------------------------
-AudioBufferSourceNode::AudioBufferSourceNode(AbstractAudioContext& context, float sampleRate)
+AudioBufferSourceNode::AudioBufferSourceNode(AbstractAudioContext& context)
: AudioScheduledSourceNode(context)
, m_playbackRate(AudioParam::create(context, ParamTypeAudioBufferSourcePlaybackRate, 1.0))
, m_detune(AudioParam::create(context, ParamTypeAudioBufferSourceDetune, 0.0))
{
- setHandler(AudioBufferSourceHandler::create(*this, sampleRate, m_playbackRate->handler(), m_detune->handler()));
+ setHandler(AudioBufferSourceHandler::create(
+ *this,
+ context.sampleRate(),
+ m_playbackRate->handler(),
+ m_detune->handler()));
}
-AudioBufferSourceNode* AudioBufferSourceNode::create(AbstractAudioContext& context, float sampleRate)
+AudioBufferSourceNode* AudioBufferSourceNode::create(AbstractAudioContext& context, ExceptionState& exceptionState)
{
- return new AudioBufferSourceNode(context, sampleRate);
+ DCHECK(isMainThread());
+
+ if (context.isContextClosed()) {
+ context.throwExceptionForClosedState(exceptionState);
+ return nullptr;
+ }
+
+ return new AudioBufferSourceNode(context);
}
DEFINE_TRACE(AudioBufferSourceNode)

Powered by Google App Engine
This is Rietveld 408576698