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

Unified Diff: chrome/browser/speech/speech_input_dispatcher_host.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
« no previous file with comments | « chrome/browser/speech/speech_input_dispatcher_host.h ('k') | chrome/browser/speech/speech_input_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/speech_input_dispatcher_host.cc
diff --git a/chrome/browser/speech/speech_input_dispatcher_host.cc b/chrome/browser/speech/speech_input_dispatcher_host.cc
index cfcbed7270505859a2c8950f4d6dda48187be0aa..dc993d5077e6397dc9178e247a03b06ff66c85ec 100644
--- a/chrome/browser/speech/speech_input_dispatcher_host.cc
+++ b/chrome/browser/speech/speech_input_dispatcher_host.cc
@@ -105,13 +105,21 @@ SpeechInputManager::AccessorMethod*
SpeechInputDispatcherHost::manager_accessor_ = &SpeechInputManager::Get;
SpeechInputDispatcherHost::SpeechInputDispatcherHost(int render_process_id)
- : render_process_id_(render_process_id) {
+ : render_process_id_(render_process_id),
+ may_have_pending_requests_(false) {
// This is initialized by Browser. Do not add any non-trivial
// initialization here, instead do it lazily when required (e.g. see the
// method |manager()|) or add an Init() method.
}
SpeechInputDispatcherHost::~SpeechInputDispatcherHost() {
+ // If the renderer crashed for some reason or if we didn't receive a proper
+ // Cancel/Stop call for an existing session, cancel such active sessions now.
+ // We first check if this dispatcher received any speech IPC requst so that
+ // we don't end up creating the speech input manager for web pages which don't
+ // use speech input.
+ if (may_have_pending_requests_)
+ manager()->CancelAllRequestsWithDelegate(this);
}
SpeechInputManager* SpeechInputDispatcherHost::manager() {
@@ -131,6 +139,7 @@ bool SpeechInputDispatcherHost::OnMessageReceived(
return true;
}
+ may_have_pending_requests_ = true;
IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message,
*message_was_ok)
IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition,
« no previous file with comments | « chrome/browser/speech/speech_input_dispatcher_host.h ('k') | chrome/browser/speech/speech_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698