summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc3
-rw-r--r--content/browser/speech/input_tag_speech_dispatcher_host.cc110
-rw-r--r--content/browser/speech/input_tag_speech_dispatcher_host.h12
-rw-r--r--content/browser/speech/speech_recognition_browsertest.cc30
-rw-r--r--content/browser/speech/speech_recognition_manager_impl.cc178
-rw-r--r--content/browser/speech/speech_recognition_manager_impl.h40
-rw-r--r--content/browser/speech/speech_recognizer_impl.cc38
-rw-r--r--content/browser/speech/speech_recognizer_impl.h8
-rw-r--r--content/browser/speech/speech_recognizer_impl_unittest.cc20
-rw-r--r--content/public/browser/speech_recognition_event_listener.h22
-rw-r--r--content/public/browser/speech_recognition_manager.h6
-rw-r--r--content/public/browser/speech_recognition_manager_delegate.h16
-rw-r--r--content/public/browser/speech_recognizer.h6
13 files changed, 243 insertions, 246 deletions
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 5cef5da..2f26a73 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -500,8 +500,7 @@ void RenderProcessHostImpl::CreateMessageFilters() {
#if defined(ENABLE_INPUT_SPEECH)
channel_->AddFilter(new speech::InputTagSpeechDispatcherHost(
GetID(), browser_context->GetRequestContext(),
- browser_context->GetSpeechRecognitionPreferences(),
- content::BrowserMainLoop::GetAudioManager()));
+ browser_context->GetSpeechRecognitionPreferences()));
#endif
channel_->AddFilter(new FileAPIMessageFilter(
GetID(),
diff --git a/content/browser/speech/input_tag_speech_dispatcher_host.cc b/content/browser/speech/input_tag_speech_dispatcher_host.cc
index 6ec3be0..29eebb64 100644
--- a/content/browser/speech/input_tag_speech_dispatcher_host.cc
+++ b/content/browser/speech/input_tag_speech_dispatcher_host.cc
@@ -14,12 +14,16 @@ using content::BrowserThread;
namespace speech {
-//----------------------------- Callers -----------------------------
+//----------------------------- Sessions -----------------------------
+
+// TODO(primiano) Remove session handling from here in the next CL. The manager
+// shall be the only one in charge of keeping all the context information for
+// all recognition sessions.
// 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 InputTagSpeechDispatcherHost::Callers {
+class InputTagSpeechDispatcherHost::Sessions {
public:
// Creates a new ID for a given tuple.
int CreateId(int render_process_id, int render_view_id, int request_id);
@@ -36,32 +40,32 @@ class InputTagSpeechDispatcherHost::Callers {
int request_id(int id);
private:
- struct CallerInfo {
+ struct SessionInfo {
int render_process_id;
int render_view_id;
int request_id;
};
- friend struct base::DefaultLazyInstanceTraits<Callers>;
+ friend struct base::DefaultLazyInstanceTraits<Sessions>;
- Callers();
+ Sessions();
- std::map<int, CallerInfo> callers_;
+ std::map<int, SessionInfo> sessions_;
int next_id_;
};
-static base::LazyInstance<InputTagSpeechDispatcherHost::Callers>
- g_callers = LAZY_INSTANCE_INITIALIZER;
+static base::LazyInstance<InputTagSpeechDispatcherHost::Sessions>
+ g_sessions = LAZY_INSTANCE_INITIALIZER;
-InputTagSpeechDispatcherHost::Callers::Callers()
+InputTagSpeechDispatcherHost::Sessions::Sessions()
: next_id_(1) {
}
-int InputTagSpeechDispatcherHost::Callers::GetId(int render_process_id,
+int InputTagSpeechDispatcherHost::Sessions::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;
+ for (std::map<int, SessionInfo>::iterator it = sessions_.begin();
+ it != sessions_.end(); it++) {
+ const SessionInfo& item = it->second;
if (item.render_process_id == render_process_id &&
item.render_view_id == render_view_id &&
item.request_id == request_id) {
@@ -76,33 +80,33 @@ int InputTagSpeechDispatcherHost::Callers::GetId(int render_process_id,
return 0;
}
-int InputTagSpeechDispatcherHost::Callers::CreateId(int render_process_id,
+int InputTagSpeechDispatcherHost::Sessions::CreateId(int render_process_id,
int render_view_id,
int request_id) {
- CallerInfo info;
+ SessionInfo info;
info.render_process_id = render_process_id;
info.render_view_id = render_view_id;
info.request_id = request_id;
- callers_[next_id_] = info;
+ sessions_[next_id_] = info;
return next_id_++;
}
-void InputTagSpeechDispatcherHost::Callers::RemoveId(int id) {
- callers_.erase(id);
+void InputTagSpeechDispatcherHost::Sessions::RemoveId(int id) {
+ sessions_.erase(id);
}
-int InputTagSpeechDispatcherHost::Callers::render_process_id(
+int InputTagSpeechDispatcherHost::Sessions::render_process_id(
int id) {
- return callers_[id].render_process_id;
+ return sessions_[id].render_process_id;
}
-int InputTagSpeechDispatcherHost::Callers::render_view_id(
+int InputTagSpeechDispatcherHost::Sessions::render_view_id(
int id) {
- return callers_[id].render_view_id;
+ return sessions_[id].render_view_id;
}
-int InputTagSpeechDispatcherHost::Callers::request_id(int id) {
- return callers_[id].request_id;
+int InputTagSpeechDispatcherHost::Sessions::request_id(int id) {
+ return sessions_[id].request_id;
}
//----------------------- InputTagSpeechDispatcherHost ----------------------
@@ -117,13 +121,11 @@ void InputTagSpeechDispatcherHost::set_manager(
InputTagSpeechDispatcherHost::InputTagSpeechDispatcherHost(
int render_process_id,
net::URLRequestContextGetter* context_getter,
- content::SpeechRecognitionPreferences* recognition_preferences,
- media::AudioManager* audio_manager)
+ content::SpeechRecognitionPreferences* recognition_preferences)
: render_process_id_(render_process_id),
may_have_pending_requests_(false),
context_getter_(context_getter),
- recognition_preferences_(recognition_preferences),
- audio_manager_(audio_manager) {
+ 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.
@@ -171,9 +173,9 @@ bool InputTagSpeechDispatcherHost::OnMessageReceived(
void InputTagSpeechDispatcherHost::OnStartRecognition(
const InputTagSpeechHostMsg_StartRecognition_Params &params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- int caller_id = g_callers.Get().CreateId(
+ int session_id = g_sessions.Get().CreateId(
render_process_id_, params.render_view_id, params.request_id);
- manager()->StartRecognition(this, caller_id,
+ manager()->StartRecognition(this, session_id,
render_process_id_,
params.render_view_id, params.element_rect,
params.language, params.grammar,
@@ -184,55 +186,55 @@ void InputTagSpeechDispatcherHost::OnStartRecognition(
void InputTagSpeechDispatcherHost::OnCancelRecognition(int render_view_id,
int request_id) {
- int caller_id = g_callers.Get().GetId(
+ int session_id = g_sessions.Get().GetId(
render_process_id_, render_view_id, request_id);
- if (caller_id) {
- manager()->CancelRecognition(caller_id);
+ if (session_id) {
+ manager()->CancelRecognition(session_id);
// Request sequence ended so remove mapping.
- g_callers.Get().RemoveId(caller_id);
+ g_sessions.Get().RemoveId(session_id);
}
}
void InputTagSpeechDispatcherHost::OnStopRecording(int render_view_id,
int request_id) {
- int caller_id = g_callers.Get().GetId(
+ int session_id = g_sessions.Get().GetId(
render_process_id_, render_view_id, request_id);
- if (caller_id)
- manager()->StopRecording(caller_id);
+ if (session_id)
+ manager()->StopRecording(session_id);
}
void InputTagSpeechDispatcherHost::SetRecognitionResult(
- int caller_id, const content::SpeechRecognitionResult& result) {
+ int session_id, const content::SpeechRecognitionResult& result) {
VLOG(1) << "InputTagSpeechDispatcherHost::SetRecognitionResult enter";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- 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,
+ int session_render_view_id = g_sessions.Get().render_view_id(session_id);
+ int session_request_id = g_sessions.Get().request_id(session_id);
+ Send(new InputTagSpeechMsg_SetRecognitionResult(session_render_view_id,
+ session_request_id,
result));
VLOG(1) << "InputTagSpeechDispatcherHost::SetRecognitionResult exit";
}
-void InputTagSpeechDispatcherHost::DidCompleteRecording(int caller_id) {
+void InputTagSpeechDispatcherHost::DidCompleteRecording(int session_id) {
VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecording enter";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- 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));
+ int session_render_view_id = g_sessions.Get().render_view_id(session_id);
+ int session_request_id = g_sessions.Get().request_id(session_id);
+ Send(new InputTagSpeechMsg_RecordingComplete(session_render_view_id,
+ session_request_id));
VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecording exit";
}
-void InputTagSpeechDispatcherHost::DidCompleteRecognition(int caller_id) {
+void InputTagSpeechDispatcherHost::DidCompleteRecognition(int session_id) {
VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecognition enter";
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- 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_RecognitionComplete(caller_render_view_id,
- caller_request_id));
+ int session_render_view_id =
+ g_sessions.Get().render_view_id(session_id);
+ int session_request_id = g_sessions.Get().request_id(session_id);
+ Send(new InputTagSpeechMsg_RecognitionComplete(session_render_view_id,
+ session_request_id));
// Request sequence ended, so remove mapping.
- g_callers.Get().RemoveId(caller_id);
+ g_sessions.Get().RemoveId(session_id);
VLOG(1) << "InputTagSpeechDispatcherHost::DidCompleteRecognition exit";
}
diff --git a/content/browser/speech/input_tag_speech_dispatcher_host.h b/content/browser/speech/input_tag_speech_dispatcher_host.h
index c988faf..95bd252 100644
--- a/content/browser/speech/input_tag_speech_dispatcher_host.h
+++ b/content/browser/speech/input_tag_speech_dispatcher_host.h
@@ -31,19 +31,18 @@ class SpeechRecognitionManagerImpl;
class CONTENT_EXPORT InputTagSpeechDispatcherHost
: public content::BrowserMessageFilter {
public:
- class Callers;
+ class Sessions;
InputTagSpeechDispatcherHost(
int render_process_id,
net::URLRequestContextGetter* context_getter,
- content::SpeechRecognitionPreferences* recognition_preferences,
- media::AudioManager* audio_manager);
+ content::SpeechRecognitionPreferences* recognition_preferences);
// Methods called by SpeechRecognitionManagerImpl.
- void SetRecognitionResult(int caller_id,
+ void SetRecognitionResult(int session_id,
const content::SpeechRecognitionResult& result);
- void DidCompleteRecording(int caller_id);
- void DidCompleteRecognition(int caller_id);
+ void DidCompleteRecording(int session_id);
+ void DidCompleteRecognition(int session_id);
// content::BrowserMessageFilter implementation.
virtual bool OnMessageReceived(const IPC::Message& message,
@@ -69,7 +68,6 @@ class CONTENT_EXPORT InputTagSpeechDispatcherHost
scoped_refptr<net::URLRequestContextGetter> context_getter_;
scoped_refptr<content::SpeechRecognitionPreferences> recognition_preferences_;
- media::AudioManager* audio_manager_;
static SpeechRecognitionManagerImpl* manager_;
diff --git a/content/browser/speech/speech_recognition_browsertest.cc b/content/browser/speech/speech_recognition_browsertest.cc
index 70dcc6f..ea8f95e 100644
--- a/content/browser/speech/speech_recognition_browsertest.cc
+++ b/content/browser/speech/speech_recognition_browsertest.cc
@@ -35,7 +35,7 @@ const char kTestResult[] = "Pictures of the moon";
class FakeSpeechRecognitionManager : public SpeechRecognitionManagerImpl {
public:
FakeSpeechRecognitionManager()
- : caller_id_(0),
+ : session_id_(0),
delegate_(NULL),
did_cancel_all_(false),
should_send_fake_response_(true),
@@ -65,7 +65,7 @@ class FakeSpeechRecognitionManager : public SpeechRecognitionManagerImpl {
// SpeechRecognitionManager methods.
virtual void StartRecognition(
InputTagSpeechDispatcherHost* delegate,
- int caller_id,
+ int session_id,
int render_process_id,
int render_view_id,
const gfx::Rect& element_rect,
@@ -75,9 +75,9 @@ class FakeSpeechRecognitionManager : public SpeechRecognitionManagerImpl {
net::URLRequestContextGetter* context_getter,
content::SpeechRecognitionPreferences* recognition_prefs) OVERRIDE {
VLOG(1) << "StartRecognition invoked.";
- EXPECT_EQ(0, caller_id_);
+ EXPECT_EQ(0, session_id_);
EXPECT_EQ(NULL, delegate_);
- caller_id_ = caller_id;
+ session_id_ = session_id;
delegate_ = delegate;
grammar_ = grammar;
if (should_send_fake_response_) {
@@ -93,15 +93,15 @@ class FakeSpeechRecognitionManager : public SpeechRecognitionManagerImpl {
}
recognition_started_event_.Signal();
}
- virtual void CancelRecognition(int caller_id) OVERRIDE {
+ virtual void CancelRecognition(int session_id) OVERRIDE {
VLOG(1) << "CancelRecognition invoked.";
- EXPECT_EQ(caller_id_, caller_id);
- caller_id_ = 0;
+ EXPECT_EQ(session_id_, session_id);
+ session_id_ = 0;
delegate_ = NULL;
}
- virtual void StopRecording(int caller_id) OVERRIDE {
+ virtual void StopRecording(int session_id) OVERRIDE {
VLOG(1) << "StopRecording invoked.";
- EXPECT_EQ(caller_id_, caller_id);
+ EXPECT_EQ(session_id_, session_id);
// Nothing to do here since we aren't really recording.
}
virtual void CancelAllRequestsWithDelegate(
@@ -116,21 +116,21 @@ class FakeSpeechRecognitionManager : public SpeechRecognitionManagerImpl {
private:
void SetFakeRecognitionResult() {
- if (caller_id_) { // Do a check in case we were cancelled..
+ if (session_id_) { // Do a check in case we were cancelled..
VLOG(1) << "Setting fake recognition result.";
- delegate_->DidCompleteRecording(caller_id_);
+ delegate_->DidCompleteRecording(session_id_);
content::SpeechRecognitionResult results;
results.hypotheses.push_back(content::SpeechRecognitionHypothesis(
ASCIIToUTF16(kTestResult), 1.0));
- delegate_->SetRecognitionResult(caller_id_, results);
- delegate_->DidCompleteRecognition(caller_id_);
- caller_id_ = 0;
+ delegate_->SetRecognitionResult(session_id_, results);
+ delegate_->DidCompleteRecognition(session_id_);
+ session_id_ = 0;
delegate_ = NULL;
VLOG(1) << "Finished setting fake recognition result.";
}
}
- int caller_id_;
+ int session_id_;
InputTagSpeechDispatcherHost* delegate_;
std::string grammar_;
bool did_cancel_all_;
diff --git a/content/browser/speech/speech_recognition_manager_impl.cc b/content/browser/speech/speech_recognition_manager_impl.cc
index ddd373a..ed567e1 100644
--- a/content/browser/speech/speech_recognition_manager_impl.cc
+++ b/content/browser/speech/speech_recognition_manager_impl.cc
@@ -33,7 +33,7 @@ namespace speech {
struct SpeechRecognitionManagerImpl::SpeechRecognitionParams {
SpeechRecognitionParams(
InputTagSpeechDispatcherHost* delegate,
- int caller_id,
+ int session_id,
int render_process_id,
int render_view_id,
const gfx::Rect& element_rect,
@@ -43,7 +43,7 @@ struct SpeechRecognitionManagerImpl::SpeechRecognitionParams {
net::URLRequestContextGetter* context_getter,
content::SpeechRecognitionPreferences* recognition_prefs)
: delegate(delegate),
- caller_id(caller_id),
+ session_id(session_id),
render_process_id(render_process_id),
render_view_id(render_view_id),
element_rect(element_rect),
@@ -55,7 +55,7 @@ struct SpeechRecognitionManagerImpl::SpeechRecognitionParams {
}
InputTagSpeechDispatcherHost* delegate;
- int caller_id;
+ int session_id;
int render_process_id;
int render_view_id;
gfx::Rect element_rect;
@@ -72,7 +72,7 @@ SpeechRecognitionManagerImpl* SpeechRecognitionManagerImpl::GetInstance() {
SpeechRecognitionManagerImpl::SpeechRecognitionManagerImpl()
: can_report_metrics_(false),
- recording_caller_id_(0) {
+ recording_session_id_(0) {
delegate_.reset(content::GetContentClient()->browser()->
GetSpeechRecognitionManagerDelegate());
}
@@ -94,13 +94,13 @@ string16 SpeechRecognitionManagerImpl::GetAudioInputDeviceModel() {
return BrowserMainLoop::GetAudioManager()->GetAudioInputDeviceModel();
}
-bool SpeechRecognitionManagerImpl::HasPendingRequest(int caller_id) const {
- return requests_.find(caller_id) != requests_.end();
+bool SpeechRecognitionManagerImpl::HasPendingRequest(int session_id) const {
+ return requests_.find(session_id) != requests_.end();
}
InputTagSpeechDispatcherHost* SpeechRecognitionManagerImpl::GetDelegate(
- int caller_id) const {
- return requests_.find(caller_id)->second.delegate;
+ int session_id) const {
+ return requests_.find(session_id)->second.delegate;
}
void SpeechRecognitionManagerImpl::ShowAudioInputSettings() {
@@ -122,7 +122,7 @@ void SpeechRecognitionManagerImpl::ShowAudioInputSettings() {
void SpeechRecognitionManagerImpl::StartRecognition(
InputTagSpeechDispatcherHost* delegate,
- int caller_id,
+ int session_id,
int render_process_id,
int render_view_id,
const gfx::Rect& element_rect,
@@ -138,7 +138,7 @@ void SpeechRecognitionManagerImpl::StartRecognition(
&SpeechRecognitionManagerImpl::CheckRenderViewTypeAndStartRecognition,
base::Unretained(this),
SpeechRecognitionParams(
- delegate, caller_id, render_process_id, render_view_id,
+ delegate, session_id, render_process_id, render_view_id,
element_rect, language, grammar, origin_url, context_getter,
recognition_prefs)));
}
@@ -170,78 +170,78 @@ void SpeechRecognitionManagerImpl::CheckRenderViewTypeAndStartRecognition(
void SpeechRecognitionManagerImpl::ProceedStartingRecognition(
const SpeechRecognitionParams& params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(!HasPendingRequest(params.caller_id));
+ DCHECK(!HasPendingRequest(params.session_id));
if (delegate_.get()) {
delegate_->ShowRecognitionRequested(
- params.caller_id, params.render_process_id, params.render_view_id,
+ params.session_id, params.render_process_id, params.render_view_id,
params.element_rect);
delegate_->GetRequestInfo(&can_report_metrics_, &request_info_);
}
- Request* request = &requests_[params.caller_id];
+ Request* request = &requests_[params.session_id];
request->delegate = params.delegate;
request->recognizer = content::SpeechRecognizer::Create(
- this, params.caller_id, params.language, params.grammar,
+ this, params.session_id, params.language, params.grammar,
params.context_getter, params.recognition_prefs->FilterProfanities(),
request_info_, can_report_metrics_ ? params.origin_url : "");
request->is_active = false;
- StartRecognitionForRequest(params.caller_id);
+ StartRecognitionForRequest(params.session_id);
}
-void SpeechRecognitionManagerImpl::StartRecognitionForRequest(int caller_id) {
- SpeechRecognizerMap::iterator request = requests_.find(caller_id);
+void SpeechRecognitionManagerImpl::StartRecognitionForRequest(int session_id) {
+ SpeechRecognizerMap::iterator request = requests_.find(session_id);
if (request == requests_.end()) {
NOTREACHED();
return;
}
- // We should not currently be recording for the caller.
- CHECK(recording_caller_id_ != caller_id);
+ // We should not currently be recording for the session.
+ CHECK(recording_session_id_ != session_id);
- // If we are currently recording audio for another caller, abort that cleanly.
- if (recording_caller_id_)
- CancelRecognitionAndInformDelegate(recording_caller_id_);
- recording_caller_id_ = caller_id;
- requests_[caller_id].is_active = true;
- requests_[caller_id].recognizer->StartRecognition();
+ // If we are currently recording audio for another session, abort it cleanly.
+ if (recording_session_id_)
+ CancelRecognitionAndInformDelegate(recording_session_id_);
+ recording_session_id_ = session_id;
+ requests_[session_id].is_active = true;
+ requests_[session_id].recognizer->StartRecognition();
if (delegate_.get())
- delegate_->ShowWarmUp(caller_id);
+ delegate_->ShowWarmUp(session_id);
}
-void SpeechRecognitionManagerImpl::CancelRecognitionForRequest(int caller_id) {
- // Ignore if the caller id was not in our active recognizers list because the
+void SpeechRecognitionManagerImpl::CancelRecognitionForRequest(int session_id) {
+ // Ignore if the session id was not in our active recognizers list because the
// user might have clicked more than once, or recognition could have been
// ended due to other reasons before the user click was processed.
- if (!HasPendingRequest(caller_id))
+ if (!HasPendingRequest(session_id))
return;
- CancelRecognitionAndInformDelegate(caller_id);
+ CancelRecognitionAndInformDelegate(session_id);
}
-void SpeechRecognitionManagerImpl::FocusLostForRequest(int caller_id) {
+void SpeechRecognitionManagerImpl::FocusLostForRequest(int session_id) {
// See above comment.
- if (!HasPendingRequest(caller_id))
+ if (!HasPendingRequest(session_id))
return;
// If this is an ongoing recording or if we were displaying an error message
// to the user, abort it since user has switched focus. Otherwise
// recognition has started and keep that going so user can start speaking to
// another element while this gets the results in parallel.
- if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active)
- CancelRecognitionAndInformDelegate(caller_id);
+ if (recording_session_id_ == session_id || !requests_[session_id].is_active)
+ CancelRecognitionAndInformDelegate(session_id);
}
-void SpeechRecognitionManagerImpl::CancelRecognition(int caller_id) {
- DCHECK(HasPendingRequest(caller_id));
- if (requests_[caller_id].is_active)
- requests_[caller_id].recognizer->AbortRecognition();
- requests_.erase(caller_id);
- if (recording_caller_id_ == caller_id)
- recording_caller_id_ = 0;
+void SpeechRecognitionManagerImpl::CancelRecognition(int session_id) {
+ DCHECK(HasPendingRequest(session_id));
+ if (requests_[session_id].is_active)
+ requests_[session_id].recognizer->AbortRecognition();
+ requests_.erase(session_id);
+ if (recording_session_id_ == session_id)
+ recording_session_id_ = 0;
if (delegate_.get())
- delegate_->DoClose(caller_id);
+ delegate_->DoClose(session_id);
}
void SpeechRecognitionManagerImpl::CancelAllRequestsWithDelegate(
@@ -258,101 +258,101 @@ void SpeechRecognitionManagerImpl::CancelAllRequestsWithDelegate(
}
}
-void SpeechRecognitionManagerImpl::StopRecording(int caller_id) {
+void SpeechRecognitionManagerImpl::StopRecording(int session_id) {
// No pending requests on extension popups.
- if (!HasPendingRequest(caller_id))
+ if (!HasPendingRequest(session_id))
return;
- requests_[caller_id].recognizer->StopAudioCapture();
+ requests_[session_id].recognizer->StopAudioCapture();
}
// -------- SpeechRecognitionEventListener interface implementation. ---------
void SpeechRecognitionManagerImpl::OnRecognitionResult(
- int caller_id, const content::SpeechRecognitionResult& result) {
- DCHECK(HasPendingRequest(caller_id));
- GetDelegate(caller_id)->SetRecognitionResult(caller_id, result);
+ int session_id, const content::SpeechRecognitionResult& result) {
+ DCHECK(HasPendingRequest(session_id));
+ GetDelegate(session_id)->SetRecognitionResult(session_id, result);
}
-void SpeechRecognitionManagerImpl::OnAudioEnd(int caller_id) {
- if (recording_caller_id_ != caller_id)
+void SpeechRecognitionManagerImpl::OnAudioEnd(int session_id) {
+ if (recording_session_id_ != session_id)
return;
- DCHECK_EQ(recording_caller_id_, caller_id);
- DCHECK(HasPendingRequest(caller_id));
- if (!requests_[caller_id].is_active)
+ DCHECK_EQ(recording_session_id_, session_id);
+ DCHECK(HasPendingRequest(session_id));
+ if (!requests_[session_id].is_active)
return;
- recording_caller_id_ = 0;
- GetDelegate(caller_id)->DidCompleteRecording(caller_id);
+ recording_session_id_ = 0;
+ GetDelegate(session_id)->DidCompleteRecording(session_id);
if (delegate_.get())
- delegate_->ShowRecognizing(caller_id);
+ delegate_->ShowRecognizing(session_id);
}
-void SpeechRecognitionManagerImpl::OnRecognitionEnd(int caller_id) {
- if (!HasPendingRequest(caller_id) || !requests_[caller_id].is_active)
+void SpeechRecognitionManagerImpl::OnRecognitionEnd(int session_id) {
+ if (!HasPendingRequest(session_id) || !requests_[session_id].is_active)
return;
- GetDelegate(caller_id)->DidCompleteRecognition(caller_id);
- requests_.erase(caller_id);
+ GetDelegate(session_id)->DidCompleteRecognition(session_id);
+ requests_.erase(session_id);
if (delegate_.get())
- delegate_->DoClose(caller_id);
+ delegate_->DoClose(session_id);
}
-void SpeechRecognitionManagerImpl::OnSoundStart(int caller_id) {
+void SpeechRecognitionManagerImpl::OnSoundStart(int session_id) {
}
-void SpeechRecognitionManagerImpl::OnSoundEnd(int caller_id) {
+void SpeechRecognitionManagerImpl::OnSoundEnd(int session_id) {
}
void SpeechRecognitionManagerImpl::OnRecognitionError(
- int caller_id, const content::SpeechRecognitionError& error) {
- DCHECK(HasPendingRequest(caller_id));
- if (caller_id == recording_caller_id_)
- recording_caller_id_ = 0;
- requests_[caller_id].is_active = false;
+ int session_id, const content::SpeechRecognitionError& error) {
+ DCHECK(HasPendingRequest(session_id));
+ if (session_id == recording_session_id_)
+ recording_session_id_ = 0;
+ requests_[session_id].is_active = false;
if (delegate_.get()) {
if (error.code == content::SPEECH_RECOGNITION_ERROR_AUDIO &&
error.details == content::SPEECH_AUDIO_ERROR_DETAILS_NO_MIC) {
- delegate_->ShowMicError(caller_id,
+ delegate_->ShowMicError(session_id,
SpeechRecognitionManagerDelegate::MIC_ERROR_NO_DEVICE_AVAILABLE);
} else if (error.code == content::SPEECH_RECOGNITION_ERROR_AUDIO &&
error.details == content::SPEECH_AUDIO_ERROR_DETAILS_IN_USE) {
- delegate_->ShowMicError(
- caller_id, SpeechRecognitionManagerDelegate::MIC_ERROR_DEVICE_IN_USE);
+ delegate_->ShowMicError(session_id,
+ SpeechRecognitionManagerDelegate::MIC_ERROR_DEVICE_IN_USE);
} else {
- delegate_->ShowRecognizerError(caller_id, error.code);
+ delegate_->ShowRecognizerError(session_id, error.code);
}
}
}
-void SpeechRecognitionManagerImpl::OnAudioStart(int caller_id) {
- DCHECK(HasPendingRequest(caller_id));
- DCHECK_EQ(recording_caller_id_, caller_id);
+void SpeechRecognitionManagerImpl::OnAudioStart(int session_id) {
+ DCHECK(HasPendingRequest(session_id));
+ DCHECK_EQ(recording_session_id_, session_id);
if (delegate_.get())
- delegate_->ShowRecording(caller_id);
+ delegate_->ShowRecording(session_id);
}
-void SpeechRecognitionManagerImpl::OnRecognitionStart(int caller_id) {
+void SpeechRecognitionManagerImpl::OnRecognitionStart(int session_id) {
}
void SpeechRecognitionManagerImpl::OnEnvironmentEstimationComplete(
- int caller_id) {
- DCHECK(HasPendingRequest(caller_id));
- DCHECK_EQ(recording_caller_id_, caller_id);
+ int session_id) {
+ DCHECK(HasPendingRequest(session_id));
+ DCHECK_EQ(recording_session_id_, session_id);
}
void SpeechRecognitionManagerImpl::OnAudioLevelsChange(
- int caller_id, float volume, float noise_volume) {
- DCHECK(HasPendingRequest(caller_id));
- DCHECK_EQ(recording_caller_id_, caller_id);
+ int session_id, float volume, float noise_volume) {
+ DCHECK(HasPendingRequest(session_id));
+ DCHECK_EQ(recording_session_id_, session_id);
if (delegate_.get())
- delegate_->ShowInputVolume(caller_id, volume, noise_volume);
+ delegate_->ShowInputVolume(session_id, volume, noise_volume);
}
void SpeechRecognitionManagerImpl::CancelRecognitionAndInformDelegate(
- int caller_id) {
- InputTagSpeechDispatcherHost* cur_delegate = GetDelegate(caller_id);
- CancelRecognition(caller_id);
- cur_delegate->DidCompleteRecording(caller_id);
- cur_delegate->DidCompleteRecognition(caller_id);
+ int session_id) {
+ InputTagSpeechDispatcherHost* cur_delegate = GetDelegate(session_id);
+ CancelRecognition(session_id);
+ cur_delegate->DidCompleteRecording(session_id);
+ cur_delegate->DidCompleteRecognition(session_id);
}
SpeechRecognitionManagerImpl::Request::Request()
diff --git a/content/browser/speech/speech_recognition_manager_impl.h b/content/browser/speech/speech_recognition_manager_impl.h
index bb38cec..9a0c967 100644
--- a/content/browser/speech/speech_recognition_manager_impl.h
+++ b/content/browser/speech/speech_recognition_manager_impl.h
@@ -40,9 +40,9 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl
static SpeechRecognitionManagerImpl* GetInstance();
// SpeechRecognitionManager implementation:
- virtual void StartRecognitionForRequest(int caller_id) OVERRIDE;
- virtual void CancelRecognitionForRequest(int caller_id) OVERRIDE;
- virtual void FocusLostForRequest(int caller_id) OVERRIDE;
+ virtual void StartRecognitionForRequest(int session_id) OVERRIDE;
+ virtual void CancelRecognitionForRequest(int session_id) OVERRIDE;
+ virtual void FocusLostForRequest(int session_id) OVERRIDE;
virtual bool HasAudioInputDevices() OVERRIDE;
virtual bool IsCapturingAudio() OVERRIDE;
virtual string16 GetAudioInputDeviceModel() OVERRIDE;
@@ -58,7 +58,7 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl
// input (in page coordinates).
virtual void StartRecognition(
InputTagSpeechDispatcherHost* delegate,
- int caller_id,
+ int session_id,
int render_process_id,
int render_view_id,
const gfx::Rect& element_rect,
@@ -67,25 +67,25 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl
const std::string& origin_url,
net::URLRequestContextGetter* context_getter,
content::SpeechRecognitionPreferences* speech_recognition_prefs);
- virtual void CancelRecognition(int caller_id);
+ virtual void CancelRecognition(int session_id);
virtual void CancelAllRequestsWithDelegate(
InputTagSpeechDispatcherHost* delegate);
- virtual void StopRecording(int caller_id);
+ virtual void StopRecording(int session_id);
// SpeechRecognitionEventListener methods.
- virtual void OnRecognitionStart(int caller_id) OVERRIDE;
- virtual void OnAudioStart(int caller_id) OVERRIDE;
- virtual void OnEnvironmentEstimationComplete(int caller_id) OVERRIDE;
- virtual void OnSoundStart(int caller_id) OVERRIDE;
- virtual void OnSoundEnd(int caller_id) OVERRIDE;
- virtual void OnAudioEnd(int caller_id) OVERRIDE;
- virtual void OnRecognitionEnd(int caller_id) OVERRIDE;
+ virtual void OnRecognitionStart(int session_id) OVERRIDE;
+ virtual void OnAudioStart(int session_id) OVERRIDE;
+ virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE;
+ virtual void OnSoundStart(int session_id) OVERRIDE;
+ virtual void OnSoundEnd(int session_id) OVERRIDE;
+ virtual void OnAudioEnd(int session_id) OVERRIDE;
+ virtual void OnRecognitionEnd(int session_id) OVERRIDE;
virtual void OnRecognitionResult(
- int caller_id, const content::SpeechRecognitionResult& result) OVERRIDE;
+ int session_id, const content::SpeechRecognitionResult& result) OVERRIDE;
virtual void OnRecognitionError(
- int caller_id, const content::SpeechRecognitionError& error) OVERRIDE;
+ int session_id, const content::SpeechRecognitionError& error) OVERRIDE;
virtual void OnAudioLevelsChange(
- int caller_id, float volume, float noise_volume) OVERRIDE;
+ int session_id, float volume, float noise_volume) OVERRIDE;
protected:
// Private constructor to enforce singleton.
@@ -93,7 +93,7 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl
SpeechRecognitionManagerImpl();
virtual ~SpeechRecognitionManagerImpl();
- bool HasPendingRequest(int caller_id) const;
+ bool HasPendingRequest(int session_id) const;
private:
struct Request {
@@ -107,19 +107,19 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl
struct SpeechRecognitionParams;
- InputTagSpeechDispatcherHost* GetDelegate(int caller_id) const;
+ InputTagSpeechDispatcherHost* GetDelegate(int session_id) const;
void CheckRenderViewTypeAndStartRecognition(
const SpeechRecognitionParams& params);
void ProceedStartingRecognition(const SpeechRecognitionParams& params);
- void CancelRecognitionAndInformDelegate(int caller_id);
+ void CancelRecognitionAndInformDelegate(int session_id);
typedef std::map<int, Request> SpeechRecognizerMap;
SpeechRecognizerMap requests_;
std::string request_info_;
bool can_report_metrics_;
- int recording_caller_id_;
+ int recording_session_id_;
scoped_ptr<content::SpeechRecognitionManagerDelegate> delegate_;
};
diff --git a/content/browser/speech/speech_recognizer_impl.cc b/content/browser/speech/speech_recognizer_impl.cc
index d9d9bab..d8b765f 100644
--- a/content/browser/speech/speech_recognizer_impl.cc
+++ b/content/browser/speech/speech_recognizer_impl.cc
@@ -63,9 +63,13 @@ bool DetectClipping(const speech::AudioChunk& chunk) {
} // namespace
+// TODO(primiano) Create(...) is transitional (until we fix speech input
+// extensions) and should be removed soon. The manager should be the only one
+// knowing the existence of SpeechRecognizer(Impl), thus the only one in charge
+// of instantiating it.
SpeechRecognizer* SpeechRecognizer::Create(
SpeechRecognitionEventListener* listener,
- int caller_id,
+ int session_id,
const std::string& language,
const std::string& grammar,
net::URLRequestContextGetter* context_getter,
@@ -89,7 +93,7 @@ SpeechRecognizer* SpeechRecognizer::Create(
google_remote_engine->SetConfig(remote_engine_config);
return new speech::SpeechRecognizerImpl(listener,
- caller_id,
+ session_id,
google_remote_engine);
}
@@ -106,13 +110,13 @@ COMPILE_ASSERT(SpeechRecognizerImpl::kNumBitsPerAudioSample % 8 == 0,
SpeechRecognizerImpl::SpeechRecognizerImpl(
SpeechRecognitionEventListener* listener,
- int caller_id,
+ int session_id,
SpeechRecognitionEngine* engine)
: listener_(listener),
testing_audio_manager_(NULL),
recognition_engine_(engine),
endpointer_(kAudioSampleRate),
- caller_id_(caller_id),
+ session_id_(session_id),
is_dispatching_event_(false),
state_(STATE_IDLE) {
DCHECK(listener_ != NULL);
@@ -406,7 +410,7 @@ SpeechRecognizerImpl::StartRecording(const FSMEventArgs&) {
DVLOG(1) << "SpeechRecognizerImpl starting audio capture.";
num_samples_recorded_ = 0;
audio_level_ = 0;
- listener_->OnRecognitionStart(caller_id_);
+ listener_->OnRecognitionStart(session_id_);
if (!audio_manager->HasAudioInputDevices()) {
return AbortWithError(SpeechRecognitionError(
@@ -447,7 +451,7 @@ SpeechRecognizerImpl::StartRecognitionEngine(const FSMEventArgs& event_args) {
// started and the delegate notified about the event.
DCHECK(recognition_engine_.get() != NULL);
recognition_engine_->StartRecognition();
- listener_->OnAudioStart(caller_id_);
+ listener_->OnAudioStart(session_id_);
// This is a little hack, since TakeAudioChunk() is already called by
// ProcessAudioPipeline(). It is the best tradeoff, unless we allow dropping
@@ -461,7 +465,7 @@ SpeechRecognizerImpl::WaitEnvironmentEstimationCompletion(const FSMEventArgs&) {
DCHECK(endpointer_.IsEstimatingEnvironment());
if (GetElapsedTimeMs() >= kEndpointerEstimationTimeMs) {
endpointer_.SetUserInputMode();
- listener_->OnEnvironmentEstimationComplete(caller_id_);
+ listener_->OnEnvironmentEstimationComplete(session_id_);
return STATE_WAITING_FOR_SPEECH;
} else {
return STATE_ESTIMATING_ENVIRONMENT;
@@ -471,7 +475,7 @@ SpeechRecognizerImpl::WaitEnvironmentEstimationCompletion(const FSMEventArgs&) {
SpeechRecognizerImpl::FSMState
SpeechRecognizerImpl::DetectUserSpeechOrTimeout(const FSMEventArgs&) {
if (endpointer_.DidStartReceivingSpeech()) {
- listener_->OnSoundStart(caller_id_);
+ listener_->OnSoundStart(session_id_);
return STATE_RECOGNIZING;
} else if (GetElapsedTimeMs() >= kNoSpeechTimeoutMs) {
return AbortWithError(
@@ -497,9 +501,9 @@ SpeechRecognizerImpl::StopCaptureAndWaitForResult(const FSMEventArgs&) {
recognition_engine_->AudioChunksEnded();
if (state_ > STATE_WAITING_FOR_SPEECH)
- listener_->OnSoundEnd(caller_id_);
+ listener_->OnSoundEnd(session_id_);
- listener_->OnAudioEnd(caller_id_);
+ listener_->OnAudioEnd(session_id_);
return STATE_WAITING_FINAL_RESULT;
}
@@ -538,15 +542,15 @@ SpeechRecognizerImpl::FSMState SpeechRecognizerImpl::AbortWithError(
}
if (state_ > STATE_WAITING_FOR_SPEECH && state_ < STATE_WAITING_FINAL_RESULT)
- listener_->OnSoundEnd(caller_id_);
+ listener_->OnSoundEnd(session_id_);
if (state_ > STATE_STARTING && state_ < STATE_WAITING_FINAL_RESULT)
- listener_->OnAudioEnd(caller_id_);
+ listener_->OnAudioEnd(session_id_);
if (error != NULL)
- listener_->OnRecognitionError(caller_id_, *error);
+ listener_->OnRecognitionError(session_id_, *error);
- listener_->OnRecognitionEnd(caller_id_);
+ listener_->OnRecognitionEnd(session_id_);
return STATE_IDLE;
}
@@ -563,8 +567,8 @@ SpeechRecognizerImpl::ProcessFinalResult(const FSMEventArgs& event_args) {
const SpeechRecognitionResult& result = event_args.engine_result;
DVLOG(1) << "Got valid result";
recognition_engine_->EndRecognition();
- listener_->OnRecognitionResult(caller_id_, result);
- listener_->OnRecognitionEnd(caller_id_);
+ listener_->OnRecognitionResult(session_id_, result);
+ listener_->OnRecognitionEnd(session_id_);
return STATE_IDLE;
}
@@ -615,7 +619,7 @@ void SpeechRecognizerImpl::UpdateSignalAndNoiseLevels(const float& rms,
kAudioMeterRangeMaxUnclipped);
listener_->OnAudioLevelsChange(
- caller_id_, clip_detected ? 1.0f : audio_level_, noise_level);
+ session_id_, clip_detected ? 1.0f : audio_level_, noise_level);
}
const SpeechRecognitionEngine&
diff --git a/content/browser/speech/speech_recognizer_impl.h b/content/browser/speech/speech_recognizer_impl.h
index a2cce74..5b37d61 100644
--- a/content/browser/speech/speech_recognizer_impl.h
+++ b/content/browser/speech/speech_recognizer_impl.h
@@ -18,11 +18,9 @@
namespace content {
class SpeechRecognitionEventListener;
-struct SpeechRecognitionResult;
}
namespace media {
-class AudioInputController;
class AudioManager;
}
@@ -32,7 +30,7 @@ namespace speech {
// /content/public/browser/speech_recognizer.h interface since this class should
// not be visible outside (currently we need it for speech input extension API).
-// Handles speech recognition for a session (identified by |caller_id|), taking
+// Handles speech recognition for a session (identified by |session_id|), taking
// care of audio capture, silence detection/endpointer and interaction with the
// SpeechRecognitionEngine.
class CONTENT_EXPORT SpeechRecognizerImpl
@@ -48,7 +46,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl
SpeechRecognizerImpl(
content::SpeechRecognitionEventListener* listener,
- int caller_id,
+ int session_id,
SpeechRecognitionEngine* engine);
virtual ~SpeechRecognizerImpl();
@@ -152,7 +150,7 @@ class CONTENT_EXPORT SpeechRecognizerImpl
scoped_ptr<SpeechRecognitionEngine> recognition_engine_;
Endpointer endpointer_;
scoped_refptr<media::AudioInputController> audio_controller_;
- int caller_id_;
+ int session_id_;
int num_samples_recorded_;
float audio_level_;
bool is_dispatching_event_;
diff --git a/content/browser/speech/speech_recognizer_impl_unittest.cc b/content/browser/speech/speech_recognizer_impl_unittest.cc
index 5dbe6cc..d9658f9 100644
--- a/content/browser/speech/speech_recognizer_impl_unittest.cc
+++ b/content/browser/speech/speech_recognizer_impl_unittest.cc
@@ -147,52 +147,52 @@ class SpeechRecognizerImplTest : public content::SpeechRecognitionEventListener,
}
// Overridden from content::SpeechRecognitionEventListener:
- virtual void OnAudioStart(int caller_id) OVERRIDE {
+ virtual void OnAudioStart(int session_id) OVERRIDE {
audio_started_ = true;
CheckEventsConsistency();
}
- virtual void OnAudioEnd(int caller_id) OVERRIDE {
+ virtual void OnAudioEnd(int session_id) OVERRIDE {
audio_ended_ = true;
CheckEventsConsistency();
}
virtual void OnRecognitionResult(
- int caller_id, const content::SpeechRecognitionResult& result) OVERRIDE {
+ int session_id, const content::SpeechRecognitionResult& result) OVERRIDE {
result_received_ = true;
}
virtual void OnRecognitionError(
- int caller_id, const content::SpeechRecognitionError& error) OVERRIDE {
+ int session_id, const content::SpeechRecognitionError& error) OVERRIDE {
EXPECT_TRUE(recognition_started_);
EXPECT_FALSE(recognition_ended_);
error_ = error.code;
}
- virtual void OnAudioLevelsChange(int caller_id, float volume,
+ virtual void OnAudioLevelsChange(int session_id, float volume,
float noise_volume) OVERRIDE {
volume_ = volume;
noise_volume_ = noise_volume;
}
- virtual void OnRecognitionEnd(int caller_id) OVERRIDE {
+ virtual void OnRecognitionEnd(int session_id) OVERRIDE {
recognition_ended_ = true;
CheckEventsConsistency();
}
- virtual void OnRecognitionStart(int caller_id) OVERRIDE {
+ virtual void OnRecognitionStart(int session_id) OVERRIDE {
recognition_started_ = true;
CheckEventsConsistency();
}
- virtual void OnEnvironmentEstimationComplete(int caller_id) OVERRIDE {}
+ virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE {}
- virtual void OnSoundStart(int caller_id) OVERRIDE {
+ virtual void OnSoundStart(int session_id) OVERRIDE {
sound_started_ = true;
CheckEventsConsistency();
}
- virtual void OnSoundEnd(int caller_id) OVERRIDE {
+ virtual void OnSoundEnd(int session_id) OVERRIDE {
sound_ended_ = true;
CheckEventsConsistency();
}
diff --git a/content/public/browser/speech_recognition_event_listener.h b/content/public/browser/speech_recognition_event_listener.h
index 7ce6995..10d64b3 100644
--- a/content/public/browser/speech_recognition_event_listener.h
+++ b/content/public/browser/speech_recognition_event_listener.h
@@ -19,46 +19,46 @@ class CONTENT_EXPORT SpeechRecognitionEventListener {
public:
// Invoked when the StartRequest is received and the recognition process is
// started.
- virtual void OnRecognitionStart(int caller_id_id) = 0;
+ virtual void OnRecognitionStart(int session_id) = 0;
// Invoked when the first audio capture is initiated.
- virtual void OnAudioStart(int caller_id) = 0;
+ virtual void OnAudioStart(int session_id) = 0;
// At the start of recognition, a short amount of audio is recorded to
// estimate the environment/background noise and this callback is issued
// after that is complete. Typically the delegate brings up any speech
// recognition UI once this callback is received.
- virtual void OnEnvironmentEstimationComplete(int caller_id) = 0;
+ virtual void OnEnvironmentEstimationComplete(int session_id) = 0;
// Informs that the end pointer has started detecting sound (possibly speech).
- virtual void OnSoundStart(int caller_id) = 0;
+ virtual void OnSoundStart(int session_id) = 0;
// Informs that the end pointer has stopped detecting sound (a long silence).
- virtual void OnSoundEnd(int caller_id) = 0;
+ virtual void OnSoundEnd(int session_id) = 0;
// Invoked when audio capture stops, either due to the end pointer detecting
// silence, an internal error, or an explicit stop was issued.
- virtual void OnAudioEnd(int caller_id) = 0;
+ virtual void OnAudioEnd(int session_id) = 0;
// Invoked when a result is retrieved.
- virtual void OnRecognitionResult(int caller_id,
+ virtual void OnRecognitionResult(int session_id,
const SpeechRecognitionResult& result) = 0;
// Invoked if there was an error while capturing or recognizing audio.
// The recognition has already been cancelled when this call is made and
// no more events will be raised.
- virtual void OnRecognitionError(int caller_id,
+ virtual void OnRecognitionError(int session_id,
const SpeechRecognitionError& error) = 0;
// Informs of a change in the captured audio level, useful if displaying
// a microphone volume indicator while recording.
// The value of |volume| and |noise_volume| is in the [0.0, 1.0] range.
- virtual void OnAudioLevelsChange(int caller_id, float volume,
- float noise_volume) = 0;
+ virtual void OnAudioLevelsChange(int session_id,
+ float volume, float noise_volume) = 0;
// This is guaranteed to be the last event raised in the recognition
// process and the |SpeechRecognizer| object can be freed if necessary.
- virtual void OnRecognitionEnd(int caller_id) = 0;
+ virtual void OnRecognitionEnd(int session_id) = 0;
protected:
virtual ~SpeechRecognitionEventListener() { }
diff --git a/content/public/browser/speech_recognition_manager.h b/content/public/browser/speech_recognition_manager.h
index 89651c1..9c94999 100644
--- a/content/public/browser/speech_recognition_manager.h
+++ b/content/public/browser/speech_recognition_manager.h
@@ -20,14 +20,14 @@ class SpeechRecognitionManager {
CONTENT_EXPORT static SpeechRecognitionManager* GetInstance();
// Starts/restarts recognition for an existing request.
- virtual void StartRecognitionForRequest(int caller_id) = 0;
+ virtual void StartRecognitionForRequest(int session_id) = 0;
// Cancels recognition for an existing request.
- virtual void CancelRecognitionForRequest(int caller_id) = 0;
+ virtual void CancelRecognitionForRequest(int session_id) = 0;
// Called when the user clicks outside the speech input UI causing it to close
// and possibly have speech input go to another element.
- virtual void FocusLostForRequest(int caller_id) = 0;
+ virtual void FocusLostForRequest(int session_id) = 0;
// Returns true if the OS reports existence of audio recording devices.
virtual bool HasAudioInputDevices() = 0;
diff --git a/content/public/browser/speech_recognition_manager_delegate.h b/content/public/browser/speech_recognition_manager_delegate.h
index dc52947..7156bc2 100644
--- a/content/public/browser/speech_recognition_manager_delegate.h
+++ b/content/public/browser/speech_recognition_manager_delegate.h
@@ -38,34 +38,34 @@ class SpeechRecognitionManagerDelegate {
// the view port for the given caller. The embedder should call the
// StartRecognition or CancelRecognition methods on SpeechInutManager in
// response.
- virtual void ShowRecognitionRequested(int caller_id,
+ virtual void ShowRecognitionRequested(int session_id,
int render_process_id,
int render_view_id,
const gfx::Rect& element_rect) = 0;
// Called when recognition is starting up.
- virtual void ShowWarmUp(int caller_id) = 0;
+ virtual void ShowWarmUp(int session_id) = 0;
// Called when recognition has started.
- virtual void ShowRecognizing(int caller_id) = 0;
+ virtual void ShowRecognizing(int session_id) = 0;
// Called when recording has started.
- virtual void ShowRecording(int caller_id) = 0;
+ virtual void ShowRecording(int session_id) = 0;
// Continuously updated with the current input volume.
- virtual void ShowInputVolume(int caller_id,
+ virtual void ShowInputVolume(int session_id,
float volume,
float noise_volume) = 0;
// Called when no microphone has been found.
- virtual void ShowMicError(int caller_id, MicError error) = 0;
+ virtual void ShowMicError(int session_id, MicError error) = 0;
// Called when there has been a error with the recognition.
- virtual void ShowRecognizerError(int caller_id,
+ virtual void ShowRecognizerError(int session_id,
SpeechRecognitionErrorCode error) = 0;
// Called when recognition has ended or has been canceled.
- virtual void DoClose(int caller_id) = 0;
+ virtual void DoClose(int session_id) = 0;
};
} // namespace content
diff --git a/content/public/browser/speech_recognizer.h b/content/public/browser/speech_recognizer.h
index 4e64e10..330048e 100644
--- a/content/public/browser/speech_recognizer.h
+++ b/content/public/browser/speech_recognizer.h
@@ -25,13 +25,9 @@ class SpeechRecognitionEventListener;
class SpeechRecognizer : public base::RefCountedThreadSafe<SpeechRecognizer> {
public:
- // TODO(primiano) Create(...) is transitional (until we fix speech input
- // extensions) and should be removed soon. The manager should be the only one
- // knowing the existence of SpeechRecognizer, thus the only one in charge of
- // instantiating it.
CONTENT_EXPORT static SpeechRecognizer* Create(
SpeechRecognitionEventListener* event_listener,
- int caller_id,
+ int session_id,
const std::string& language,
const std::string& grammar,
net::URLRequestContextGetter* context_getter,