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

Unified Diff: third_party/WebKit/Source/modules/webaudio/OscillatorNode.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/OscillatorNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
index 3dc83b36be3147145fb06f1a7a1a3e493f88b061..e9deeba4b84f6d74b34c5117b41dff7dbef3f786 100644
--- a/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/OscillatorNode.cpp
@@ -330,19 +330,26 @@ bool OscillatorHandler::propagatesSilence() const
// ----------------------------------------------------------------
-OscillatorNode::OscillatorNode(AbstractAudioContext& context, float sampleRate)
+OscillatorNode::OscillatorNode(AbstractAudioContext& context)
: AudioScheduledSourceNode(context)
// Use musical pitch standard A440 as a default.
- , m_frequency(AudioParam::create(context, ParamTypeOscillatorFrequency, 440, 0, sampleRate / 2))
+ , m_frequency(AudioParam::create(context, ParamTypeOscillatorFrequency, 440, 0, context.sampleRate() / 2))
// Default to no detuning.
, m_detune(AudioParam::create(context, ParamTypeOscillatorDetune, 0))
{
- setHandler(OscillatorHandler::create(*this, sampleRate, m_frequency->handler(), m_detune->handler()));
+ setHandler(OscillatorHandler::create(*this, context.sampleRate(), m_frequency->handler(), m_detune->handler()));
}
-OscillatorNode* OscillatorNode::create(AbstractAudioContext& context, float sampleRate)
+OscillatorNode* OscillatorNode::create(AbstractAudioContext& context, ExceptionState& exceptionState)
{
- return new OscillatorNode(context, sampleRate);
+ DCHECK(isMainThread());
+
+ if (context.isContextClosed()) {
+ context.throwExceptionForClosedState(exceptionState);
+ return nullptr;
+ }
+
+ return new OscillatorNode(context);
}
DEFINE_TRACE(OscillatorNode)
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/OscillatorNode.h ('k') | third_party/WebKit/Source/modules/webaudio/PannerNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698