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

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

Issue 10399025: Moved instantiation of SpeechRecognitionManager inside browser_main_loop, instead of Singleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed according to Hans review + nits. 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 2482f714c7c9347544f78f8029b6aa85f2986f47..5b9384e8943dcd232f852179233eb73ebdbd6904 100644
--- a/content/browser/speech/input_tag_speech_dispatcher_host.cc
+++ b/content/browser/speech/input_tag_speech_dispatcher_host.cc
@@ -14,6 +14,7 @@
#include "content/public/browser/speech_recognition_session_context.h"
using content::BrowserThread;
+using content::SpeechRecognitionManager;
using content::SpeechRecognitionSessionConfig;
using content::SpeechRecognitionSessionContext;
@@ -29,11 +30,11 @@ bool IsSameContext(int render_process_id,
} // namespace
namespace speech {
-SpeechRecognitionManagerImpl* InputTagSpeechDispatcherHost::manager_;
+SpeechRecognitionManager* InputTagSpeechDispatcherHost::manager_for_tests_;
-void InputTagSpeechDispatcherHost::set_manager(
- SpeechRecognitionManagerImpl* manager) {
- manager_ = manager;
+void InputTagSpeechDispatcherHost::set_manager_for_tests(
+ SpeechRecognitionManager* manager) {
+ manager_for_tests_ = manager;
}
InputTagSpeechDispatcherHost::InputTagSpeechDispatcherHost(
@@ -59,11 +60,11 @@ InputTagSpeechDispatcherHost::~InputTagSpeechDispatcherHost() {
manager()->AbortAllSessionsForListener(this);
}
-SpeechRecognitionManagerImpl* InputTagSpeechDispatcherHost::manager() {
- if (manager_)
- return manager_;
+SpeechRecognitionManager* InputTagSpeechDispatcherHost::manager() {
+ if (manager_for_tests_)
+ return manager_for_tests_;
#if defined(ENABLE_INPUT_SPEECH)
- return SpeechRecognitionManagerImpl::GetInstance();
+ return SpeechRecognitionManager::GetInstance();
#else
return NULL;
#endif
@@ -108,7 +109,7 @@ void InputTagSpeechDispatcherHost::OnStartRecognition(
config.event_listener = this;
int session_id = manager()->CreateSession(config);
- if (session_id == content::SpeechRecognitionManager::kSessionIDInvalid)
+ if (session_id == SpeechRecognitionManager::kSessionIDInvalid)
return;
manager()->StartSession(session_id);
@@ -122,7 +123,7 @@ void InputTagSpeechDispatcherHost::OnCancelRecognition(int render_view_id,
render_process_id_,
render_view_id,
request_id));
- if (session_id != content::SpeechRecognitionManager::kSessionIDInvalid)
+ if (session_id != SpeechRecognitionManager::kSessionIDInvalid)
manager()->AbortSession(session_id);
}
@@ -134,7 +135,7 @@ void InputTagSpeechDispatcherHost::OnStopRecording(int render_view_id,
render_process_id_,
render_view_id,
request_id));
- DCHECK_NE(session_id, content::SpeechRecognitionManager::kSessionIDInvalid);
+ DCHECK_NE(session_id, SpeechRecognitionManager::kSessionIDInvalid);
manager()->StopAudioCaptureForSession(session_id);
}

Powered by Google App Engine
This is Rietveld 408576698