Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_APP_LIST_SPEECH_RECOGNIZER_H_ | |
| 6 #define CHROME_BROWSER_UI_APP_LIST_SPEECH_RECOGNIZER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 | |
| 12 namespace net { | |
| 13 class URLRequestContextGetter; | |
| 14 } | |
| 15 | |
| 16 namespace app_list { | |
| 17 | |
| 18 class SpeechRecognizerDelegate; | |
| 19 | |
| 20 // SpeechRecognizer is a wrapper around the speech recognition engine that | |
| 21 // simplifies its use from the UI thread. This class handles all setup/shutdown, | |
| 22 // collection of results, error cases, and threading. | |
| 23 class SpeechRecognizer { | |
| 24 public: | |
| 25 SpeechRecognizer(SpeechRecognizerDelegate* delegate, | |
| 26 net::URLRequestContextGetter* url_request_context_getter, | |
| 27 const std::string& locale); | |
| 28 ~SpeechRecognizer(); | |
| 29 | |
| 30 // Start/stop the speech recognizer. Must be called on the UI thread. | |
| 31 void Start(); | |
| 32 void Stop(); | |
| 33 | |
| 34 private: | |
| 35 class EventListener; | |
| 36 | |
| 37 SpeechRecognizerDelegate* delegate_; // Not owned. | |
|
Lei Zhang
2014/11/05 03:44:38
Can you just use save the content::WebContents* in
Anand Mistry (off Chromium)
2014/11/05 04:44:11
No, because it might change. However, the current
| |
| 38 scoped_refptr<EventListener> speech_event_listener_; | |
| 39 | |
| 40 // Weak pointer to pass to EventListener. | |
| 41 base::WeakPtrFactory<SpeechRecognizerDelegate> delegate_weak_factory_; | |
|
Lei Zhang
2014/11/05 03:44:38
The delegate should have its own WeakPtrFactory()
Anand Mistry (off Chromium)
2014/11/05 04:44:11
Done.
| |
| 42 | |
| 43 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); | |
| 44 }; | |
| 45 | |
| 46 } // namespace app_list | |
| 47 | |
| 48 #endif // CHROME_BROWSER_UI_APP_LIST_SPEECH_RECOGNIZER_H_ | |
| OLD | NEW |