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

Side by Side Diff: content/public/browser/speech_recognition_manager.h

Issue 9972011: Speech refactoring: Reimplemented SpeechRecognitionManagerImpl as a FSM. (CL1.7) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed detach -> background. Created 8 years, 7 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 | Annotate | Revision Log
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_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_
6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_
7 7
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/callback.h"
9 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/public/common/speech_recognition_result.h"
10 12
11 namespace content { 13 namespace content {
12 14
13 // This is the gatekeeper for speech recognition in the browser process. It 15 class SpeechRecognitionEventListener;
14 // handles requests received from various render views and makes sure only one 16 struct SpeechRecognitionSessionConfig;
15 // of them can use speech recognition at a time. It also sends recognition 17 struct SpeechRecognitionSessionContext;
16 // results and status events to the render views when required. 18
17 class SpeechRecognitionManager { 19 // The SpeechRecognitionManager (SRM) is a singleton class that handles SR
20 // functionalities within Chrome. Everyone that needs to perform SR should
21 // interface exclusively with the SRM, receiving events through the callback
22 // interface SpeechRecognitionEventListener.
23 // Since many different sources can use SR in different times (some overlapping
24 // is allowed while waiting for results), the SRM has the further responsibility
25 // of handling separately and reliably (taking into account also call sequences
26 // that might not make sense, e.g., two subsequent AbortSession calls).
27 // In this sense a session, within the SRM, models the ongoing evolution of a
28 // SR request from the viewpoint of the end-user, abstracting all the concrete
29 // operations that must be carried out, that will be handled by inner classes.
30 class CONTENT_EXPORT SpeechRecognitionManager {
18 public: 31 public:
32 static const int kSessionIDInvalid;
33
19 // Returns the singleton instance. 34 // Returns the singleton instance.
20 CONTENT_EXPORT static SpeechRecognitionManager* GetInstance(); 35 static SpeechRecognitionManager* GetInstance();
21 36
22 // Starts/restarts recognition for an existing request. 37 // Creates a new recognition session.
23 virtual void StartRecognitionForRequest(int session_id) = 0; 38 virtual int CreateSession(const SpeechRecognitionSessionConfig& config,
39 SpeechRecognitionEventListener* listener) = 0;
24 40
25 // Cancels recognition for an existing request. 41 // Starts/restarts recognition for an existing session.
26 virtual void CancelRecognitionForRequest(int session_id) = 0; 42 virtual void StartSession(int session_id) = 0;
27 43
28 // Called when the user clicks outside the speech input UI causing it to close 44 // Aborts recognition for an existing session, without providing any result.
29 // and possibly have speech input go to another element. 45 virtual void AbortSession(int session_id) = 0;
30 virtual void FocusLostForRequest(int session_id) = 0; 46
47 // Aborts all sessions for a given listener, without providing any result.
48 virtual void AbortAllSessionsForListener(
49 SpeechRecognitionEventListener* listener) = 0;
50
51 // Stops audio capture for an existing session. The audio captured before the
52 // call will be processed, possibly ending up with a result.
53 virtual void StopAudioCaptureForSession(int session_id) = 0;
54
55 // Sends the session to background preventing it from interacting further with
56 // the browser (typically invoked when the user clicks outside the speech UI).
57 // The session will be silently continued in background if possible (in the
58 // case it already finished capturing audio and was just waiting for the
Satish 2012/04/24 10:48:08 'in case it already finished capturing audio' - th
Primiano Tucci (use gerrit) 2012/04/24 10:58:53 Done.
59 // result) or will be aborted if user interaction (e.g., audio recording) was
60 // involved when this function was called.
61 virtual void SendToBackgroundSession(int session_id) = 0;
Satish 2012/04/24 10:48:08 change to SendSessionToBackground
Primiano Tucci (use gerrit) 2012/04/24 10:58:53 Done.
62
63 // Retrieves the context associated to a session.
64 virtual SpeechRecognitionSessionContext GetSessionContext(
65 int session_id) const = 0;
66
67 // Looks-up an existing session using a caller-provided matcher function.
68 virtual int LookupSessionByContext(
69 base::Callback<bool(
70 const content::SpeechRecognitionSessionContext&)> matcher)
71 const = 0;
31 72
32 // Returns true if the OS reports existence of audio recording devices. 73 // Returns true if the OS reports existence of audio recording devices.
33 virtual bool HasAudioInputDevices() = 0; 74 virtual bool HasAudioInputDevices() = 0;
34 75
35 // Used to determine if something else is currently making use of audio input. 76 // Used to determine if something else is currently making use of audio input.
36 virtual bool IsCapturingAudio() = 0; 77 virtual bool IsCapturingAudio() = 0;
37 78
38 // Returns a human readable string for the model/make of the active audio 79 // Returns a human readable string for the model/make of the active audio
39 // input device for this computer. 80 // input device for this computer.
40 virtual string16 GetAudioInputDeviceModel() = 0; 81 virtual string16 GetAudioInputDeviceModel() = 0;
41 82
42 // Invokes the platform provided microphone settings UI in a non-blocking way, 83 // Invokes the platform provided microphone settings UI in a non-blocking way,
43 // via the BrowserThread::FILE thread. 84 // via the BrowserThread::FILE thread.
44 virtual void ShowAudioInputSettings() = 0; 85 virtual void ShowAudioInputSettings() = 0;
45 86
46 protected: 87 protected:
47 virtual ~SpeechRecognitionManager() {} 88 virtual ~SpeechRecognitionManager() {}
48 }; 89 };
49 90
50 } // namespace content 91 } // namespace content
51 92
52 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ 93 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/speech_recognition_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698