summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorprimiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-16 14:37:13 +0000
committerprimiano@chromium.org <primiano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-16 14:37:13 +0000
commit1f8fa2bd3c39b4eacc6a63b0eca5610acaee987b (patch)
tree5bb93e83b16d425663752c6f4634abb77c59dced /content
parent607e5de91bf57cdf7ab3cd26242849226b4cff41 (diff)
downloadchromium_src-1f8fa2bd3c39b4eacc6a63b0eca5610acaee987b.zip
chromium_src-1f8fa2bd3c39b4eacc6a63b0eca5610acaee987b.tar.gz
chromium_src-1f8fa2bd3c39b4eacc6a63b0eca5610acaee987b.tar.bz2
Fixed a memory leak in SpeechRecognitionManagerImpl causing ChromeSpeechInputManagerDelegate to be never freed.
BUG=123116,116954 TEST=Run Valgrind tests. Review URL: https://chromiumcodereview.appspot.com/10071040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/speech/speech_recognition_manager_impl.cc23
-rw-r--r--content/browser/speech/speech_recognition_manager_impl.h3
2 files changed, 13 insertions, 13 deletions
diff --git a/content/browser/speech/speech_recognition_manager_impl.cc b/content/browser/speech/speech_recognition_manager_impl.cc
index 7600b50..ed69eed 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_.get()) {
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_.get())
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_.get())
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_.get())
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_.get())
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_.get()) {
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_.get())
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_.get())
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() {
diff --git a/content/browser/speech/speech_recognition_manager_impl.h b/content/browser/speech/speech_recognition_manager_impl.h
index f063a15..bb38cec 100644
--- a/content/browser/speech/speech_recognition_manager_impl.h
+++ b/content/browser/speech/speech_recognition_manager_impl.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "content/public/browser/speech_recognition_event_listener.h"
#include "content/public/browser/speech_recognition_manager.h"
@@ -119,7 +120,7 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl
std::string request_info_;
bool can_report_metrics_;
int recording_caller_id_;
- content::SpeechRecognitionManagerDelegate* delegate_;
+ scoped_ptr<content::SpeechRecognitionManagerDelegate> delegate_;
};
} // namespace speech