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

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

Issue 2103823002: Disallow raw pointers in CrossThreadCopier/threadSafeBind() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug fix. Created 4 years, 6 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/AsyncAudioDecoder.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AsyncAudioDecoder.cpp b/third_party/WebKit/Source/modules/webaudio/AsyncAudioDecoder.cpp
index e0aa660705706b9e95aeb51b8e5962e2847bd21e..010ba3147b3e8860e51d6e33b36103b7fb16954e 100644
--- a/third_party/WebKit/Source/modules/webaudio/AsyncAudioDecoder.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AsyncAudioDecoder.cpp
@@ -52,7 +52,6 @@ void AsyncAudioDecoder::decodeAsync(DOMArrayBuffer* audioData, float sampleRate,
if (!audioData)
return;
- // The leak references to successCallback and errorCallback are picked up on notifyComplete.
m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&AsyncAudioDecoder::decode, wrapCrossThreadPersistent(audioData), sampleRate, wrapCrossThreadPersistent(successCallback), wrapCrossThreadPersistent(errorCallback), wrapCrossThreadPersistent(resolver), wrapCrossThreadPersistent(context)));
}
@@ -61,17 +60,14 @@ void AsyncAudioDecoder::decode(DOMArrayBuffer* audioData, float sampleRate, Audi
RefPtr<AudioBus> bus = createBusFromInMemoryAudioFile(audioData->data(), audioData->byteLength(), false, sampleRate);
// Decoding is finished, but we need to do the callbacks on the main thread.
- // The leaked reference to audioBuffer is picked up in notifyComplete.
- Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&AsyncAudioDecoder::notifyComplete, wrapCrossThreadPersistent(audioData), wrapCrossThreadPersistent(successCallback), wrapCrossThreadPersistent(errorCallback), bus.release().leakRef(), wrapCrossThreadPersistent(resolver), wrapCrossThreadPersistent(context)));
+ // A reference to |*bus| is retained by WTF::Function and will be removed after notifyComplete() is done.
+ Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&AsyncAudioDecoder::notifyComplete, wrapCrossThreadPersistent(audioData), wrapCrossThreadPersistent(successCallback), wrapCrossThreadPersistent(errorCallback), bus.release(), wrapCrossThreadPersistent(resolver), wrapCrossThreadPersistent(context)));
}
void AsyncAudioDecoder::notifyComplete(DOMArrayBuffer*, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, AudioBus* audioBus, ScriptPromiseResolver* resolver, AbstractAudioContext* context)
{
ASSERT(isMainThread());
- // Adopt references, so everything gets correctly dereffed.
- RefPtr<AudioBus> audioBusRef = adoptRef(audioBus);
-
AudioBuffer* audioBuffer = AudioBuffer::createFromAudioBus(audioBus);
// Let the context finish the notification.

Powered by Google App Engine
This is Rietveld 408576698