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

Unified Diff: content/browser/speech/input_tag_speech_dispatcher_host.cc

Issue 10273006: Introduced SpeechRecognitionDispatcher(Host) classes, handling dispatch of IPC messages for continu… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small fix (forgot break in switch) Created 8 years, 7 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: content/browser/speech/input_tag_speech_dispatcher_host.cc
diff --git a/content/browser/speech/input_tag_speech_dispatcher_host.cc b/content/browser/speech/input_tag_speech_dispatcher_host.cc
index 0fa54be0a6b808ac8e01fdf41bddc3263fcc9633..3f3941884493e253e3e8946c8f1f77c0298cdfcc 100644
--- a/content/browser/speech/input_tag_speech_dispatcher_host.cc
+++ b/content/browser/speech/input_tag_speech_dispatcher_host.cc
@@ -6,9 +6,8 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
-#include "content/browser/speech/speech_recognition_manager_impl.h"
-#include "content/browser/speech/speech_recognizer_impl.h"
#include "content/common/speech_recognition_messages.h"
+#include "content/public/browser/speech_recognition_manager.h"
#include "content/public/browser/speech_recognition_preferences.h"
#include "content/public/browser/speech_recognition_session_config.h"
#include "content/public/browser/speech_recognition_session_context.h"
@@ -42,32 +41,21 @@ InputTagSpeechDispatcherHost::InputTagSpeechDispatcherHost(
net::URLRequestContextGetter* url_request_context_getter,
content::SpeechRecognitionPreferences* recognition_preferences)
: render_process_id_(render_process_id),
- may_have_pending_requests_(false),
url_request_context_getter_(url_request_context_getter),
recognition_preferences_(recognition_preferences) {
- // 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.
+ // 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.
}
InputTagSpeechDispatcherHost::~InputTagSpeechDispatcherHost() {
- // 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()->AbortAllSessionsForListener(this);
+ if (SpeechRecognitionManager* sr_manager = manager())
+ sr_manager->AbortAllSessionsForListener(this);
}
SpeechRecognitionManager* InputTagSpeechDispatcherHost::manager() {
if (manager_for_tests_)
return manager_for_tests_;
-#if defined(ENABLE_INPUT_SPEECH)
return SpeechRecognitionManager::GetInstance();
-#else
- return NULL;
-#endif
}
bool InputTagSpeechDispatcherHost::OnMessageReceived(
@@ -84,13 +72,11 @@ bool InputTagSpeechDispatcherHost::OnMessageReceived(
OnStopRecording)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
- if (handled)
- may_have_pending_requests_ = true;
return handled;
}
void InputTagSpeechDispatcherHost::OnStartRecognition(
- const InputTagSpeechHostMsg_StartRecognition_Params &params) {
+ const InputTagSpeechHostMsg_StartRecognition_Params& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
SpeechRecognitionSessionContext context;
@@ -112,10 +98,8 @@ void InputTagSpeechDispatcherHost::OnStartRecognition(
config.event_listener = this;
int session_id = manager()->CreateSession(config);
- if (session_id == SpeechRecognitionManager::kSessionIDInvalid)
- return;
-
- manager()->StartSession(session_id);
+ DCHECK_NE(session_id, content::SpeechRecognitionManager::kSessionIDInvalid);
+ manager()->StartSession(session_id);
}
void InputTagSpeechDispatcherHost::OnCancelRecognition(int render_view_id,

Powered by Google App Engine
This is Rietveld 408576698