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

Side by Side Diff: content/browser/speech/google_streaming_remote_engine.cc

Issue 1073513002: Fix to proper error type on SpeechRecognition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/public/common/speech_recognition_error.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/speech/google_streaming_remote_engine.h" 5 #include "content/browser/speech/google_streaming_remote_engine.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/big_endian.h" 10 #include "base/big_endian.h"
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 break; 442 break;
443 case proto::SpeechRecognitionEvent::STATUS_NO_SPEECH: 443 case proto::SpeechRecognitionEvent::STATUS_NO_SPEECH:
444 return Abort(SPEECH_RECOGNITION_ERROR_NO_SPEECH); 444 return Abort(SPEECH_RECOGNITION_ERROR_NO_SPEECH);
445 case proto::SpeechRecognitionEvent::STATUS_ABORTED: 445 case proto::SpeechRecognitionEvent::STATUS_ABORTED:
446 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); 446 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED);
447 case proto::SpeechRecognitionEvent::STATUS_AUDIO_CAPTURE: 447 case proto::SpeechRecognitionEvent::STATUS_AUDIO_CAPTURE:
448 return Abort(SPEECH_RECOGNITION_ERROR_AUDIO); 448 return Abort(SPEECH_RECOGNITION_ERROR_AUDIO);
449 case proto::SpeechRecognitionEvent::STATUS_NETWORK: 449 case proto::SpeechRecognitionEvent::STATUS_NETWORK:
450 return Abort(SPEECH_RECOGNITION_ERROR_NETWORK); 450 return Abort(SPEECH_RECOGNITION_ERROR_NETWORK);
451 case proto::SpeechRecognitionEvent::STATUS_NOT_ALLOWED: 451 case proto::SpeechRecognitionEvent::STATUS_NOT_ALLOWED:
452 // TODO(hans): We need a better error code for this. 452 return Abort(SPEECH_RECOGNITION_ERROR_NOT_ALLOWED);
453 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED);
454 case proto::SpeechRecognitionEvent::STATUS_SERVICE_NOT_ALLOWED: 453 case proto::SpeechRecognitionEvent::STATUS_SERVICE_NOT_ALLOWED:
455 // TODO(hans): We need a better error code for this. 454 return Abort(SPEECH_RECOGNITION_ERROR_SERVICE_NOT_ALLOWED);
456 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED);
457 case proto::SpeechRecognitionEvent::STATUS_BAD_GRAMMAR: 455 case proto::SpeechRecognitionEvent::STATUS_BAD_GRAMMAR:
458 return Abort(SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR); 456 return Abort(SPEECH_RECOGNITION_ERROR_BAD_GRAMMAR);
459 case proto::SpeechRecognitionEvent::STATUS_LANGUAGE_NOT_SUPPORTED: 457 case proto::SpeechRecognitionEvent::STATUS_LANGUAGE_NOT_SUPPORTED:
460 // TODO(hans): We need a better error code for this. 458 return Abort(SPEECH_RECOGNITION_ERROR_LANGUAGE_NOT_SUPPORTED);
461 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED);
462 } 459 }
463 } 460 }
464 461
465 SpeechRecognitionResults results; 462 SpeechRecognitionResults results;
466 for (int i = 0; i < ws_event.result_size(); ++i) { 463 for (int i = 0; i < ws_event.result_size(); ++i) {
467 const proto::SpeechRecognitionResult& ws_result = ws_event.result(i); 464 const proto::SpeechRecognitionResult& ws_result = ws_event.result(i);
468 results.push_back(SpeechRecognitionResult()); 465 results.push_back(SpeechRecognitionResult());
469 SpeechRecognitionResult& result = results.back(); 466 SpeechRecognitionResult& result = results.back();
470 result.is_provisional = !(ws_result.has_final() && ws_result.final()); 467 result.is_provisional = !(ws_result.has_final() && ws_result.final());
471 468
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 628 }
632 629
633 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) 630 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value)
634 : event(event_value) { 631 : event(event_value) {
635 } 632 }
636 633
637 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { 634 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() {
638 } 635 }
639 636
640 } // namespace content 637 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/public/common/speech_recognition_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698