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

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

Issue 1952793002: Move the exception logic to the AudioNode creator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move more things to Node::create() 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/MediaElementAudioSourceNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.cpp b/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.cpp
index 10318c7860b6baf80e42ad22e30adee42e978948..c4711d517d907af20eb493521a5df77817a6ba5d 100644
--- a/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/MediaElementAudioSourceNode.cpp
@@ -208,9 +208,33 @@ MediaElementAudioSourceNode::MediaElementAudioSourceNode(AbstractAudioContext& c
setHandler(MediaElementAudioSourceHandler::create(*this, mediaElement));
}
-MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AbstractAudioContext& context, HTMLMediaElement& mediaElement)
+MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(
+ AbstractAudioContext& context, HTMLMediaElement& mediaElement, ExceptionState& exceptionState)
{
- return new MediaElementAudioSourceNode(context, mediaElement);
+ ASSERT(isMainThread());
hongchan 2016/05/13 01:20:12 DCHECK.
Raymond Toy 2016/05/20 23:12:00 Done.
+
+ if (context.isContextClosed()) {
+ context.throwExceptionForClosedState(exceptionState);
+ return nullptr;
+ }
+
+ // First check if this media element already has a source node.
+ if (mediaElement.audioSourceNode()) {
+ exceptionState.throwDOMException(
+ InvalidStateError,
+ "HTMLMediaElement already connected previously to a different MediaElementSourceNode.");
hongchan 2016/05/13 01:20:12 Over 80 cols. Might have to break this into multip
+ return nullptr;
+ }
+
+ MediaElementAudioSourceNode* node = new MediaElementAudioSourceNode(context, mediaElement);
+
+ if (node) {
+ mediaElement.setAudioSourceNode(node);
+ // context keeps reference until node is disconnected
+ context.notifySourceNodeStartedProcessing(node);
+ }
+
+ return node;
}
DEFINE_TRACE(MediaElementAudioSourceNode)

Powered by Google App Engine
This is Rietveld 408576698