Commit 2bd26402 authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

Converting PlatformSpeechSynthesizer to PreFinalizer

Bug: 981043
Change-Id: I405ec5da96e34a5bf5665ea338130976614d8237
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1697188
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676589}
parent adc8e7eb
......@@ -113,4 +113,8 @@ void PlatformSpeechSynthesizer::Trace(blink::Visitor* visitor) {
visitor->Trace(web_speech_synthesizer_client_);
}
void PlatformSpeechSynthesizer::Dispose() {
web_speech_synthesizer_.reset();
}
} // namespace blink
......@@ -62,6 +62,18 @@ class PLATFORM_EXPORT PlatformSpeechSynthesizerClient
class PLATFORM_EXPORT PlatformSpeechSynthesizer
: public GarbageCollectedFinalized<PlatformSpeechSynthesizer> {
// Pre-finalization is required to promptly release the owned
// WebSpeechSynthesizer.
//
// If not and delayed until lazily swept, web_speech_synthesizer_client_ may
// end up being lazily swept first (i.e., before this
// PlatformSpeechSynthesizer), leaving web_speech_synthesizer_ with a
// dangling pointer to a finalized object -- WebSpeechSynthesizer embedder
// implementations calling notification methods in the other directions by
// way of web_speech_synthesizer_client_. Eagerly releasing
// WebSpeechSynthesizer prevents such unsafe accesses.
USING_PRE_FINALIZER(PlatformSpeechSynthesizer, Dispose);
public:
static PlatformSpeechSynthesizer* Create(PlatformSpeechSynthesizerClient*);
......@@ -81,19 +93,10 @@ class PLATFORM_EXPORT PlatformSpeechSynthesizer
void SetVoiceList(Vector<scoped_refptr<PlatformSpeechSynthesisVoice>>&);
// Eager finalization is required to promptly release the owned
// WebSpeechSynthesizer.
//
// If not and delayed until lazily swept, m_webSpeechSynthesizerClient may end
// up being lazily swept first (i.e., before this PlatformSpeechSynthesizer),
// leaving m_webSpeechSynthesizer with a dangling pointer to a finalized
// object -- WebSpeechSynthesizer embedder implementations calling
// notification methods in the other directions by way of
// m_webSpeechSynthesizerClient. Eagerly releasing WebSpeechSynthesizer
// prevents such unsafe accesses.
EAGERLY_FINALIZE();
virtual void Trace(blink::Visitor*);
void Dispose();
protected:
virtual void InitializeVoiceList();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment