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

Unified Diff: content/browser/speech/speech_recognition_manager_impl.cc

Issue 10071040: Fixed a memory leak in SpeechRecognitionManagerImpl causing ChromeSpeechInputManagerDelegate to be … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits. Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/speech/speech_recognition_manager_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/speech/speech_recognition_manager_impl.cc
diff --git a/content/browser/speech/speech_recognition_manager_impl.cc b/content/browser/speech/speech_recognition_manager_impl.cc
index 7600b508093f9fee129e2d25f94f9f52e1959c92..cd44c533456a8dac6ac10ba73ad3b1ad399efcae 100644
--- a/content/browser/speech/speech_recognition_manager_impl.cc
+++ b/content/browser/speech/speech_recognition_manager_impl.cc
@@ -73,8 +73,8 @@ SpeechRecognitionManagerImpl* SpeechRecognitionManagerImpl::GetInstance() {
SpeechRecognitionManagerImpl::SpeechRecognitionManagerImpl()
: can_report_metrics_(false),
recording_caller_id_(0) {
- delegate_ = content::GetContentClient()->browser()->
- GetSpeechRecognitionManagerDelegate();
+ delegate_.reset(content::GetContentClient()->browser()->
+ GetSpeechRecognitionManagerDelegate());
}
SpeechRecognitionManagerImpl::~SpeechRecognitionManagerImpl() {
@@ -172,7 +172,7 @@ void SpeechRecognitionManagerImpl::ProceedStartingRecognition(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!HasPendingRequest(params.caller_id));
- if (delegate_) {
+ if (delegate_ != NULL) {
jam 2012/04/13 18:19:54 by convention we don't do if (foo != NULL), but ju
Primiano Tucci (use gerrit) 2012/04/16 08:47:37 Ah, I am sorry, I was not aware. I fixed it. Can I
delegate_->ShowRecognitionRequested(
params.caller_id, params.render_process_id, params.render_view_id,
params.element_rect);
@@ -206,7 +206,7 @@ void SpeechRecognitionManagerImpl::StartRecognitionForRequest(int caller_id) {
recording_caller_id_ = caller_id;
requests_[caller_id].is_active = true;
requests_[caller_id].recognizer->StartRecognition();
- if (delegate_)
+ if (delegate_ != NULL)
delegate_->ShowWarmUp(caller_id);
}
@@ -240,7 +240,7 @@ void SpeechRecognitionManagerImpl::CancelRecognition(int caller_id) {
requests_.erase(caller_id);
if (recording_caller_id_ == caller_id)
recording_caller_id_ = 0;
- if (delegate_)
+ if (delegate_ != NULL)
delegate_->DoClose(caller_id);
}
@@ -283,7 +283,7 @@ void SpeechRecognitionManagerImpl::OnAudioEnd(int caller_id) {
return;
recording_caller_id_ = 0;
GetDelegate(caller_id)->DidCompleteRecording(caller_id);
- if (delegate_)
+ if (delegate_ != NULL)
delegate_->ShowRecognizing(caller_id);
}
@@ -292,7 +292,7 @@ void SpeechRecognitionManagerImpl::OnRecognitionEnd(int caller_id) {
return;
GetDelegate(caller_id)->DidCompleteRecognition(caller_id);
requests_.erase(caller_id);
- if (delegate_)
+ if (delegate_ != NULL)
delegate_->DoClose(caller_id);
}
@@ -308,7 +308,7 @@ void SpeechRecognitionManagerImpl::OnRecognitionError(
if (caller_id == recording_caller_id_)
recording_caller_id_ = 0;
requests_[caller_id].is_active = false;
- if (delegate_) {
+ if (delegate_ != NULL) {
if (error.code == content::SPEECH_RECOGNITION_ERROR_AUDIO &&
error.details == content::SPEECH_AUDIO_ERROR_DETAILS_NO_MIC) {
delegate_->ShowMicError(caller_id,
@@ -326,7 +326,7 @@ void SpeechRecognitionManagerImpl::OnRecognitionError(
void SpeechRecognitionManagerImpl::OnAudioStart(int caller_id) {
DCHECK(HasPendingRequest(caller_id));
DCHECK_EQ(recording_caller_id_, caller_id);
- if (delegate_)
+ if (delegate_ != NULL)
delegate_->ShowRecording(caller_id);
}
@@ -343,7 +343,7 @@ void SpeechRecognitionManagerImpl::OnAudioLevelsChange(
int caller_id, float volume, float noise_volume) {
DCHECK(HasPendingRequest(caller_id));
DCHECK_EQ(recording_caller_id_, caller_id);
- if (delegate_)
+ if (delegate_ != NULL)
delegate_->ShowInputVolume(caller_id, volume, noise_volume);
}
@@ -356,8 +356,7 @@ void SpeechRecognitionManagerImpl::CancelRecognitionAndInformDelegate(
}
SpeechRecognitionManagerImpl::Request::Request()
- : delegate(NULL),
- is_active(false) {
+ : is_active(false) {
}
SpeechRecognitionManagerImpl::Request::~Request() {
« no previous file with comments | « content/browser/speech/speech_recognition_manager_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698