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

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

Issue 2826263002: Make DOMArrayBuffer::Transfer neuter v8::ArrayBuffers (Closed)
Patch Set: feedback Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMSharedArrayBuffer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 aa91dff6eeb9549e42a29a0eefde133b082d5abf..403b1f851c9e0707c5d69fac4561dd84d6369380 100644
--- a/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp
@@ -285,8 +285,19 @@ ScriptPromise BaseAudioContext::decodeAudioData(
DCHECK_GT(rate, 0);
- if (audio_data->IsNeutered()) {
- // If audioData is detached (neutered) we need to reject the
+ v8::Isolate* isolate = script_state->GetIsolate();
+ WTF::ArrayBufferContents buffer_contents;
+ // Detach the audio array buffer from the main thread and start
+ // async decoding of the data.
+ if (audio_data->IsNeuterable(isolate) &&
+ audio_data->Transfer(isolate, buffer_contents)) {
+ DOMArrayBuffer* audio = DOMArrayBuffer::Create(buffer_contents);
+
+ decode_audio_resolvers_.insert(resolver);
+ audio_decoder_.DecodeAsync(audio, rate, success_callback, error_callback,
+ resolver, this);
+ } else {
+ // If audioData is already detached (neutered) we need to reject the
// promise with an error.
DOMException* error = DOMException::Create(
kDataCloneError, "Cannot decode detached ArrayBuffer");
@@ -294,16 +305,6 @@ ScriptPromise BaseAudioContext::decodeAudioData(
if (error_callback) {
error_callback->handleEvent(error);
}
- } else {
- // Detach the audio array buffer from the main thread and start
- // async decoding of the data.
- WTF::ArrayBufferContents buffer_contents;
- audio_data->Transfer(buffer_contents);
- DOMArrayBuffer* audio = DOMArrayBuffer::Create(buffer_contents);
-
- decode_audio_resolvers_.insert(resolver);
- audio_decoder_.DecodeAsync(audio, rate, success_callback, error_callback,
- resolver, this);
}
return promise;
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMSharedArrayBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698