OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "content/browser/renderer_host/media/media_stream_requester.h" | 15 #include "content/browser/renderer_host/media/media_stream_requester.h" |
16 #include "content/public/browser/speech_recognition_event_listener.h" | 16 #include "content/public/browser/speech_recognition_event_listener.h" |
17 #include "content/public/browser/speech_recognition_manager.h" | 17 #include "content/public/browser/speech_recognition_manager.h" |
18 #include "content/public/browser/speech_recognition_session_config.h" | 18 #include "content/public/browser/speech_recognition_session_config.h" |
19 #include "content/public/browser/speech_recognition_session_context.h" | 19 #include "content/public/browser/speech_recognition_session_context.h" |
20 #include "content/public/common/speech_recognition_error.h" | 20 #include "content/public/common/speech_recognition_error.h" |
21 | 21 |
22 namespace media { | 22 namespace media { |
23 class AudioSystem; | 23 class AudioSystem; |
| 24 class AudioManager; |
24 } | 25 } |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 class BrowserMainLoop; | 28 class BrowserMainLoop; |
28 class MediaStreamManager; | 29 class MediaStreamManager; |
29 class MediaStreamUIProxy; | 30 class MediaStreamUIProxy; |
30 class SpeechRecognitionManagerDelegate; | 31 class SpeechRecognitionManagerDelegate; |
31 class SpeechRecognizer; | 32 class SpeechRecognizer; |
32 | 33 |
33 // This is the manager for speech recognition. It is a single instance in | 34 // This is the manager for speech recognition. It is a single instance in |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 float noise_volume) override; | 91 float noise_volume) override; |
91 | 92 |
92 SpeechRecognitionManagerDelegate* delegate() const { return delegate_.get(); } | 93 SpeechRecognitionManagerDelegate* delegate() const { return delegate_.get(); } |
93 | 94 |
94 protected: | 95 protected: |
95 // BrowserMainLoop is the only one allowed to istantiate and free us. | 96 // BrowserMainLoop is the only one allowed to istantiate and free us. |
96 friend class BrowserMainLoop; | 97 friend class BrowserMainLoop; |
97 // Needed for dtor. | 98 // Needed for dtor. |
98 friend std::default_delete<SpeechRecognitionManagerImpl>; | 99 friend std::default_delete<SpeechRecognitionManagerImpl>; |
99 SpeechRecognitionManagerImpl(media::AudioSystem* audio_system, | 100 SpeechRecognitionManagerImpl(media::AudioSystem* audio_system, |
| 101 media::AudioManager* audio_manager, |
100 MediaStreamManager* media_stream_manager); | 102 MediaStreamManager* media_stream_manager); |
101 ~SpeechRecognitionManagerImpl() override; | 103 ~SpeechRecognitionManagerImpl() override; |
102 | 104 |
103 private: | 105 private: |
104 // Data types for the internal Finite State Machine (FSM). | 106 // Data types for the internal Finite State Machine (FSM). |
105 enum FSMState { | 107 enum FSMState { |
106 SESSION_STATE_IDLE = 0, | 108 SESSION_STATE_IDLE = 0, |
107 SESSION_STATE_CAPTURING_AUDIO, | 109 SESSION_STATE_CAPTURING_AUDIO, |
108 SESSION_STATE_WAITING_FOR_RESULT, | 110 SESSION_STATE_WAITING_FOR_RESULT, |
109 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT | 111 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 void SessionDelete(Session* session); | 167 void SessionDelete(Session* session); |
166 void NotFeasible(const Session& session, FSMEvent event); | 168 void NotFeasible(const Session& session, FSMEvent event); |
167 | 169 |
168 bool SessionExists(int session_id) const; | 170 bool SessionExists(int session_id) const; |
169 Session* GetSession(int session_id) const; | 171 Session* GetSession(int session_id) const; |
170 SpeechRecognitionEventListener* GetListener(int session_id) const; | 172 SpeechRecognitionEventListener* GetListener(int session_id) const; |
171 SpeechRecognitionEventListener* GetDelegateListener() const; | 173 SpeechRecognitionEventListener* GetDelegateListener() const; |
172 int GetNextSessionID(); | 174 int GetNextSessionID(); |
173 | 175 |
174 media::AudioSystem* audio_system_; | 176 media::AudioSystem* audio_system_; |
| 177 media::AudioManager* audio_manager_; |
175 MediaStreamManager* media_stream_manager_; | 178 MediaStreamManager* media_stream_manager_; |
176 typedef std::map<int, Session*> SessionsTable; | 179 typedef std::map<int, Session*> SessionsTable; |
177 SessionsTable sessions_; | 180 SessionsTable sessions_; |
178 int primary_session_id_; | 181 int primary_session_id_; |
179 int last_session_id_; | 182 int last_session_id_; |
180 bool is_dispatching_event_; | 183 bool is_dispatching_event_; |
181 std::unique_ptr<SpeechRecognitionManagerDelegate> delegate_; | 184 std::unique_ptr<SpeechRecognitionManagerDelegate> delegate_; |
182 | 185 |
183 // Used for posting asynchronous tasks (on the IO thread) without worrying | 186 // Used for posting asynchronous tasks (on the IO thread) without worrying |
184 // about this class being destroyed in the meanwhile (due to browser shutdown) | 187 // about this class being destroyed in the meanwhile (due to browser shutdown) |
185 // since tasks pending on a destroyed WeakPtr are automatically discarded. | 188 // since tasks pending on a destroyed WeakPtr are automatically discarded. |
186 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; | 189 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; |
187 }; | 190 }; |
188 | 191 |
189 } // namespace content | 192 } // namespace content |
190 | 193 |
191 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ | 194 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
OLD | NEW |