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

Unified 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: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/speech/speech_recognition_dispatcher_host.h
diff --git a/content/browser/speech/speech_recognition_dispatcher_host.h b/content/browser/speech/speech_recognition_dispatcher_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..62684357882426181ef0e1764686d7829b093a1f
--- /dev/null
+++ b/content/browser/speech/speech_recognition_dispatcher_host.h
@@ -0,0 +1,86 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_
+#define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_
+#pragma once
+
+#include "base/memory/scoped_ptr.h"
+#include "content/common/content_export.h"
+#include "content/public/browser/browser_message_filter.h"
+#include "content/public/browser/speech_recognition_event_listener.h"
+#include "net/url_request/url_request_context_getter.h"
+
+struct SpeechRecognitionHostMsg_StartRequest_Params;
+
+namespace content {
+class SpeechRecognitionPreferences;
+struct SpeechRecognitionResult;
+}
+
+namespace speech {
+
+class SpeechRecognitionManagerImpl;
+
+// SpeechRecognitionDispatcherHost is a delegate for Speech API messages used by
+// RenderMessageFilter. Basically it acts as a proxy, relaying the events coming
+// from the SpeechRecognitionManager to IPC messages (and vice versa).
+// It's the complement of SpeechRecognitionDispatcher (owned by RenderView).
+class CONTENT_EXPORT SpeechRecognitionDispatcherHost
+ : public content::BrowserMessageFilter,
+ public content::SpeechRecognitionEventListener {
+ public:
+ SpeechRecognitionDispatcherHost(
+ int render_process_id,
+ net::URLRequestContextGetter* context_getter,
+ content::SpeechRecognitionPreferences* recognition_preferences);
+
+ // SpeechRecognitionEventListener methods.
+ virtual void OnRecognitionStart(int session_id) OVERRIDE;
+ virtual void OnAudioStart(int session_id) OVERRIDE;
+ virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE;
+ virtual void OnSoundStart(int session_id) OVERRIDE;
+ virtual void OnSoundEnd(int session_id) OVERRIDE;
+ virtual void OnAudioEnd(int session_id) OVERRIDE;
+ virtual void OnRecognitionEnd(int session_id) OVERRIDE;
+ virtual void OnRecognitionResult(
+ int session_id, const content::SpeechRecognitionResult& result) OVERRIDE;
+ virtual void OnRecognitionError(
+ int session_id, const content::SpeechRecognitionError& error) OVERRIDE;
+ virtual void OnAudioLevelsChange(
+ int session_id, float volume, float noise_volume) OVERRIDE;
+
+ // content::BrowserMessageFilter implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) OVERRIDE;
+
+ // Singleton manager setter useful for tests.
+ static void set_manager(SpeechRecognitionManagerImpl* manager);
+
+ private:
+ virtual ~SpeechRecognitionDispatcherHost();
+
+ void OnStartRequest(
+ const SpeechRecognitionHostMsg_StartRequest_Params &params);
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.
+ void OnAbortRequest(int render_view_id, int js_handle_id);
+ void OnStopCaptureRequest(int render_view_id, int js_handle_id);
+
+ // 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
+ // if needed.
+ SpeechRecognitionManagerImpl* manager();
+
+ int render_process_id_;
+ 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.
+
+ scoped_refptr<net::URLRequestContextGetter> context_getter_;
+ scoped_refptr<content::SpeechRecognitionPreferences> recognition_preferences_;
+
+ static SpeechRecognitionManagerImpl* manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcherHost);
+};
+
+} // namespace speech
+
+#endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698