Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: content/browser/speech/speech_recognition_manager_impl.h

Issue 2651373002: Removing SpeechRecognitionManager::HasAudioInputDevices() and ShowAudioInputSettings() (Closed)
Patch Set: fix for tests Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
23 class AudioManager;
24 }
25
26 namespace content { 22 namespace content {
27 class BrowserMainLoop; 23 class BrowserMainLoop;
28 class MediaStreamManager; 24 class MediaStreamManager;
29 class MediaStreamUIProxy; 25 class MediaStreamUIProxy;
30 class SpeechRecognitionManagerDelegate; 26 class SpeechRecognitionManagerDelegate;
31 class SpeechRecognizer; 27 class SpeechRecognizer;
32 28
33 // This is the manager for speech recognition. It is a single instance in 29 // This is the manager for speech recognition. It is a single instance in
34 // the browser process and can serve several requests. Each recognition request 30 // the browser process and can serve several requests. Each recognition request
35 // corresponds to a session, initiated via |CreateSession|. 31 // corresponds to a session, initiated via |CreateSession|.
(...skipping 29 matching lines...) Expand all
65 void AbortAllSessionsForRenderView(int render_process_id, 61 void AbortAllSessionsForRenderView(int render_process_id,
66 int render_view_id) override; 62 int render_view_id) override;
67 void StopAudioCaptureForSession(int session_id) override; 63 void StopAudioCaptureForSession(int session_id) override;
68 const SpeechRecognitionSessionConfig& GetSessionConfig( 64 const SpeechRecognitionSessionConfig& GetSessionConfig(
69 int session_id) const override; 65 int session_id) const override;
70 SpeechRecognitionSessionContext GetSessionContext( 66 SpeechRecognitionSessionContext GetSessionContext(
71 int session_id) const override; 67 int session_id) const override;
72 int GetSession(int render_process_id, 68 int GetSession(int render_process_id,
73 int render_view_id, 69 int render_view_id,
74 int request_id) const override; 70 int request_id) const override;
75 bool HasAudioInputDevices() override;
76 void ShowAudioInputSettings() override;
77 71
78 // SpeechRecognitionEventListener methods. 72 // SpeechRecognitionEventListener methods.
79 void OnRecognitionStart(int session_id) override; 73 void OnRecognitionStart(int session_id) override;
80 void OnAudioStart(int session_id) override; 74 void OnAudioStart(int session_id) override;
81 void OnEnvironmentEstimationComplete(int session_id) override; 75 void OnEnvironmentEstimationComplete(int session_id) override;
82 void OnSoundStart(int session_id) override; 76 void OnSoundStart(int session_id) override;
83 void OnSoundEnd(int session_id) override; 77 void OnSoundEnd(int session_id) override;
84 void OnAudioEnd(int session_id) override; 78 void OnAudioEnd(int session_id) override;
85 void OnRecognitionEnd(int session_id) override; 79 void OnRecognitionEnd(int session_id) override;
86 void OnRecognitionResults(int session_id, 80 void OnRecognitionResults(int session_id,
87 const SpeechRecognitionResults& result) override; 81 const SpeechRecognitionResults& result) override;
88 void OnRecognitionError(int session_id, 82 void OnRecognitionError(int session_id,
89 const SpeechRecognitionError& error) override; 83 const SpeechRecognitionError& error) override;
90 void OnAudioLevelsChange(int session_id, 84 void OnAudioLevelsChange(int session_id,
91 float volume, 85 float volume,
92 float noise_volume) override; 86 float noise_volume) override;
93 87
94 SpeechRecognitionManagerDelegate* delegate() const { return delegate_.get(); } 88 SpeechRecognitionManagerDelegate* delegate() const { return delegate_.get(); }
95 89
96 protected: 90 protected:
97 // BrowserMainLoop is the only one allowed to istantiate and free us. 91 // BrowserMainLoop is the only one allowed to istantiate and free us.
98 friend class BrowserMainLoop; 92 friend class BrowserMainLoop;
99 // Needed for dtor. 93 // Needed for dtor.
100 friend std::default_delete<SpeechRecognitionManagerImpl>; 94 friend std::default_delete<SpeechRecognitionManagerImpl>;
101 SpeechRecognitionManagerImpl(media::AudioManager* audio_manager, 95 SpeechRecognitionManagerImpl(MediaStreamManager* media_stream_manager);
102 MediaStreamManager* media_stream_manager);
103 ~SpeechRecognitionManagerImpl() override; 96 ~SpeechRecognitionManagerImpl() override;
104 97
105 private: 98 private:
106 // Data types for the internal Finite State Machine (FSM). 99 // Data types for the internal Finite State Machine (FSM).
107 enum FSMState { 100 enum FSMState {
108 SESSION_STATE_IDLE = 0, 101 SESSION_STATE_IDLE = 0,
109 SESSION_STATE_CAPTURING_AUDIO, 102 SESSION_STATE_CAPTURING_AUDIO,
110 SESSION_STATE_WAITING_FOR_RESULT, 103 SESSION_STATE_WAITING_FOR_RESULT,
111 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT 104 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT
112 }; 105 };
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void ResetCapturingSessionId(const Session& session); 159 void ResetCapturingSessionId(const Session& session);
167 void SessionDelete(Session* session); 160 void SessionDelete(Session* session);
168 void NotFeasible(const Session& session, FSMEvent event); 161 void NotFeasible(const Session& session, FSMEvent event);
169 162
170 bool SessionExists(int session_id) const; 163 bool SessionExists(int session_id) const;
171 Session* GetSession(int session_id) const; 164 Session* GetSession(int session_id) const;
172 SpeechRecognitionEventListener* GetListener(int session_id) const; 165 SpeechRecognitionEventListener* GetListener(int session_id) const;
173 SpeechRecognitionEventListener* GetDelegateListener() const; 166 SpeechRecognitionEventListener* GetDelegateListener() const;
174 int GetNextSessionID(); 167 int GetNextSessionID();
175 168
176 media::AudioManager* audio_manager_;
177 MediaStreamManager* media_stream_manager_; 169 MediaStreamManager* media_stream_manager_;
178 typedef std::map<int, Session*> SessionsTable; 170 typedef std::map<int, Session*> SessionsTable;
179 SessionsTable sessions_; 171 SessionsTable sessions_;
180 int primary_session_id_; 172 int primary_session_id_;
181 int last_session_id_; 173 int last_session_id_;
182 bool is_dispatching_event_; 174 bool is_dispatching_event_;
183 std::unique_ptr<SpeechRecognitionManagerDelegate> delegate_; 175 std::unique_ptr<SpeechRecognitionManagerDelegate> delegate_;
184 176
185 // Used for posting asynchronous tasks (on the IO thread) without worrying 177 // Used for posting asynchronous tasks (on the IO thread) without worrying
186 // about this class being destroyed in the meanwhile (due to browser shutdown) 178 // about this class being destroyed in the meanwhile (due to browser shutdown)
187 // since tasks pending on a destroyed WeakPtr are automatically discarded. 179 // since tasks pending on a destroyed WeakPtr are automatically discarded.
188 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; 180 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_;
189 }; 181 };
190 182
191 } // namespace content 183 } // namespace content
192 184
193 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ 185 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/speech/speech_recognition_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698