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

Unified Diff: content/renderer/speech_recognition_dispatcher.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: Test fixed + Satish nits. 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/speech_recognition_dispatcher.h
diff --git a/content/renderer/speech_recognition_dispatcher.h b/content/renderer/speech_recognition_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..04182a9faae7becc6d972247ff5c4f541a15992a
--- /dev/null
+++ b/content/renderer/speech_recognition_dispatcher.h
@@ -0,0 +1,75 @@
+// 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_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_
+#define CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_
+#pragma once
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "content/public/renderer/render_view_observer.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognitionHandle.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognizer.h"
+
+class RenderViewImpl;
+
+namespace content {
+struct SpeechRecognitionError;
+struct SpeechRecognitionResult;
+}
+
+namespace WebKit {
+class WebSpeechRecognitionParams;
+class WebSpeechRecognizerClient;
jam 2012/05/23 15:41:24 these forward declarations are already in WebSPeec
Primiano Tucci (use gerrit) 2012/05/23 17:11:56 Done.
+}
+
+// SpeechRecognitionDispatcher is a delegate for methods used by WebKit for
+// scripted JS speech APIs. It's the complement of
+// SpeechRecognitionDispatcherHost (owned by RenderViewHost).
+class SpeechRecognitionDispatcher : public content::RenderViewObserver,
+ public WebKit::WebSpeechRecognizer {
+ public:
+ SpeechRecognitionDispatcher(RenderViewImpl* render_view);
jam 2012/05/23 15:41:24 nit: explicit
Primiano Tucci (use gerrit) 2012/05/23 17:11:56 Done.
+ virtual ~SpeechRecognitionDispatcher();
+
+ private:
+ // RenderView::Observer implementation.
jam 2012/05/23 15:41:24 nit: RenderViewObserver
Primiano Tucci (use gerrit) 2012/05/23 17:11:56 Done.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ // WebKit::WebSpeechRecognizer implementation.
+ virtual void start(const WebKit::WebSpeechRecognitionHandle&,
+ const WebKit::WebSpeechRecognitionParams&,
+ WebKit::WebSpeechRecognizerClient*) OVERRIDE;
+ virtual void stop(const WebKit::WebSpeechRecognitionHandle&,
+ WebKit::WebSpeechRecognizerClient*) OVERRIDE;
+ virtual void abort(const WebKit::WebSpeechRecognitionHandle&,
+ WebKit::WebSpeechRecognizerClient*) OVERRIDE;
+
+ void OnRecognitionStarted(int request_id);
+ void OnAudioStarted(int request_id);
+ void OnSoundStarted(int request_id);
+ void OnSoundEnded(int request_id);
+ void OnAudioEnded(int request_id);
+ void OnErrorOccurred(int request_id,
+ const content::SpeechRecognitionError& error);
+ void OnRecognitionEnded(int request_id);
+ void OnResultRetrieved(int request_id,
+ const content::SpeechRecognitionResult& result);
+
+ int GetIDForHandle(const WebKit::WebSpeechRecognitionHandle& handle);
+ const WebKit::WebSpeechRecognitionHandle& GetHandleFromID(int handle_id);
+
+ // The WebKit client class that we use to send events back to the JS world.
+ WebKit::WebSpeechRecognizerClient* recognizer_client_;
+
+ typedef std::map<int, WebKit::WebSpeechRecognitionHandle> HandleMap;
+ HandleMap handle_map_;
+ int next_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher);
+};
+
+#endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698