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

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

Issue 11347004: content/browser: Move speech code into content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/common/content_export.h" 9 #include "content/common/content_export.h"
10 #include "content/public/browser/browser_message_filter.h" 10 #include "content/public/browser/browser_message_filter.h"
11 #include "content/public/browser/speech_recognition_event_listener.h" 11 #include "content/public/browser/speech_recognition_event_listener.h"
12 #include "net/url_request/url_request_context_getter.h" 12 #include "net/url_request/url_request_context_getter.h"
13 13
14 struct SpeechRecognitionHostMsg_StartRequest_Params; 14 struct SpeechRecognitionHostMsg_StartRequest_Params;
15 15
16 namespace content { 16 namespace content {
17
17 class SpeechRecognitionManager; 18 class SpeechRecognitionManager;
18 class SpeechRecognitionPreferences; 19 class SpeechRecognitionPreferences;
19 struct SpeechRecognitionResult; 20 struct SpeechRecognitionResult;
20 }
21
22 namespace speech {
23 21
24 // SpeechRecognitionDispatcherHost is a delegate for Speech API messages used by 22 // SpeechRecognitionDispatcherHost is a delegate for Speech API messages used by
25 // RenderMessageFilter. Basically it acts as a proxy, relaying the events coming 23 // RenderMessageFilter. Basically it acts as a proxy, relaying the events coming
26 // from the SpeechRecognitionManager to IPC messages (and vice versa). 24 // from the SpeechRecognitionManager to IPC messages (and vice versa).
27 // It's the complement of SpeechRecognitionDispatcher (owned by RenderView). 25 // It's the complement of SpeechRecognitionDispatcher (owned by RenderView).
28 class CONTENT_EXPORT SpeechRecognitionDispatcherHost 26 class CONTENT_EXPORT SpeechRecognitionDispatcherHost
29 : public content::BrowserMessageFilter, 27 : public BrowserMessageFilter,
30 public content::SpeechRecognitionEventListener { 28 public SpeechRecognitionEventListener {
31 public: 29 public:
32 SpeechRecognitionDispatcherHost( 30 SpeechRecognitionDispatcherHost(
33 int render_process_id, 31 int render_process_id,
34 net::URLRequestContextGetter* context_getter, 32 net::URLRequestContextGetter* context_getter,
35 content::SpeechRecognitionPreferences* recognition_preferences); 33 SpeechRecognitionPreferences* recognition_preferences);
36 34
37 // SpeechRecognitionEventListener methods. 35 // SpeechRecognitionEventListener methods.
38 virtual void OnRecognitionStart(int session_id) OVERRIDE; 36 virtual void OnRecognitionStart(int session_id) OVERRIDE;
39 virtual void OnAudioStart(int session_id) OVERRIDE; 37 virtual void OnAudioStart(int session_id) OVERRIDE;
40 virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE; 38 virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE;
41 virtual void OnSoundStart(int session_id) OVERRIDE; 39 virtual void OnSoundStart(int session_id) OVERRIDE;
42 virtual void OnSoundEnd(int session_id) OVERRIDE; 40 virtual void OnSoundEnd(int session_id) OVERRIDE;
43 virtual void OnAudioEnd(int session_id) OVERRIDE; 41 virtual void OnAudioEnd(int session_id) OVERRIDE;
44 virtual void OnRecognitionEnd(int session_id) OVERRIDE; 42 virtual void OnRecognitionEnd(int session_id) OVERRIDE;
45 virtual void OnRecognitionResult( 43 virtual void OnRecognitionResult(
46 int session_id, const content::SpeechRecognitionResult& result) OVERRIDE; 44 int session_id,
45 const SpeechRecognitionResult& result) OVERRIDE;
47 virtual void OnRecognitionError( 46 virtual void OnRecognitionError(
48 int session_id, const content::SpeechRecognitionError& error) OVERRIDE; 47 int session_id,
49 virtual void OnAudioLevelsChange( 48 const SpeechRecognitionError& error) OVERRIDE;
50 int session_id, float volume, float noise_volume) OVERRIDE; 49 virtual void OnAudioLevelsChange(int session_id,
50 float volume,
51 float noise_volume) OVERRIDE;
51 52
52 // content::BrowserMessageFilter implementation. 53 // BrowserMessageFilter implementation.
53 virtual bool OnMessageReceived(const IPC::Message& message, 54 virtual bool OnMessageReceived(const IPC::Message& message,
54 bool* message_was_ok) OVERRIDE; 55 bool* message_was_ok) OVERRIDE;
55 56
56 // Singleton manager setter useful for tests. 57 // Singleton manager setter useful for tests.
57 static void SetManagerForTests(content::SpeechRecognitionManager* manager); 58 static void SetManagerForTests(SpeechRecognitionManager* manager);
58 59
59 private: 60 private:
60 virtual ~SpeechRecognitionDispatcherHost(); 61 virtual ~SpeechRecognitionDispatcherHost();
61 62
62 void OnStartRequest( 63 void OnStartRequest(
63 const SpeechRecognitionHostMsg_StartRequest_Params& params); 64 const SpeechRecognitionHostMsg_StartRequest_Params& params);
64 void OnAbortRequest(int render_view_id, int request_id); 65 void OnAbortRequest(int render_view_id, int request_id);
65 void OnStopCaptureRequest(int render_view_id, int request_id); 66 void OnStopCaptureRequest(int render_view_id, int request_id);
66 67
67 // Returns the speech recognition manager to forward requests to. 68 // Returns the speech recognition manager to forward requests to.
68 content::SpeechRecognitionManager* manager(); 69 SpeechRecognitionManager* manager();
69 70
70 int render_process_id_; 71 int render_process_id_;
71 scoped_refptr<net::URLRequestContextGetter> context_getter_; 72 scoped_refptr<net::URLRequestContextGetter> context_getter_;
72 scoped_refptr<content::SpeechRecognitionPreferences> recognition_preferences_; 73 scoped_refptr<SpeechRecognitionPreferences> recognition_preferences_;
73 74
74 static content::SpeechRecognitionManager* manager_for_tests_; 75 static SpeechRecognitionManager* manager_for_tests_;
75 76
76 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcherHost); 77 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcherHost);
77 }; 78 };
78 79
79 } // namespace speech 80 } // namespace content
80 81
81 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ 82 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698