diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-16 11:31:15 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-16 11:31:15 +0000 |
commit | 13167fff3ada75bd8c8dd8c6acc558d64ecde053 (patch) | |
tree | ca27eb32a3340db4ac10c077583c3a7082423ec9 /content/browser/speech/speech_recognizer.h | |
parent | 251ca36b35f7a9faef360c70acc84fc9a3ad1c40 (diff) | |
download | chromium_src-13167fff3ada75bd8c8dd8c6acc558d64ecde053.zip chromium_src-13167fff3ada75bd8c8dd8c6acc558d64ecde053.tar.gz chromium_src-13167fff3ada75bd8c8dd8c6acc558d64ecde053.tar.bz2 |
Move SpeechRecognizer delegate into its own header file and put it in the content namespace.
This reverts commit 3942a25369d4e15de6c47b0c1df59827eec49a5e.
This avoids having a nested class as it leads to too many includes in headers.
This fixes the two issues raised by Win bots:
- It includes speech_recognizer.h in certain source files to silence the warnings.
- It tags SpeechRecognizerDelegate with CONTENT_EXPORT because SpeechInputManager is deriving from it and it's tagged with CONTENT_EXPORT, so we have to export the base class to silence the warning on Windows.
BUG=98716
R=jam@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9388038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122276 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/speech/speech_recognizer.h')
-rw-r--r-- | content/browser/speech/speech_recognizer.h | 67 |
1 files changed, 8 insertions, 59 deletions
diff --git a/content/browser/speech/speech_recognizer.h b/content/browser/speech/speech_recognizer.h index 1e26754..67b1732 100644 --- a/content/browser/speech/speech_recognizer.h +++ b/content/browser/speech/speech_recognizer.h @@ -18,6 +18,10 @@ #include "content/public/common/speech_input_result.h" #include "media/audio/audio_input_controller.h" +namespace content { +class SpeechRecognizerDelegate; +} + namespace net { class URLRequestContextGetter; } @@ -31,57 +35,7 @@ class CONTENT_EXPORT SpeechRecognizer public media::AudioInputController::EventHandler, public SpeechRecognitionRequestDelegate { public: - // Implemented by the caller to receive recognition events. - class CONTENT_EXPORT Delegate { - public: - virtual void SetRecognitionResult( - int caller_id, - const content::SpeechInputResult& result) = 0; - - // Invoked when the first audio packet was received from the audio capture - // device. - virtual void DidStartReceivingAudio(int caller_id) = 0; - - // Invoked when audio recording stops, either due to the end pointer - // detecting silence in user input or if |StopRecording| was called. The - // delegate has to wait until |DidCompleteRecognition| is invoked before - // destroying the |SpeechRecognizer| object. - virtual void DidCompleteRecording(int caller_id) = 0; - - // This is guaranteed to be the last method invoked in the recognition - // sequence and the |SpeechRecognizer| object can be freed up if necessary. - virtual void DidCompleteRecognition(int caller_id) = 0; - - // Informs that the end pointer has started detecting speech. - virtual void DidStartReceivingSpeech(int caller_id) = 0; - - // Informs that the end pointer has stopped detecting speech. - virtual void DidStopReceivingSpeech(int caller_id) = 0; - - // Invoked if there was an error while recording or recognizing audio. The - // session has already been cancelled when this call is made and the DidXxxx - // callbacks will not be issued. It is safe to destroy/release the - // |SpeechRecognizer| object while processing this call. - virtual void OnRecognizerError(int caller_id, - content::SpeechInputError error) = 0; - - // At the start of recognition, a short amount of audio is recorded to - // estimate the environment/background noise and this callback is issued - // after that is complete. Typically the delegate brings up any speech - // recognition UI once this callback is received. - virtual void DidCompleteEnvironmentEstimation(int caller_id) = 0; - - // Informs of a change in the captured audio level, useful if displaying - // a microphone volume indicator while recording. - // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range. - virtual void SetInputVolume(int caller_id, float volume, - float noise_volume) = 0; - - protected: - virtual ~Delegate() {} - }; - - SpeechRecognizer(Delegate* delegate, + SpeechRecognizer(content::SpeechRecognizerDelegate* delegate, int caller_id, const std::string& language, const std::string& grammar, @@ -96,7 +50,8 @@ class CONTENT_EXPORT SpeechRecognizer // Starts audio recording and does recognition after recording ends. The same // SpeechRecognizer instance can be used multiple times for speech recognition // though each recognition request can be made only after the previous one - // completes (i.e. after receiving Delegate::DidCompleteRecognition). + // completes (i.e. after receiving + // SpeechRecognizerDelegate::DidCompleteRecognition). bool StartRecording(); // Stops recording audio and starts recognition. @@ -140,7 +95,7 @@ class CONTENT_EXPORT SpeechRecognizer // Helper method which closes the audio controller and blocks until done. void CloseAudioControllerSynchronously(); - Delegate* delegate_; + content::SpeechRecognizerDelegate* delegate_; int caller_id_; std::string language_; std::string grammar_; @@ -161,12 +116,6 @@ class CONTENT_EXPORT SpeechRecognizer DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); }; -// This typedef is to workaround the issue with certain versions of -// Visual Studio where it gets confused between multiple Delegate -// classes and gives a C2500 error. (I saw this error on the try bots - -// the workaround was not needed for my machine). -typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate; - } // namespace speech_input #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ |