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

Unified Diff: chrome/browser/speech/speech_recognizer.cc

Issue 6381004: Fix a potential assert in SpeechRecognizer dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/speech/speech_recognizer.cc
diff --git a/chrome/browser/speech/speech_recognizer.cc b/chrome/browser/speech/speech_recognizer.cc
index 38bbeca5be7af4e2d5c10ebc7f42df608f0aa023..113600ba9428a8bf1e03dd24cb7bf5cc17c7c6c6 100644
--- a/chrome/browser/speech/speech_recognizer.cc
+++ b/chrome/browser/speech/speech_recognizer.cc
@@ -129,8 +129,12 @@ void SpeechRecognizer::StopRecording() {
// Since the http request takes a single string as POST data, allocate
// one and copy over bytes from the audio buffers to the string.
// And If we haven't got any audio yet end the recognition sequence here.
+ string mime_type = encoder_->mime_type();
string data;
- if (!encoder_->GetEncodedData(&data)) {
+ encoder_->GetEncodedData(&data);
+ encoder_.reset();
+
+ if (data.empty()) {
// Guard against the delegate freeing us until we finish our job.
scoped_refptr<SpeechRecognizer> me(this);
delegate_->DidCompleteRecognition(caller_id_);
@@ -139,9 +143,8 @@ void SpeechRecognizer::StopRecording() {
request_.reset(new SpeechRecognitionRequest(
Profile::GetDefaultRequestContext(), this));
request_->Send(language_, grammar_, hardware_info_, origin_url_,
- encoder_->mime_type(), data);
+ mime_type, data);
}
- encoder_.reset();
}
void SpeechRecognizer::ReleaseAudioBuffers() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698