OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/app_list/speech_recognizer.h" | 5 #include "chrome/browser/ui/app_list/speech_recognizer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 148 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
149 if (session_ == kInvalidSessionId) | 149 if (session_ == kInvalidSessionId) |
150 return; | 150 return; |
151 | 151 |
152 // Prevent recursion. | 152 // Prevent recursion. |
153 int session = session_; | 153 int session = session_; |
154 session_ = kInvalidSessionId; | 154 session_ = kInvalidSessionId; |
155 StopSpeechTimeout(); | 155 StopSpeechTimeout(); |
156 content::SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession( | 156 content::SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession( |
157 session); | 157 session); |
| 158 weak_factory_.InvalidateWeakPtrs(); |
158 } | 159 } |
159 | 160 |
160 void SpeechRecognizer::EventListener::NotifyRecognitionStateChanged( | 161 void SpeechRecognizer::EventListener::NotifyRecognitionStateChanged( |
161 SpeechRecognitionState new_state) { | 162 SpeechRecognitionState new_state) { |
162 content::BrowserThread::PostTask( | 163 content::BrowserThread::PostTask( |
163 content::BrowserThread::UI, | 164 content::BrowserThread::UI, |
164 FROM_HERE, | 165 FROM_HERE, |
165 base::Bind(&SpeechRecognizerDelegate::OnSpeechRecognitionStateChanged, | 166 base::Bind(&SpeechRecognizerDelegate::OnSpeechRecognitionStateChanged, |
166 delegate_, | 167 delegate_, |
167 new_state)); | 168 new_state)); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 void SpeechRecognizer::Stop() { | 308 void SpeechRecognizer::Stop() { |
308 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 309 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
309 content::BrowserThread::PostTask( | 310 content::BrowserThread::PostTask( |
310 content::BrowserThread::IO, | 311 content::BrowserThread::IO, |
311 FROM_HERE, | 312 FROM_HERE, |
312 base::Bind(&SpeechRecognizer::EventListener::StopOnIOThread, | 313 base::Bind(&SpeechRecognizer::EventListener::StopOnIOThread, |
313 speech_event_listener_)); | 314 speech_event_listener_)); |
314 } | 315 } |
315 | 316 |
316 } // namespace app_list | 317 } // namespace app_list |
OLD | NEW |