Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ | |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "content/common/content_export.h" | |
| 11 #include "content/public/browser/browser_message_filter.h" | |
| 12 #include "content/public/browser/speech_recognition_event_listener.h" | |
| 13 #include "net/url_request/url_request_context_getter.h" | |
| 14 | |
| 15 struct SpeechRecognitionHostMsg_StartRequest_Params; | |
| 16 | |
| 17 namespace content { | |
| 18 class SpeechRecognitionPreferences; | |
| 19 struct SpeechRecognitionResult; | |
| 20 } | |
| 21 | |
| 22 namespace speech { | |
| 23 | |
| 24 class SpeechRecognitionManagerImpl; | |
| 25 | |
| 26 // SpeechRecognitionDispatcherHost is a delegate for Speech API messages used by | |
| 27 // RenderMessageFilter. Basically it acts as a proxy, relaying the events coming | |
| 28 // from the SpeechRecognitionManager to IPC messages (and vice versa). | |
| 29 // It's the complement of SpeechRecognitionDispatcher (owned by RenderView). | |
| 30 class CONTENT_EXPORT SpeechRecognitionDispatcherHost | |
| 31 : public content::BrowserMessageFilter, | |
| 32 public content::SpeechRecognitionEventListener { | |
| 33 public: | |
| 34 SpeechRecognitionDispatcherHost( | |
| 35 int render_process_id, | |
| 36 net::URLRequestContextGetter* context_getter, | |
| 37 content::SpeechRecognitionPreferences* recognition_preferences); | |
| 38 | |
| 39 // SpeechRecognitionEventListener methods. | |
| 40 virtual void OnRecognitionStart(int session_id) OVERRIDE; | |
| 41 virtual void OnAudioStart(int session_id) OVERRIDE; | |
| 42 virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE; | |
| 43 virtual void OnSoundStart(int session_id) OVERRIDE; | |
| 44 virtual void OnSoundEnd(int session_id) OVERRIDE; | |
| 45 virtual void OnAudioEnd(int session_id) OVERRIDE; | |
| 46 virtual void OnRecognitionEnd(int session_id) OVERRIDE; | |
| 47 virtual void OnRecognitionResult( | |
| 48 int session_id, const content::SpeechRecognitionResult& result) OVERRIDE; | |
| 49 virtual void OnRecognitionError( | |
| 50 int session_id, const content::SpeechRecognitionError& error) OVERRIDE; | |
| 51 virtual void OnAudioLevelsChange( | |
| 52 int session_id, float volume, float noise_volume) OVERRIDE; | |
| 53 | |
| 54 // content::BrowserMessageFilter implementation. | |
| 55 virtual bool OnMessageReceived(const IPC::Message& message, | |
| 56 bool* message_was_ok) OVERRIDE; | |
| 57 | |
| 58 // Singleton manager setter useful for tests. | |
| 59 static void set_manager(SpeechRecognitionManagerImpl* manager); | |
| 60 | |
| 61 private: | |
| 62 virtual ~SpeechRecognitionDispatcherHost(); | |
| 63 | |
| 64 void OnStartRequest( | |
| 65 const SpeechRecognitionHostMsg_StartRequest_Params ¶ms); | |
|
hans
2012/05/11 16:56:32
the & should be on the type
Primiano Tucci (use gerrit)
2012/05/14 12:58:22
Oops. Done.
| |
| 66 void OnAbortRequest(int render_view_id, int js_handle_id); | |
| 67 void OnStopCaptureRequest(int render_view_id, int js_handle_id); | |
| 68 | |
| 69 // Returns the speech recognition manager to forward events to, creating one | |
|
hans
2012/05/11 16:56:32
hmm, maybe change the comment to say "requests" ra
Primiano Tucci (use gerrit)
2012/05/14 12:58:22
Right. Furthermore I removed the "creating one if
| |
| 70 // if needed. | |
| 71 SpeechRecognitionManagerImpl* manager(); | |
| 72 | |
| 73 int render_process_id_; | |
| 74 bool may_have_pending_requests_; // Set if we received any speech IPC request | |
|
hans
2012/05/11 16:56:32
nit: period.
Primiano Tucci (use gerrit)
2012/05/14 12:58:22
Done.
| |
| 75 | |
| 76 scoped_refptr<net::URLRequestContextGetter> context_getter_; | |
| 77 scoped_refptr<content::SpeechRecognitionPreferences> recognition_preferences_; | |
| 78 | |
| 79 static SpeechRecognitionManagerImpl* manager_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcherHost); | |
| 82 }; | |
| 83 | |
| 84 } // namespace speech | |
| 85 | |
| 86 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ | |
| OLD | NEW |