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

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

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

Powered by Google App Engine
This is Rietveld 408576698