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

Side by Side Diff: chrome/browser/speech/tts_controller_impl.cc

Issue 546213003: [TTS] Fix non-enqueueable Utterance leak in TtsController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/speech/tts_controller_impl.h" 5 #include "chrome/browser/speech/tts_controller_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/float_util.h" 10 #include "base/float_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Clear any queued utterances too. 131 // Clear any queued utterances too.
132 ClearUtteranceQueue(false); // Don't sent events. 132 ClearUtteranceQueue(false); // Don't sent events.
133 } 133 }
134 134
135 void TtsControllerImpl::SpeakOrEnqueue(Utterance* utterance) { 135 void TtsControllerImpl::SpeakOrEnqueue(Utterance* utterance) {
136 // If we're paused and we get an utterance that can't be queued, 136 // If we're paused and we get an utterance that can't be queued,
137 // flush the queue but stay in the paused state. 137 // flush the queue but stay in the paused state.
138 if (paused_ && !utterance->can_enqueue()) { 138 if (paused_ && !utterance->can_enqueue()) {
139 Stop(); 139 Stop();
140 paused_ = true; 140 paused_ = true;
141 delete utterance;
141 return; 142 return;
142 } 143 }
143 144
144 if (paused_ || (IsSpeaking() && utterance->can_enqueue())) { 145 if (paused_ || (IsSpeaking() && utterance->can_enqueue())) {
145 utterance_queue_.push(utterance); 146 utterance_queue_.push(utterance);
146 } else { 147 } else {
147 Stop(); 148 Stop();
148 SpeakNow(utterance); 149 SpeakNow(utterance);
149 } 150 }
150 } 151 }
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 455 }
455 456
456 void TtsControllerImpl::SetTtsEngineDelegate( 457 void TtsControllerImpl::SetTtsEngineDelegate(
457 TtsEngineDelegate* delegate) { 458 TtsEngineDelegate* delegate) {
458 tts_engine_delegate_ = delegate; 459 tts_engine_delegate_ = delegate;
459 } 460 }
460 461
461 TtsEngineDelegate* TtsControllerImpl::GetTtsEngineDelegate() { 462 TtsEngineDelegate* TtsControllerImpl::GetTtsEngineDelegate() {
462 return tts_engine_delegate_; 463 return tts_engine_delegate_;
463 } 464 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698