Chromium Code Reviews| Index: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
| diff --git a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
| index d0acd8dbd40e27c20f1486655552d659e763b0ab..73f783cef62b3fe3f5e324cb8f0a50c7f6ca4fb5 100644 |
| --- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
| +++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp |
| @@ -284,9 +284,26 @@ ScriptPromise BaseAudioContext::decodeAudioData( |
| DCHECK_GT(rate, 0); |
| - m_decodeAudioResolvers.insert(resolver); |
| - m_audioDecoder.decodeAsync(audioData, rate, successCallback, errorCallback, |
| - resolver, this); |
| + if (audioData->isNeutered()) { |
| + // If audioData is detached (neutered) we need to reject the |
| + // promise with error.. |
|
hongchan
2017/03/23 16:40:25
super nit: two periods?
|
| + DOMException* error = DOMException::create( |
| + DataCloneError, "Cannot decode detached ArrayBuffer"); |
| + resolver->reject(error); |
| + if (errorCallback) { |
| + errorCallback->handleEvent(error); |
| + } |
| + } else { |
| + // Detach the audio array buffer from the main thread and start |
| + // async decoding of the data. |
| + WTF::ArrayBufferContents buf; |
|
hongchan
2017/03/23 16:40:25
s/buf/bufferContent/
|
| + audioData->transfer(buf); |
| + DOMArrayBuffer* audio = DOMArrayBuffer::create(buf); |
| + |
| + m_decodeAudioResolvers.insert(resolver); |
| + m_audioDecoder.decodeAsync(audio, rate, successCallback, errorCallback, |
| + resolver, this); |
| + } |
| return promise; |
| } |