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

Side by Side Diff: Source/modules/speech/SpeechSynthesis.cpp

Issue 228133002: Fix crash if utterance is garbage-collected before speech ends. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch to RefPtrWillBeRawPtr Created 6 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/speechsynthesis/speech-synthesis-gc-utterance-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtteran ce* utterance, unsigned long charIndex, const String& name) 146 void SpeechSynthesis::fireEvent(const AtomicString& type, SpeechSynthesisUtteran ce* utterance, unsigned long charIndex, const String& name)
147 { 147 {
148 if (!executionContext()->activeDOMObjectsAreStopped()) 148 if (!executionContext()->activeDOMObjectsAreStopped())
149 utterance->dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, ( currentTime() - utterance->startTime()), name)); 149 utterance->dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, ( currentTime() - utterance->startTime()), name));
150 } 150 }
151 151
152 void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc e, bool errorOccurred) 152 void SpeechSynthesis::handleSpeakingCompleted(SpeechSynthesisUtterance* utteranc e, bool errorOccurred)
153 { 153 {
154 ASSERT(utterance); 154 ASSERT(utterance);
155 RefPtrWillBeRawPtr<SpeechSynthesisUtterance> protect(utterance);
155 156
156 bool didJustFinishCurrentUtterance = false; 157 bool didJustFinishCurrentUtterance = false;
157 // If the utterance that completed was the one we're currently speaking, 158 // If the utterance that completed was the one we're currently speaking,
158 // remove it from the queue and start speaking the next one. 159 // remove it from the queue and start speaking the next one.
159 if (utterance == currentSpeechUtterance()) { 160 if (utterance == currentSpeechUtterance()) {
160 m_utteranceQueue.removeFirst(); 161 m_utteranceQueue.removeFirst();
eseidel 2014/04/08 17:56:33 How did this work before if "utterance" can be del
161 didJustFinishCurrentUtterance = true; 162 didJustFinishCurrentUtterance = true;
162 } 163 }
163 164
164 // Always fire the event, because the platform may have asynchronously 165 // Always fire the event, because the platform may have asynchronously
165 // sent an event on an utterance before it got the message that we 166 // sent an event on an utterance before it got the message that we
166 // canceled it, and we should always report to the user what actually 167 // canceled it, and we should always report to the user what actually
167 // happened. 168 // happened.
168 fireEvent(errorOccurred ? EventTypeNames::error : EventTypeNames::end, utter ance, 0, String()); 169 fireEvent(errorOccurred ? EventTypeNames::error : EventTypeNames::end, utter ance, 0, String());
169 170
170 // Start the next utterance if we just finished one and one was pending. 171 // Start the next utterance if we just finished one and one was pending.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 return EventTargetNames::SpeechSynthesisUtterance; 234 return EventTargetNames::SpeechSynthesisUtterance;
234 } 235 }
235 236
236 void SpeechSynthesis::trace(Visitor* visitor) 237 void SpeechSynthesis::trace(Visitor* visitor)
237 { 238 {
238 visitor->trace(m_voiceList); 239 visitor->trace(m_voiceList);
239 visitor->trace(m_utteranceQueue); 240 visitor->trace(m_utteranceQueue);
240 } 241 }
241 242
242 } // namespace WebCore 243 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/speechsynthesis/speech-synthesis-gc-utterance-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698