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

Unified Diff: chrome/browser/speech/speech_input_manager.cc

Issue 6358007: Cancel any pending speech recognitions when the dispatcher host terminates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 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: chrome/browser/speech/speech_input_manager.cc
diff --git a/chrome/browser/speech/speech_input_manager.cc b/chrome/browser/speech/speech_input_manager.cc
index 25f055074bbd4bdaaf948c8b401478f7d555240f..f76775a85bdf305c1efecbf864d86088f367d904 100644
--- a/chrome/browser/speech/speech_input_manager.cc
+++ b/chrome/browser/speech/speech_input_manager.cc
@@ -102,6 +102,8 @@ class SpeechInputManagerImpl : public SpeechInputManager,
const std::string& grammar);
virtual void CancelRecognition(int caller_id);
virtual void StopRecording(int caller_id);
+ virtual void CancelAllRequestsWithDelegate(
+ SpeechInputManagerDelegate* delegate);
// SpeechRecognizer::Delegate methods.
virtual void SetRecognitionResult(int caller_id,
@@ -254,6 +256,20 @@ void SpeechInputManagerImpl::CancelRecognition(int caller_id) {
bubble_controller_->CloseBubble(caller_id);
}
+void SpeechInputManagerImpl::CancelAllRequestsWithDelegate(
+ SpeechInputManagerDelegate* delegate) {
+ SpeechRecognizerMap::iterator it = requests_.begin();
+ while (it != requests_.end()) {
+ if (it->second.delegate == delegate) {
+ CancelRecognition(it->first);
+ // This map will have very few elements so it is simpler to restart.
+ it = requests_.begin();
+ } else {
+ ++it;
+ }
+ }
+}
+
void SpeechInputManagerImpl::StopRecording(int caller_id) {
DCHECK(HasPendingRequest(caller_id));
requests_[caller_id].recognizer->StopRecording();

Powered by Google App Engine
This is Rietveld 408576698