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

Unified Diff: content/renderer/speech_recognition_dispatcher.cc

Issue 10831110: SpeechRecognitionDispatcher: break out translation of error codes to separate function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make android happy Created 8 years, 5 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
« no previous file with comments | « content/public/common/speech_recognition_error.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/speech_recognition_dispatcher.cc
diff --git a/content/renderer/speech_recognition_dispatcher.cc b/content/renderer/speech_recognition_dispatcher.cc
index ad1610c3ccf90d0214a7ba1b6c5e5452dfd74a6d..acb3d87f03940fd8ac9efdd0477444248d7a70e6 100644
--- a/content/renderer/speech_recognition_dispatcher.cc
+++ b/content/renderer/speech_recognition_dispatcher.cc
@@ -121,38 +121,39 @@ void SpeechRecognitionDispatcher::OnAudioEnded(int request_id) {
recognizer_client_->didEndAudio(GetHandleFromID(request_id));
}
+static WebSpeechRecognizerClient::ErrorCode WebKitErrorCode(
+ content::SpeechRecognitionErrorCode e) {
+ switch (e) {
+ case content::SPEECH_RECOGNITION_ERROR_NONE:
+ NOTREACHED();
+ return WebSpeechRecognizerClient::OtherError;
+ case content::SPEECH_RECOGNITION_ERROR_ABORTED:
+ return WebSpeechRecognizerClient::AbortedError;
+ case content::SPEECH_RECOGNITION_ERROR_AUDIO:
+ return WebSpeechRecognizerClient::AudioCaptureError;
+ case content::SPEECH_RECOGNITION_ERROR_NETWORK:
+ return WebSpeechRecognizerClient::NetworkError;
+ case content::SPEECH_RECOGNITION_ERROR_NO_SPEECH:
+ return WebSpeechRecognizerClient::NoSpeechError;
+ case content::SPEECH_RECOGNITION_ERROR_NO_MATCH:
+ NOTREACHED();
+ return WebSpeechRecognizerClient::OtherError;
+ case content::SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR:
+ return WebSpeechRecognizerClient::BadGrammarError;
+ }
+ NOTREACHED();
+ return WebSpeechRecognizerClient::OtherError;
+}
+
void SpeechRecognitionDispatcher::OnErrorOccurred(
int request_id, const SpeechRecognitionError& error) {
if (error.code == content::SPEECH_RECOGNITION_ERROR_NO_MATCH) {
recognizer_client_->didReceiveNoMatch(GetHandleFromID(request_id),
WebSpeechRecognitionResult());
} else {
- // TODO(primiano): speech_recognition_error.h must be updated to match the
- // new enums defined in the the API specs (thus removing the code below).
- WebSpeechRecognizerClient::ErrorCode wk_error_code;
- switch (error.code) {
- case content::SPEECH_RECOGNITION_ERROR_ABORTED:
- wk_error_code = WebSpeechRecognizerClient::AbortedError;
- break;
- case content::SPEECH_RECOGNITION_ERROR_AUDIO:
- wk_error_code = WebSpeechRecognizerClient::AudioCaptureError;
- break;
- case content::SPEECH_RECOGNITION_ERROR_NETWORK:
- wk_error_code = WebSpeechRecognizerClient::NetworkError;
- break;
- case content::SPEECH_RECOGNITION_ERROR_NO_SPEECH:
- wk_error_code = WebSpeechRecognizerClient::NoSpeechError;
- break;
- case content::SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR:
- wk_error_code = WebSpeechRecognizerClient::BadGrammarError;
- break;
- default:
- NOTREACHED();
- wk_error_code = WebSpeechRecognizerClient::OtherError;
- }
recognizer_client_->didReceiveError(GetHandleFromID(request_id),
WebString(), // TODO(primiano): message?
- wk_error_code);
+ WebKitErrorCode(error.code));
}
}
« no previous file with comments | « content/public/common/speech_recognition_error.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698