| 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> |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 struct Session { | 124 struct Session { |
| 125 Session(); | 125 Session(); |
| 126 ~Session(); | 126 ~Session(); |
| 127 | 127 |
| 128 int id; | 128 int id; |
| 129 bool abort_requested; | 129 bool abort_requested; |
| 130 bool listener_is_active; | 130 bool listener_is_active; |
| 131 SpeechRecognitionSessionConfig config; | 131 SpeechRecognitionSessionConfig config; |
| 132 SpeechRecognitionSessionContext context; | 132 SpeechRecognitionSessionContext context; |
| 133 scoped_refptr<SpeechRecognizer> recognizer; | 133 scoped_refptr<SpeechRecognizer> recognizer; |
| 134 scoped_ptr<MediaStreamUIProxy> ui; | 134 std::unique_ptr<MediaStreamUIProxy> ui; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 // Callback issued by the SpeechRecognitionManagerDelegate for reporting | 137 // Callback issued by the SpeechRecognitionManagerDelegate for reporting |
| 138 // asynchronously the result of the CheckRecognitionIsAllowed call. | 138 // asynchronously the result of the CheckRecognitionIsAllowed call. |
| 139 void RecognitionAllowedCallback(int session_id, | 139 void RecognitionAllowedCallback(int session_id, |
| 140 bool ask_user, | 140 bool ask_user, |
| 141 bool is_allowed); | 141 bool is_allowed); |
| 142 | 142 |
| 143 // Callback to get back the result of a media request. |devices| is an array | 143 // Callback to get back the result of a media request. |devices| is an array |
| 144 // of devices approved to be used for the request, |devices| is empty if the | 144 // of devices approved to be used for the request, |devices| is empty if the |
| 145 // users deny the request. | 145 // users deny the request. |
| 146 void MediaRequestPermissionCallback(int session_id, | 146 void MediaRequestPermissionCallback( |
| 147 const MediaStreamDevices& devices, | 147 int session_id, |
| 148 scoped_ptr<MediaStreamUIProxy> stream_ui); | 148 const MediaStreamDevices& devices, |
| 149 std::unique_ptr<MediaStreamUIProxy> stream_ui); |
| 149 | 150 |
| 150 // Entry point for pushing any external event into the session handling FSM. | 151 // Entry point for pushing any external event into the session handling FSM. |
| 151 void DispatchEvent(int session_id, FSMEvent event); | 152 void DispatchEvent(int session_id, FSMEvent event); |
| 152 | 153 |
| 153 // Defines the behavior of the session handling FSM, selecting the appropriate | 154 // Defines the behavior of the session handling FSM, selecting the appropriate |
| 154 // transition according to the session, its current state and the event. | 155 // transition according to the session, its current state and the event. |
| 155 void ExecuteTransitionAndGetNextState(Session* session, | 156 void ExecuteTransitionAndGetNextState(Session* session, |
| 156 FSMState session_state, | 157 FSMState session_state, |
| 157 FSMEvent event); | 158 FSMEvent event); |
| 158 | 159 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 173 SpeechRecognitionEventListener* GetDelegateListener() const; | 174 SpeechRecognitionEventListener* GetDelegateListener() const; |
| 174 int GetNextSessionID(); | 175 int GetNextSessionID(); |
| 175 | 176 |
| 176 media::AudioManager* audio_manager_; | 177 media::AudioManager* audio_manager_; |
| 177 MediaStreamManager* media_stream_manager_; | 178 MediaStreamManager* media_stream_manager_; |
| 178 typedef std::map<int, Session*> SessionsTable; | 179 typedef std::map<int, Session*> SessionsTable; |
| 179 SessionsTable sessions_; | 180 SessionsTable sessions_; |
| 180 int primary_session_id_; | 181 int primary_session_id_; |
| 181 int last_session_id_; | 182 int last_session_id_; |
| 182 bool is_dispatching_event_; | 183 bool is_dispatching_event_; |
| 183 scoped_ptr<SpeechRecognitionManagerDelegate> delegate_; | 184 std::unique_ptr<SpeechRecognitionManagerDelegate> delegate_; |
| 184 | 185 |
| 185 // Used for posting asynchronous tasks (on the IO thread) without worrying | 186 // Used for posting asynchronous tasks (on the IO thread) without worrying |
| 186 // 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) |
| 187 // since tasks pending on a destroyed WeakPtr are automatically discarded. | 188 // since tasks pending on a destroyed WeakPtr are automatically discarded. |
| 188 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; | 189 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; |
| 189 }; | 190 }; |
| 190 | 191 |
| 191 } // namespace content | 192 } // namespace content |
| 192 | 193 |
| 193 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ | 194 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
| OLD | NEW |