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

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

Issue 9568002: Renamed speech input implementation from to speech_recognition_*. The namespace has been renamed fr… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 10 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/speech_recognition_dispatcher_host.cc
diff --git a/content/browser/speech/speech_input_dispatcher_host.cc b/content/browser/speech/speech_recognition_dispatcher_host.cc
similarity index 53%
rename from content/browser/speech/speech_input_dispatcher_host.cc
rename to content/browser/speech/speech_recognition_dispatcher_host.cc
index 38839690188fea0b2e5ca0fa494a14109b52a511..ae2cb174a7d53467c7e6d204f7a3183091c32acc 100644
--- a/content/browser/speech/speech_input_dispatcher_host.cc
+++ b/content/browser/speech/speech_recognition_dispatcher_host.cc
@@ -2,24 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/speech/speech_input_dispatcher_host.h"
+#include "content/browser/speech/speech_recognition_dispatcher_host.h"
#include "base/lazy_instance.h"
-#include "content/browser/speech/speech_input_manager_impl.h"
+#include "content/browser/speech/speech_recognition_manager_impl.h"
#include "content/browser/speech/speech_recognizer_impl.h"
-#include "content/common/speech_input_messages.h"
-#include "content/public/browser/speech_input_preferences.h"
+#include "content/common/speech_recognition_messages.h"
+#include "content/public/browser/speech_recognition_preferences.h"
using content::BrowserThread;
-namespace speech_input {
+namespace speech {
-//----------------------------- SpeechInputCallers -----------------------------
+//----------------------------- Callers -----------------------------
// A singleton class to map the tuple
// (render-process-id, render-view-id, requestid) to a single ID which is passed
// through rest of the speech code.
-class SpeechInputDispatcherHost::SpeechInputCallers {
+class SpeechRecognitionDispatcherHost::Callers {
public:
// Creates a new ID for a given tuple.
int CreateId(int render_process_id, int render_view_id, int request_id);
@@ -41,24 +41,25 @@ class SpeechInputDispatcherHost::SpeechInputCallers {
int render_view_id;
int request_id;
};
- friend struct base::DefaultLazyInstanceTraits<SpeechInputCallers>;
+ friend struct base::DefaultLazyInstanceTraits<Callers>;
- SpeechInputCallers();
+ Callers();
std::map<int, CallerInfo> callers_;
int next_id_;
};
-static base::LazyInstance<SpeechInputDispatcherHost::SpeechInputCallers>
- g_speech_input_callers = LAZY_INSTANCE_INITIALIZER;
+static base::LazyInstance<SpeechRecognitionDispatcherHost::Callers>
+ g_callers = LAZY_INSTANCE_INITIALIZER;
-SpeechInputDispatcherHost::SpeechInputCallers::SpeechInputCallers()
+SpeechRecognitionDispatcherHost::Callers::Callers()
: next_id_(1) {
}
-int SpeechInputDispatcherHost::SpeechInputCallers::GetId(int render_process_id,
- int render_view_id,
- int request_id) {
+int SpeechRecognitionDispatcherHost::Callers::GetId(
+ int render_process_id,
+ int render_view_id,
+ int request_id) {
for (std::map<int, CallerInfo>::iterator it = callers_.begin();
it != callers_.end(); it++) {
const CallerInfo& item = it->second;
@@ -76,7 +77,7 @@ int SpeechInputDispatcherHost::SpeechInputCallers::GetId(int render_process_id,
return 0;
}
-int SpeechInputDispatcherHost::SpeechInputCallers::CreateId(
+int SpeechRecognitionDispatcherHost::Callers::CreateId(
int render_process_id,
int render_view_id,
int request_id) {
@@ -88,46 +89,49 @@ int SpeechInputDispatcherHost::SpeechInputCallers::CreateId(
return next_id_++;
}
-void SpeechInputDispatcherHost::SpeechInputCallers::RemoveId(int id) {
+void SpeechRecognitionDispatcherHost::Callers::RemoveId(int id) {
callers_.erase(id);
}
-int SpeechInputDispatcherHost::SpeechInputCallers::render_process_id(int id) {
+int SpeechRecognitionDispatcherHost::Callers::render_process_id(
+ int id) {
return callers_[id].render_process_id;
}
-int SpeechInputDispatcherHost::SpeechInputCallers::render_view_id(int id) {
+int SpeechRecognitionDispatcherHost::Callers::render_view_id(
+ int id) {
return callers_[id].render_view_id;
}
-int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) {
+int SpeechRecognitionDispatcherHost::Callers::request_id(int id) {
return callers_[id].request_id;
}
-//-------------------------- SpeechInputDispatcherHost -------------------------
+//----------------------- SpeechRecognitionDispatcherHost ----------------------
-SpeechInputManagerImpl* SpeechInputDispatcherHost::manager_;
+SpeechRecognitionManagerImpl* SpeechRecognitionDispatcherHost::manager_;
-void SpeechInputDispatcherHost::set_manager(SpeechInputManagerImpl* manager) {
+void SpeechRecognitionDispatcherHost::set_manager(
+ SpeechRecognitionManagerImpl* manager) {
manager_ = manager;
}
-SpeechInputDispatcherHost::SpeechInputDispatcherHost(
+SpeechRecognitionDispatcherHost::SpeechRecognitionDispatcherHost(
int render_process_id,
net::URLRequestContextGetter* context_getter,
- content::SpeechInputPreferences* speech_input_preferences,
+ content::SpeechRecognitionPreferences* recognition_preferences,
AudioManager* audio_manager)
: render_process_id_(render_process_id),
may_have_pending_requests_(false),
context_getter_(context_getter),
- speech_input_preferences_(speech_input_preferences),
+ recognition_preferences_(recognition_preferences),
audio_manager_(audio_manager) {
// 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() {
+SpeechRecognitionDispatcherHost::~SpeechRecognitionDispatcherHost() {
// 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
@@ -137,27 +141,27 @@ SpeechInputDispatcherHost::~SpeechInputDispatcherHost() {
manager()->CancelAllRequestsWithDelegate(this);
}
-SpeechInputManagerImpl* SpeechInputDispatcherHost::manager() {
+SpeechRecognitionManagerImpl* SpeechRecognitionDispatcherHost::manager() {
if (manager_)
return manager_;
#if defined(ENABLE_INPUT_SPEECH)
- return SpeechInputManagerImpl::GetInstance();
+ return SpeechRecognitionManagerImpl::GetInstance();
#else
return NULL;
#endif
}
-bool SpeechInputDispatcherHost::OnMessageReceived(
+bool SpeechRecognitionDispatcherHost::OnMessageReceived(
const IPC::Message& message, bool* message_was_ok) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message,
+ IPC_BEGIN_MESSAGE_MAP_EX(SpeechRecognitionDispatcherHost, message,
*message_was_ok)
- IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition,
+ IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StartRequest,
OnStartRecognition)
- IPC_MESSAGE_HANDLER(SpeechInputHostMsg_CancelRecognition,
+ IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortRequest,
OnCancelRecognition)
- IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StopRecording,
+ IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StopAudioCaptureRequest,
OnStopRecording)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -166,10 +170,10 @@ bool SpeechInputDispatcherHost::OnMessageReceived(
return handled;
}
-void SpeechInputDispatcherHost::OnStartRecognition(
- const SpeechInputHostMsg_StartRecognition_Params &params) {
+void SpeechRecognitionDispatcherHost::OnStartRecognition(
+ const SpeechRecognitionHostMsg_StartRequest_Params &params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- int caller_id = g_speech_input_callers.Get().CreateId(
+ int caller_id = g_callers.Get().CreateId(
render_process_id_, params.render_view_id, params.request_id);
manager()->StartRecognition(this, caller_id,
render_process_id_,
@@ -177,63 +181,63 @@ void SpeechInputDispatcherHost::OnStartRecognition(
params.language, params.grammar,
params.origin_url,
context_getter_.get(),
- speech_input_preferences_.get());
+ recognition_preferences_.get());
}
-void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id,
- int request_id) {
- int caller_id = g_speech_input_callers.Get().GetId(
+void SpeechRecognitionDispatcherHost::OnCancelRecognition(int render_view_id,
+ int request_id) {
+ int caller_id = g_callers.Get().GetId(
render_process_id_, render_view_id, request_id);
if (caller_id) {
manager()->CancelRecognition(caller_id);
// Request sequence ended so remove mapping.
- g_speech_input_callers.Get().RemoveId(caller_id);
+ g_callers.Get().RemoveId(caller_id);
}
}
-void SpeechInputDispatcherHost::OnStopRecording(int render_view_id,
- int request_id) {
- int caller_id = g_speech_input_callers.Get().GetId(
+void SpeechRecognitionDispatcherHost::OnStopRecording(int render_view_id,
+ int request_id) {
+ int caller_id = g_callers.Get().GetId(
render_process_id_, render_view_id, request_id);
if (caller_id)
manager()->StopRecording(caller_id);
}
-void SpeechInputDispatcherHost::SetRecognitionResult(
+void SpeechRecognitionDispatcherHost::SetRecognitionResult(
int caller_id, const content::SpeechInputResult& result) {
- VLOG(1) << "SpeechInputDispatcherHost::SetRecognitionResult enter";
+ VLOG(1) << "SpeechRecognitionDispatcherHost::SetRecognitionResult enter";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
int caller_render_view_id =
- g_speech_input_callers.Get().render_view_id(caller_id);
- int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
- Send(new SpeechInputMsg_SetRecognitionResult(caller_render_view_id,
- caller_request_id,
- result));
- VLOG(1) << "SpeechInputDispatcherHost::SetRecognitionResult exit";
+ g_callers.Get().render_view_id(caller_id);
+ int caller_request_id = g_callers.Get().request_id(caller_id);
+ Send(new SpeechRecognitionMsg_ResultRetrieved(caller_render_view_id,
+ caller_request_id,
+ result));
+ VLOG(1) << "SpeechRecognitionDispatcherHost::SetRecognitionResult exit";
}
-void SpeechInputDispatcherHost::DidCompleteRecording(int caller_id) {
- VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecording enter";
+void SpeechRecognitionDispatcherHost::DidCompleteRecording(int caller_id) {
+ VLOG(1) << "SpeechRecognitionDispatcherHost::DidCompleteRecording enter";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
int caller_render_view_id =
- g_speech_input_callers.Get().render_view_id(caller_id);
- int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
- Send(new SpeechInputMsg_RecordingComplete(caller_render_view_id,
- caller_request_id));
- VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecording exit";
+ g_callers.Get().render_view_id(caller_id);
+ int caller_request_id = g_callers.Get().request_id(caller_id);
+ Send(new SpeechRecognitionMsg_AudioEnded(caller_render_view_id,
+ caller_request_id));
+ VLOG(1) << "SpeechRecognitionDispatcherHost::DidCompleteRecording exit";
}
-void SpeechInputDispatcherHost::DidCompleteRecognition(int caller_id) {
- VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition enter";
+void SpeechRecognitionDispatcherHost::DidCompleteRecognition(int caller_id) {
+ VLOG(1) << "SpeechRecognitionDispatcherHost::DidCompleteRecognition enter";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
int caller_render_view_id =
- g_speech_input_callers.Get().render_view_id(caller_id);
- int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
- Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id,
- caller_request_id));
+ g_callers.Get().render_view_id(caller_id);
+ int caller_request_id = g_callers.Get().request_id(caller_id);
+ Send(new SpeechRecognitionMsg_RecognitionEnded(caller_render_view_id,
+ caller_request_id));
// Request sequence ended, so remove mapping.
- g_speech_input_callers.Get().RemoveId(caller_id);
- VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit";
+ g_callers.Get().RemoveId(caller_id);
+ VLOG(1) << "SpeechRecognitionDispatcherHost::DidCompleteRecognition exit";
}
-} // namespace speech_input
+} // namespace speech

Powered by Google App Engine
This is Rietveld 408576698