| Index: content/browser/speech/speech_recognition_dispatcher_host.cc
|
| diff --git a/content/browser/speech/speech_recognition_dispatcher_host.cc b/content/browser/speech/speech_recognition_dispatcher_host.cc
|
| index 1b42f2f911fe3a7f7036eea1c3eb2a337cdc3b53..452a4dec268fe401572dceb93f022cd3aaa94cbe 100644
|
| --- a/content/browser/speech/speech_recognition_dispatcher_host.cc
|
| +++ b/content/browser/speech/speech_recognition_dispatcher_host.cc
|
| @@ -26,14 +26,22 @@ SpeechRecognitionDispatcherHost::SpeechRecognitionDispatcherHost(
|
| : BrowserMessageFilter(SpeechRecognitionMsgStart),
|
| is_guest_(is_guest),
|
| render_process_id_(render_process_id),
|
| - context_getter_(context_getter) {
|
| + context_getter_(context_getter),
|
| + weak_factory_(this) {
|
| // Do not add any non-trivial initialization here, instead do it lazily when
|
| // required (e.g. see the method |SpeechRecognitionManager::GetInstance()|) or
|
| // add an Init() method.
|
| }
|
|
|
| SpeechRecognitionDispatcherHost::~SpeechRecognitionDispatcherHost() {
|
| - SpeechRecognitionManager::GetInstance()->AbortAllSessionsForListener(this);
|
| + SpeechRecognitionManager::GetInstance()->AbortAllSessionsForRenderProcess(
|
| + render_process_id_);
|
| + weak_factory_.InvalidateWeakPtrs();
|
| +}
|
| +
|
| +base::WeakPtr<SpeechRecognitionDispatcherHost>
|
| +SpeechRecognitionDispatcherHost::AsWeakPtr() {
|
| + return weak_factory_.GetWeakPtr();
|
| }
|
|
|
| bool SpeechRecognitionDispatcherHost::OnMessageReceived(
|
| @@ -59,6 +67,10 @@ void SpeechRecognitionDispatcherHost::OverrideThreadForMessage(
|
| *thread = BrowserThread::UI;
|
| }
|
|
|
| +void SpeechRecognitionDispatcherHost::OnChannelClosing() {
|
| + weak_factory_.InvalidateWeakPtrs();
|
| +}
|
| +
|
| void SpeechRecognitionDispatcherHost::OnStartRequest(
|
| const SpeechRecognitionHostMsg_StartRequest_Params& params) {
|
| SpeechRecognitionHostMsg_StartRequest_Params input_params(params);
|
| @@ -129,7 +141,7 @@ void SpeechRecognitionDispatcherHost::OnStartRequestOnIO(
|
| config.filter_profanities = filter_profanities;
|
| config.continuous = params.continuous;
|
| config.interim_results = params.interim_results;
|
| - config.event_listener = this;
|
| + config.event_listener = this->AsWeakPtr();
|
|
|
| int session_id = SpeechRecognitionManager::GetInstance()->CreateSession(
|
| config);
|
|
|