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

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: 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..9034c2004b3a25a75cae35a17ca06c07e4609a96 100644
--- a/content/renderer/speech_recognition_dispatcher.cc
+++ b/content/renderer/speech_recognition_dispatcher.cc
@@ -121,38 +121,38 @@ 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 WebSpeechRecognitionHandle::OtherError;
+ case content::SPEECH_RECOGNITION_ERROR_ABORTED:
+ return WebSpeechRecognitionHandle::AbortedError;
+ case content::SPEECH_RECOGNITION_ERROR_AUDIO:
+ return WebSpeechRecognitionHandle::AudioCaptureError;
+ case content::SPEECH_RECOGNITION_ERROR_NETWORK:
+ return WebSpeechRecognitionHandle::NetworkError;
+ case content::SPEECH_RECOGNITION_ERROR_NO_SPEECH:
+ return WebSpeechRecognitionHandle::NoSpeechError;
+ case content::SPEECH_RECOGNITION_ERROR_NO_MATCH:
Satish 2012/08/01 13:30:33 looks like this canbeb removed (as it is handledi
hans 2012/08/01 14:46:21 The reason I kept the impossible cases (ERROR_NONE
+ NOTREACHED();
+ return WebSpeechRecognitionHandle::OtherError;
+ case content::SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR:
+ return WebSpeechRecognitionHandle::BadGrammarError;
+ }
+ NOTREACHED();
+}
+
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
Satish 2012/08/01 13:30:33 is this not the intention anymore?
hans 2012/08/01 14:46:21 No, I think it's better that the enum in speech_re
- // 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