Index: content/browser/speech/input_tag_speech_dispatcher_host.cc |
diff --git a/content/browser/speech/speech_input_dispatcher_host.cc b/content/browser/speech/input_tag_speech_dispatcher_host.cc |
similarity index 51% |
rename from content/browser/speech/speech_input_dispatcher_host.cc |
rename to content/browser/speech/input_tag_speech_dispatcher_host.cc |
index 38839690188fea0b2e5ca0fa494a14109b52a511..7c10270f61bb451e2858e2f9768acad1ba8c1f7a 100644 |
--- a/content/browser/speech/speech_input_dispatcher_host.cc |
+++ b/content/browser/speech/input_tag_speech_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/input_tag_speech_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 InputTagSpeechDispatcherHost::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,24 @@ 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<InputTagSpeechDispatcherHost::Callers> |
+ g_callers = LAZY_INSTANCE_INITIALIZER; |
-SpeechInputDispatcherHost::SpeechInputCallers::SpeechInputCallers() |
+InputTagSpeechDispatcherHost::Callers::Callers() |
: next_id_(1) { |
} |
-int SpeechInputDispatcherHost::SpeechInputCallers::GetId(int render_process_id, |
- int render_view_id, |
- int request_id) { |
+int InputTagSpeechDispatcherHost::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,10 +76,9 @@ int SpeechInputDispatcherHost::SpeechInputCallers::GetId(int render_process_id, |
return 0; |
} |
-int SpeechInputDispatcherHost::SpeechInputCallers::CreateId( |
- int render_process_id, |
- int render_view_id, |
- int request_id) { |
+int InputTagSpeechDispatcherHost::Callers::CreateId(int render_process_id, |
+ int render_view_id, |
+ int request_id) { |
CallerInfo info; |
info.render_process_id = render_process_id; |
info.render_view_id = render_view_id; |
@@ -88,46 +87,49 @@ int SpeechInputDispatcherHost::SpeechInputCallers::CreateId( |
return next_id_++; |
} |
-void SpeechInputDispatcherHost::SpeechInputCallers::RemoveId(int id) { |
+void InputTagSpeechDispatcherHost::Callers::RemoveId(int id) { |
callers_.erase(id); |
} |
-int SpeechInputDispatcherHost::SpeechInputCallers::render_process_id(int id) { |
+int InputTagSpeechDispatcherHost::Callers::render_process_id( |
+ int id) { |
return callers_[id].render_process_id; |
} |
-int SpeechInputDispatcherHost::SpeechInputCallers::render_view_id(int id) { |
+int InputTagSpeechDispatcherHost::Callers::render_view_id( |
+ int id) { |
return callers_[id].render_view_id; |
} |
-int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) { |
+int InputTagSpeechDispatcherHost::Callers::request_id(int id) { |
return callers_[id].request_id; |
} |
-//-------------------------- SpeechInputDispatcherHost ------------------------- |
+//----------------------- InputTagSpeechDispatcherHost ---------------------- |
-SpeechInputManagerImpl* SpeechInputDispatcherHost::manager_; |
+SpeechRecognitionManagerImpl* InputTagSpeechDispatcherHost::manager_; |
-void SpeechInputDispatcherHost::set_manager(SpeechInputManagerImpl* manager) { |
+void InputTagSpeechDispatcherHost::set_manager( |
+ SpeechRecognitionManagerImpl* manager) { |
manager_ = manager; |
} |
-SpeechInputDispatcherHost::SpeechInputDispatcherHost( |
+InputTagSpeechDispatcherHost::InputTagSpeechDispatcherHost( |
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() { |
+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 |
@@ -137,27 +139,27 @@ SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { |
manager()->CancelAllRequestsWithDelegate(this); |
} |
-SpeechInputManagerImpl* SpeechInputDispatcherHost::manager() { |
+SpeechRecognitionManagerImpl* InputTagSpeechDispatcherHost::manager() { |
if (manager_) |
return manager_; |
#if defined(ENABLE_INPUT_SPEECH) |
- return SpeechInputManagerImpl::GetInstance(); |
+ return SpeechRecognitionManagerImpl::GetInstance(); |
#else |
return NULL; |
#endif |
} |
-bool SpeechInputDispatcherHost::OnMessageReceived( |
+bool InputTagSpeechDispatcherHost::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(InputTagSpeechDispatcherHost, message, |
*message_was_ok) |
- IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StartRecognition, |
+ IPC_MESSAGE_HANDLER(InputTagSpeechHostMsg_StartRecognition, |
OnStartRecognition) |
- IPC_MESSAGE_HANDLER(SpeechInputHostMsg_CancelRecognition, |
+ IPC_MESSAGE_HANDLER(InputTagSpeechHostMsg_CancelRecognition, |
OnCancelRecognition) |
- IPC_MESSAGE_HANDLER(SpeechInputHostMsg_StopRecording, |
+ IPC_MESSAGE_HANDLER(InputTagSpeechHostMsg_StopRecording, |
OnStopRecording) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
@@ -166,10 +168,10 @@ bool SpeechInputDispatcherHost::OnMessageReceived( |
return handled; |
} |
-void SpeechInputDispatcherHost::OnStartRecognition( |
- const SpeechInputHostMsg_StartRecognition_Params ¶ms) { |
+void InputTagSpeechDispatcherHost::OnStartRecognition( |
+ const InputTagSpeechHostMsg_StartRecognition_Params ¶ms) { |
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 +179,61 @@ 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 InputTagSpeechDispatcherHost::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 InputTagSpeechDispatcherHost::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( |
- int caller_id, const content::SpeechInputResult& result) { |
- VLOG(1) << "SpeechInputDispatcherHost::SetRecognitionResult enter"; |
+void InputTagSpeechDispatcherHost::SetRecognitionResult( |
+ int caller_id, const content::SpeechRecognitionResult& result) { |
+ VLOG(1) << "InputTagSpeechDispatcherHost::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"; |
+ int caller_render_view_id = g_callers.Get().render_view_id(caller_id); |
+ int caller_request_id = g_callers.Get().request_id(caller_id); |
+ Send(new InputTagSpeechMsg_SetRecognitionResult(caller_render_view_id, |
+ caller_request_id, |
+ result)); |
+ VLOG(1) << "InputTagSpeechDispatcherHost::SetRecognitionResult exit"; |
} |
-void SpeechInputDispatcherHost::DidCompleteRecording(int caller_id) { |
- VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecording enter"; |
+void InputTagSpeechDispatcherHost::DidCompleteRecording(int caller_id) { |
+ VLOG(1) << "InputTagSpeechDispatcherHost::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"; |
+ int caller_render_view_id = g_callers.Get().render_view_id(caller_id); |
+ int caller_request_id = g_callers.Get().request_id(caller_id); |
+ Send(new InputTagSpeechMsg_RecordingComplete(caller_render_view_id, |
+ caller_request_id)); |
+ VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecording exit"; |
} |
-void SpeechInputDispatcherHost::DidCompleteRecognition(int caller_id) { |
- VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition enter"; |
+void InputTagSpeechDispatcherHost::DidCompleteRecognition(int caller_id) { |
+ VLOG(1) << "InputTagSpeechDispatcherHost::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 InputTagSpeechMsg_RecognitionComplete(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) << "InputTagSpeechDispatcherHost::DidCompleteRecognition exit"; |
} |
-} // namespace speech_input |
+} // namespace speech |