Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / webaudio / AudioScheduledSourceNode.cpp
index 69d050a..798fc46 100644 (file)
 
 namespace blink {
 
-#if !ENABLE(OILPAN)
-// We need a dedicated specialization for AudioScheduledSourceNode because it
-// doesn't inherit from RefCounted.
-template<> struct CrossThreadCopierBase<false, false, false, PassRefPtr<AudioScheduledSourceNode> > : public CrossThreadCopierPassThrough<PassRefPtr<AudioScheduledSourceNode> > {
-};
-#endif
-
 const double AudioScheduledSourceNode::UnknownTime = -1;
 
 AudioScheduledSourceNode::AudioScheduledSourceNode(AudioContext* context, float sampleRate)
@@ -152,6 +145,13 @@ void AudioScheduledSourceNode::start(double when, ExceptionState& exceptionState
         return;
     }
 
+    if (!std::isfinite(when) || (when < 0)) {
+        exceptionState.throwDOMException(
+            InvalidStateError,
+            "Start time must be a finite non-negative number: " + String::number(when));
+        return;
+    }
+
     m_startTime = when;
     m_playbackState = SCHEDULED_STATE;
 }
@@ -164,13 +164,21 @@ void AudioScheduledSourceNode::stop(double when, ExceptionState& exceptionState)
         exceptionState.throwDOMException(
             InvalidStateError,
             "cannot call stop without calling start first.");
-    } else {
-        // stop() can be called more than once, with the last call to stop taking effect, unless the
-        // source has already stopped due to earlier calls to stop. No exceptions are thrown in any
-        // case.
-        when = std::max(0.0, when);
-        m_endTime = when;
+        return;
     }
+
+    if (!std::isfinite(when) || (when < 0)) {
+        exceptionState.throwDOMException(
+            InvalidStateError,
+            "Stop time must be a finite non-negative number: " + String::number(when));
+        return;
+    }
+
+    // stop() can be called more than once, with the last call to stop taking effect, unless the
+    // source has already stopped due to earlier calls to stop. No exceptions are thrown in any
+    // case.
+    when = std::max(0.0, when);
+    m_endTime = when;
 }
 
 void AudioScheduledSourceNode::setOnended(PassRefPtr<EventListener> listener)
@@ -188,7 +196,7 @@ void AudioScheduledSourceNode::finish()
     }
 
     if (m_hasEndedListener && context()->executionContext()) {
-        context()->executionContext()->postTask(createCrossThreadTask(&AudioScheduledSourceNode::notifyEnded, PassRefPtrWillBeRawPtr<AudioScheduledSourceNode>(this)));
+        context()->executionContext()->postTask(createCrossThreadTask(&AudioScheduledSourceNode::notifyEnded, this));
     }
 }