Chromium Code Reviews| 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) |