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

Unified Diff: content/browser/speech/speech_recognizer_impl_android.h

Issue 15907012: Implement SpeechRecognizerImplAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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/browser/speech/speech_recognizer_impl_android.h
diff --git a/content/browser/speech/speech_recognizer_impl_android.h b/content/browser/speech/speech_recognizer_impl_android.h
new file mode 100644
index 0000000000000000000000000000000000000000..971d782c1e5ba2478023bf66d61b7c2c636c47a9
--- /dev/null
+++ b/content/browser/speech/speech_recognizer_impl_android.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2013 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_RECOGNIZER_IMPL_ANDROID_H_
+#define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Nit: Is this newline needed here? I can't find any
janx 2013/06/05 13:51:00 I think new lines are needed when include order ma
+#include "content/browser/speech/speech_recognizer.h"
+#include "content/public/browser/speech_recognition_session_config.h"
+#include "content/public/common/speech_recognition_error.h"
+#include "content/public/common/speech_recognition_result.h"
+
+namespace content {
+
+class SpeechRecognitionEventListener;
+
+class CONTENT_EXPORT SpeechRecognizerImplAndroid : public SpeechRecognizer {
+ public:
+ static void Init(JNIEnv* env);
+
+ virtual ~SpeechRecognizerImplAndroid();
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Since SpeechRecognizer (the base class) is refcoun
janx 2013/06/05 13:51:00 I'll make it private, thanks for spotting this!
+
+ SpeechRecognizerImplAndroid(SpeechRecognitionEventListener* listener,
+ const SpeechRecognitionSessionConfig& config,
+ int session_id);
+
+ void StartRecognition();
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Shouldn't this be virtual void StartRecognition()
janx 2013/06/05 13:51:00 Indeed, that's a leftover from before SpeechRecogn
+ void AbortRecognition();
+ void StopAudioCapture();
+ bool IsActive() const;
+ bool IsCapturingAudio() const;
+
+ void StartRecognitionJNI(bool continuous, bool partial_results);
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Shouldn't these three methods be private? Also, ca
janx 2013/06/05 13:51:00 Will do.
+ void CancelRecognitionJNI();
+ void StopRecognitionJNI();
+
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Add a comment: // Called from Java via JNI.
janx 2013/06/05 13:51:00 Done.
+ void OnAudioStartJNI(JNIEnv* env, jobject obj);
+ void OnSoundStartJNI(JNIEnv* env, jobject obj);
+ void OnSoundEndJNI(JNIEnv* env, jobject obj);
+ void OnRecognitionResultsJNI(JNIEnv* env, jobject obj, jobjectArray strings,
+ jfloatArray floats, jboolean partial);
+ void OnRecognitionErrorJNI(JNIEnv* env, jobject obj, jint error);
+ void OnAudioLevelsChangeJNI(JNIEnv* env, jobject obj, jfloat rms);
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Looks like here you need an OnRecognitionEndJNI ev
janx 2013/06/05 13:51:00 I'll implement an OnRecognitionEndJNI(e,o) method
+
+ void OnAudioStart();
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Similar to previous comments: I guess these 6 meth
janx 2013/06/05 13:51:00 Moving to private.
+ void OnSoundStart();
+ void OnSoundEnd();
+ void OnRecognitionResults(std::vector<string16> options,
+ std::vector<float> scores, bool partial);
+ void OnRecognitionError(SpeechRecognitionError error);
+ void OnAudioLevelsChange(float rms);
+
+ private:
+ base::android::ScopedJavaGlobalRef<jobject> j_recognition_;
+
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 Nit: remove blank line.
+ SpeechRecognitionSessionConfig config_;
Primiano Tucci (use gerrit) 2013/06/03 16:24:11 See my previous comment: since it seems you're usi
janx 2013/06/05 13:51:00 Great suggestion, I'll use SpeechRecognitionManage
+
+ DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImplAndroid);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_ANDROID_H_

Powered by Google App Engine
This is Rietveld 408576698