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" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "chrome/browser/ui/app_list/speech_recognizer_delegate.h" | 12 #include "chrome/browser/ui/app_list/speech_recognizer_delegate.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/browser/speech_recognition_event_listener.h" | 15 #include "content/public/browser/speech_recognition_event_listener.h" |
16 #include "content/public/browser/speech_recognition_manager.h" | 16 #include "content/public/browser/speech_recognition_manager.h" |
17 #include "content/public/browser/speech_recognition_session_config.h" | 17 #include "content/public/browser/speech_recognition_session_config.h" |
18 #include "content/public/browser/speech_recognition_session_preamble.h" | 18 #include "content/public/browser/speech_recognition_session_preamble.h" |
19 #include "content/public/common/child_process_host.h" | 19 #include "content/public/common/child_process_host.h" |
20 #include "content/public/common/speech_recognition_error.h" | 20 #include "content/public/common/speech_recognition_error.h" |
21 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
22 #include "ui/app_list/speech_ui_model_observer.h" | 22 #include "ui/app_list/speech_ui_model_observer.h" |
23 | 23 |
24 namespace app_list { | 24 namespace app_list { |
25 | 25 |
26 // Length of timeout to cancel recognition if there's no speech heard. | 26 // Length of timeout to cancel recognition if there's no speech heard. |
27 static const int kNoSpeechTimeoutInSeconds = 5; | 27 static const int kNoSpeechTimeoutInSeconds = 5; |
28 | 28 |
29 // Length of timeout to cancel recognition if no different results are received. | 29 // Length of timeout to cancel recognition if no different results are received. |
30 static const int kNoNewSpeechTimeoutInSeconds = 3; | 30 static const int kNoNewSpeechTimeoutInSeconds = 2; |
31 | 31 |
32 // Invalid speech session. | 32 // Invalid speech session. |
33 static const int kInvalidSessionId = -1; | 33 static const int kInvalidSessionId = -1; |
34 | 34 |
35 // Speech recognizer listener. This is separate from SpeechRecognizer because | 35 // Speech recognizer listener. This is separate from SpeechRecognizer because |
36 // the speech recognition engine must function from the IO thread. Because of | 36 // the speech recognition engine must function from the IO thread. Because of |
37 // this, the lifecycle of this class must be decoupled from the lifecycle of | 37 // this, the lifecycle of this class must be decoupled from the lifecycle of |
38 // SpeechRecognizer. To avoid circular references, this class has no reference | 38 // SpeechRecognizer. To avoid circular references, this class has no reference |
39 // to SpeechRecognizer. Instead, it has a reference to the | 39 // to SpeechRecognizer. Instead, it has a reference to the |
40 // SpeechRecognizerDelegate via a weak pointer that is only ever referenced from | 40 // SpeechRecognizerDelegate via a weak pointer that is only ever referenced from |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 void SpeechRecognizer::Stop() { | 307 void SpeechRecognizer::Stop() { |
308 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 308 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
309 content::BrowserThread::PostTask( | 309 content::BrowserThread::PostTask( |
310 content::BrowserThread::IO, | 310 content::BrowserThread::IO, |
311 FROM_HERE, | 311 FROM_HERE, |
312 base::Bind(&SpeechRecognizer::EventListener::StopOnIOThread, | 312 base::Bind(&SpeechRecognizer::EventListener::StopOnIOThread, |
313 speech_event_listener_)); | 313 speech_event_listener_)); |
314 } | 314 } |
315 | 315 |
316 } // namespace app_list | 316 } // namespace app_list |
OLD | NEW |