| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "content/browser/speech/audio_buffer.h" | 16 #include "content/browser/speech/audio_buffer.h" |
| 17 #include "content/browser/speech/proto/google_streaming_api.pb.h" | 17 #include "content/browser/speech/proto/google_streaming_api.pb.h" |
| 18 #include "content/public/browser/browser_thread.h" | |
| 19 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/common/speech_recognition_error.h" | 19 #include "content/public/common/speech_recognition_error.h" |
| 21 #include "content/public/common/speech_recognition_result.h" | 20 #include "content/public/common/speech_recognition_result.h" |
| 22 #include "google_apis/google_api_keys.h" | 21 #include "google_apis/google_api_keys.h" |
| 23 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
| 24 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 25 #include "net/url_request/url_fetcher.h" | 24 #include "net/url_request/url_fetcher.h" |
| 26 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 27 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
| 28 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 403 |
| 405 // An empty (default) event is used to notify us that the upstream has | 404 // An empty (default) event is used to notify us that the upstream has |
| 406 // been connected. Ignore. | 405 // been connected. Ignore. |
| 407 if (!ws_event.result_size() && (!ws_event.has_status() || | 406 if (!ws_event.result_size() && (!ws_event.has_status() || |
| 408 ws_event.status() == proto::SpeechRecognitionEvent::STATUS_SUCCESS)) { | 407 ws_event.status() == proto::SpeechRecognitionEvent::STATUS_SUCCESS)) { |
| 409 DVLOG(1) << "Received empty response"; | 408 DVLOG(1) << "Received empty response"; |
| 410 return state_; | 409 return state_; |
| 411 } | 410 } |
| 412 | 411 |
| 413 if (ws_event.has_status()) { | 412 if (ws_event.has_status()) { |
| 414 switch(ws_event.status()) { | 413 switch (ws_event.status()) { |
| 415 case proto::SpeechRecognitionEvent::STATUS_SUCCESS: | 414 case proto::SpeechRecognitionEvent::STATUS_SUCCESS: |
| 416 break; | 415 break; |
| 417 case proto::SpeechRecognitionEvent::STATUS_NO_SPEECH: | 416 case proto::SpeechRecognitionEvent::STATUS_NO_SPEECH: |
| 418 return Abort(SPEECH_RECOGNITION_ERROR_NO_SPEECH); | 417 return Abort(SPEECH_RECOGNITION_ERROR_NO_SPEECH); |
| 419 case proto::SpeechRecognitionEvent::STATUS_ABORTED: | 418 case proto::SpeechRecognitionEvent::STATUS_ABORTED: |
| 420 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); | 419 return Abort(SPEECH_RECOGNITION_ERROR_ABORTED); |
| 421 case proto::SpeechRecognitionEvent::STATUS_AUDIO_CAPTURE: | 420 case proto::SpeechRecognitionEvent::STATUS_AUDIO_CAPTURE: |
| 422 return Abort(SPEECH_RECOGNITION_ERROR_AUDIO); | 421 return Abort(SPEECH_RECOGNITION_ERROR_AUDIO); |
| 423 case proto::SpeechRecognitionEvent::STATUS_NETWORK: | 422 case proto::SpeechRecognitionEvent::STATUS_NETWORK: |
| 424 return Abort(SPEECH_RECOGNITION_ERROR_NETWORK); | 423 return Abort(SPEECH_RECOGNITION_ERROR_NETWORK); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 587 } |
| 589 | 588 |
| 590 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) | 589 GoogleStreamingRemoteEngine::FSMEventArgs::FSMEventArgs(FSMEvent event_value) |
| 591 : event(event_value) { | 590 : event(event_value) { |
| 592 } | 591 } |
| 593 | 592 |
| 594 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { | 593 GoogleStreamingRemoteEngine::FSMEventArgs::~FSMEventArgs() { |
| 595 } | 594 } |
| 596 | 595 |
| 597 } // namespace content | 596 } // namespace content |
| OLD | NEW |