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_one_shot_remote_engine.h" | 5 #include "content/browser/speech/google_one_shot_remote_engine.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 encoder_->Flush(); | 261 encoder_->Flush(); |
262 scoped_refptr<AudioChunk> encoded_dummy_data( | 262 scoped_refptr<AudioChunk> encoded_dummy_data( |
263 encoder_->GetEncodedDataAndClear()); | 263 encoder_->GetEncodedDataAndClear()); |
264 DCHECK(!encoded_dummy_data->IsEmpty()); | 264 DCHECK(!encoded_dummy_data->IsEmpty()); |
265 encoder_.reset(); | 265 encoder_.reset(); |
266 | 266 |
267 url_fetcher_->AppendChunkToUpload(encoded_dummy_data->AsString(), true); | 267 url_fetcher_->AppendChunkToUpload(encoded_dummy_data->AsString(), true); |
268 } | 268 } |
269 | 269 |
270 void GoogleOneShotRemoteEngine::OnURLFetchComplete( | 270 void GoogleOneShotRemoteEngine::OnURLFetchComplete( |
271 const content::URLFetcher* source) { | 271 const net::URLFetcher* source) { |
272 DCHECK_EQ(url_fetcher_.get(), source); | 272 DCHECK_EQ(url_fetcher_.get(), source); |
273 SpeechRecognitionResult result; | 273 SpeechRecognitionResult result; |
274 SpeechRecognitionError error(content::SPEECH_RECOGNITION_ERROR_NETWORK); | 274 SpeechRecognitionError error(content::SPEECH_RECOGNITION_ERROR_NETWORK); |
275 std::string data; | 275 std::string data; |
276 | 276 |
277 // The default error code in case of parse errors is NETWORK_FAILURE, however | 277 // The default error code in case of parse errors is NETWORK_FAILURE, however |
278 // ParseServerResponse can change the error to a more appropriate one. | 278 // ParseServerResponse can change the error to a more appropriate one. |
279 bool error_occurred = (!source->GetStatus().is_success() || | 279 bool error_occurred = (!source->GetStatus().is_success() || |
280 source->GetResponseCode() != 200 || | 280 source->GetResponseCode() != 200 || |
281 !source->GetResponseAsString(&data) || | 281 !source->GetResponseAsString(&data) || |
(...skipping 10 matching lines...) Expand all Loading... |
292 | 292 |
293 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { | 293 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { |
294 return url_fetcher_ != NULL; | 294 return url_fetcher_ != NULL; |
295 } | 295 } |
296 | 296 |
297 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { | 297 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { |
298 return kAudioPacketIntervalMs; | 298 return kAudioPacketIntervalMs; |
299 } | 299 } |
300 | 300 |
301 } // namespace speech | 301 } // namespace speech |
OLD | NEW |