summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 02:16:05 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 02:16:05 +0000
commit3942a25369d4e15de6c47b0c1df59827eec49a5e (patch)
tree29d05dee360e3b216dfefd9fafc8e399ebaabb45 /content
parente2d731d8b2ea857eebfdac5733da54f66a43b3a3 (diff)
downloadchromium_src-3942a25369d4e15de6c47b0c1df59827eec49a5e.zip
chromium_src-3942a25369d4e15de6c47b0c1df59827eec49a5e.tar.gz
chromium_src-3942a25369d4e15de6c47b0c1df59827eec49a5e.tar.bz2
Revert 121810 - Move SpeechRecognizer delegate into its own header file and put it in the content namespace.
This avoids having a nested class as it leads to too many includes in headers. BUG=98716 R=jam@chromium.org Review URL: https://chromiumcodereview.appspot.com/9390007 TBR=tfarina@chromium.org Review URL: https://chromiumcodereview.appspot.com/9387023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/speech/speech_input_browsertest.cc1
-rw-r--r--content/browser/speech/speech_input_manager.cc1
-rw-r--r--content/browser/speech/speech_input_manager.h15
-rw-r--r--content/browser/speech/speech_recognizer.cc5
-rw-r--r--content/browser/speech/speech_recognizer.h69
-rw-r--r--content/browser/speech/speech_recognizer_unittest.cc7
-rw-r--r--content/content_browser.gypi1
-rw-r--r--content/public/browser/speech_recognizer_delegate.h65
8 files changed, 68 insertions, 96 deletions
diff --git a/content/browser/speech/speech_input_browsertest.cc b/content/browser/speech/speech_input_browsertest.cc
index b7f24a0..83e5c01 100644
--- a/content/browser/speech/speech_input_browsertest.cc
+++ b/content/browser/speech/speech_input_browsertest.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/string_number_conversions.h"
-#include "base/synchronization/waitable_event.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
diff --git a/content/browser/speech/speech_input_manager.cc b/content/browser/speech/speech_input_manager.cc
index 4e6f879..f6d97bb 100644
--- a/content/browser/speech/speech_input_manager.cc
+++ b/content/browser/speech/speech_input_manager.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/browser/speech/speech_recognizer.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/browser/resource_context.h"
diff --git a/content/browser/speech/speech_input_manager.h b/content/browser/speech/speech_input_manager.h
index 5944e3d..33ec9a5 100644
--- a/content/browser/speech/speech_input_manager.h
+++ b/content/browser/speech/speech_input_manager.h
@@ -9,32 +9,23 @@
#include <string>
#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
+#include "content/browser/speech/speech_recognizer.h"
#include "content/common/content_export.h"
-#include "content/public/browser/speech_recognizer_delegate.h"
#include "ui/gfx/rect.h"
-class AudioManager;
-
namespace content {
class ResourceContext;
class SpeechInputPreferences;
struct SpeechInputResult;
}
-namespace net {
-class URLRequestContextGetter;
-}
-
namespace speech_input {
-class SpeechRecognizer;
// This is the gatekeeper for speech recognition in the browser process. It
// handles requests received from various render views and makes sure only one
// of them can use speech recognition at a time. It also sends recognition
// results and status events to the render views when required.
-class CONTENT_EXPORT SpeechInputManager
- : public content::SpeechRecognizerDelegate {
+class CONTENT_EXPORT SpeechInputManager : public SpeechRecognizerDelegate {
public:
// Implemented by the dispatcher host to relay events to the render views.
class Delegate {
@@ -93,7 +84,7 @@ class CONTENT_EXPORT SpeechInputManager
virtual void CancelAllRequestsWithDelegate(Delegate* delegate);
virtual void StopRecording(int caller_id);
- // Overridden from content::SpeechRecognizerDelegate:
+ // SpeechRecognizerDelegate methods.
virtual void DidStartReceivingAudio(int caller_id) OVERRIDE;
virtual void SetRecognitionResult(
int caller_id,
diff --git a/content/browser/speech/speech_recognizer.cc b/content/browser/speech/speech_recognizer.cc
index 4ea4186..92cc02d 100644
--- a/content/browser/speech/speech_recognizer.cc
+++ b/content/browser/speech/speech_recognizer.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/time.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/speech_recognizer_delegate.h"
#include "content/public/common/speech_input_result.h"
#include "net/url_request/url_request_context_getter.h"
@@ -57,7 +56,7 @@ const int SpeechRecognizer::kNumBitsPerAudioSample = 16;
const int SpeechRecognizer::kNoSpeechTimeoutSec = 8;
const int SpeechRecognizer::kEndpointerEstimationTimeMs = 300;
-SpeechRecognizer::SpeechRecognizer(content::SpeechRecognizerDelegate* delegate,
+SpeechRecognizer::SpeechRecognizer(Delegate* delegate,
int caller_id,
const std::string& language,
const std::string& grammar,
diff --git a/content/browser/speech/speech_recognizer.h b/content/browser/speech/speech_recognizer.h
index 9618f51..30145f4 100644
--- a/content/browser/speech/speech_recognizer.h
+++ b/content/browser/speech/speech_recognizer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -18,10 +18,6 @@
#include "content/public/common/speech_input_result.h"
#include "media/audio/audio_input_controller.h"
-namespace content {
-class SpeechRecognizerDelegate;
-}
-
namespace net {
class URLRequestContextGetter;
}
@@ -35,7 +31,57 @@ class CONTENT_EXPORT SpeechRecognizer
public media::AudioInputController::EventHandler,
public SpeechRecognitionRequestDelegate {
public:
- SpeechRecognizer(content::SpeechRecognizerDelegate* delegate,
+ // Implemented by the caller to receive recognition events.
+ class CONTENT_EXPORT Delegate {
+ public:
+ virtual void SetRecognitionResult(
+ int caller_id,
+ const content::SpeechInputResult& result) = 0;
+
+ // Invoked when the first audio packet was received from the audio capture
+ // device.
+ virtual void DidStartReceivingAudio(int caller_id) = 0;
+
+ // Invoked when audio recording stops, either due to the end pointer
+ // detecting silence in user input or if |StopRecording| was called. The
+ // delegate has to wait until |DidCompleteRecognition| is invoked before
+ // destroying the |SpeechRecognizer| object.
+ virtual void DidCompleteRecording(int caller_id) = 0;
+
+ // This is guaranteed to be the last method invoked in the recognition
+ // sequence and the |SpeechRecognizer| object can be freed up if necessary.
+ virtual void DidCompleteRecognition(int caller_id) = 0;
+
+ // Informs that the end pointer has started detecting speech.
+ virtual void DidStartReceivingSpeech(int caller_id) = 0;
+
+ // Informs that the end pointer has stopped detecting speech.
+ virtual void DidStopReceivingSpeech(int caller_id) = 0;
+
+ // Invoked if there was an error while recording or recognizing audio. The
+ // session has already been cancelled when this call is made and the DidXxxx
+ // callbacks will not be issued. It is safe to destroy/release the
+ // |SpeechRecognizer| object while processing this call.
+ virtual void OnRecognizerError(int caller_id,
+ content::SpeechInputError error) = 0;
+
+ // At the start of recognition, a short amount of audio is recorded to
+ // estimate the environment/background noise and this callback is issued
+ // after that is complete. Typically the delegate brings up any speech
+ // recognition UI once this callback is received.
+ virtual void DidCompleteEnvironmentEstimation(int caller_id) = 0;
+
+ // Informs of a change in the captured audio level, useful if displaying
+ // a microphone volume indicator while recording.
+ // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range.
+ virtual void SetInputVolume(int caller_id, float volume,
+ float noise_volume) = 0;
+
+ protected:
+ virtual ~Delegate() {}
+ };
+
+ SpeechRecognizer(Delegate* delegate,
int caller_id,
const std::string& language,
const std::string& grammar,
@@ -50,8 +96,7 @@ class CONTENT_EXPORT SpeechRecognizer
// Starts audio recording and does recognition after recording ends. The same
// SpeechRecognizer instance can be used multiple times for speech recognition
// though each recognition request can be made only after the previous one
- // completes (i.e. after receiving
- // SpeechRecognizerDelegate::DidCompleteRecognition).
+ // completes (i.e. after receiving Delegate::DidCompleteRecognition).
bool StartRecording();
// Stops recording audio and starts recognition.
@@ -95,7 +140,7 @@ class CONTENT_EXPORT SpeechRecognizer
// Helper method which closes the audio controller and blocks until done.
void CloseAudioControllerSynchronously();
- content::SpeechRecognizerDelegate* delegate_;
+ Delegate* delegate_;
int caller_id_;
std::string language_;
std::string grammar_;
@@ -116,6 +161,12 @@ class CONTENT_EXPORT SpeechRecognizer
DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer);
};
+// This typedef is to workaround the issue with certain versions of
+// Visual Studio where it gets confused between multiple Delegate
+// classes and gives a C2500 error. (I saw this error on the try bots -
+// the workaround was not needed for my machine).
+typedef SpeechRecognizer::Delegate SpeechRecognizerDelegate;
+
} // namespace speech_input
#endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_
diff --git a/content/browser/speech/speech_recognizer_unittest.cc b/content/browser/speech/speech_recognizer_unittest.cc
index cb4ff3b..6dcaec6 100644
--- a/content/browser/speech/speech_recognizer_unittest.cc
+++ b/content/browser/speech/speech_recognizer_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,7 +6,6 @@
#include "content/browser/browser_thread_impl.h"
#include "content/browser/speech/speech_recognizer.h"
-#include "content/public/browser/speech_recognizer_delegate.h"
#include "content/test/test_url_fetcher_factory.h"
#include "media/audio/audio_manager.h"
#include "media/audio/test_audio_input_controller_factory.h"
@@ -22,7 +21,7 @@ using media::TestAudioInputControllerFactory;
namespace speech_input {
-class SpeechRecognizerTest : public content::SpeechRecognizerDelegate,
+class SpeechRecognizerTest : public SpeechRecognizerDelegate,
public testing::Test {
public:
SpeechRecognizerTest()
@@ -45,7 +44,7 @@ class SpeechRecognizerTest : public content::SpeechRecognizerDelegate,
audio_packet_.resize(audio_packet_length_bytes);
}
- // Overridden from content::SpeechRecognizerDelegate:
+ // SpeechRecognizer::Delegate methods.
virtual void SetRecognitionResult(
int caller_id,
const content::SpeechInputResult& result) OVERRIDE {
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 8a30313..694c666 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -104,7 +104,6 @@
'public/browser/sensors_provider.h',
'public/browser/site_instance.h',
'public/browser/speech_input_preferences.h',
- 'public/browser/speech_recognizer_delegate.h',
'public/browser/user_metrics.h',
'public/browser/utility_process_host.h',
'public/browser/web_contents.h',
diff --git a/content/public/browser/speech_recognizer_delegate.h b/content/public/browser/speech_recognizer_delegate.h
deleted file mode 100644
index daf482a..0000000
--- a/content/public/browser/speech_recognizer_delegate.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// 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_PUBLIC_BROWSER_SPEECH_RECOGNIZER_DELEGATE_H_
-#define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_DELEGATE_H_
-#pragma once
-
-#include "content/public/common/speech_input_result.h"
-
-namespace content {
-
-// An interface to be implemented by consumers interested in receiving
-// recognition events.
-class SpeechRecognizerDelegate {
- public:
- virtual void SetRecognitionResult(int caller_id,
- const SpeechInputResult& result) = 0;
-
- // Invoked when the first audio packet was received from the audio capture
- // device.
- virtual void DidStartReceivingAudio(int caller_id) = 0;
-
- // Invoked when audio recording stops, either due to the end pointer
- // detecting silence in user input or if |StopRecording| was called. The
- // delegate has to wait until |DidCompleteRecognition| is invoked before
- // destroying the |SpeechRecognizer| object.
- virtual void DidCompleteRecording(int caller_id) = 0;
-
- // This is guaranteed to be the last method invoked in the recognition
- // sequence and the |SpeechRecognizer| object can be freed up if necessary.
- virtual void DidCompleteRecognition(int caller_id) = 0;
-
- // Informs that the end pointer has started detecting speech.
- virtual void DidStartReceivingSpeech(int caller_id) = 0;
-
- // Informs that the end pointer has stopped detecting speech.
- virtual void DidStopReceivingSpeech(int caller_id) = 0;
-
- // Invoked if there was an error while recording or recognizing audio. The
- // session has already been cancelled when this call is made and the DidXxxx
- // callbacks will not be issued. It is safe to destroy/release the
- // |SpeechRecognizer| object while processing this call.
- virtual void OnRecognizerError(int caller_id, SpeechInputError error) = 0;
-
- // At the start of recognition, a short amount of audio is recorded to
- // estimate the environment/background noise and this callback is issued
- // after that is complete. Typically the delegate brings up any speech
- // recognition UI once this callback is received.
- virtual void DidCompleteEnvironmentEstimation(int caller_id) = 0;
-
- // Informs of a change in the captured audio level, useful if displaying
- // a microphone volume indicator while recording.
- // The value of |volume| and |noise_volume| is in the [0.0, 1.0] range.
- virtual void SetInputVolume(int caller_id,
- float volume,
- float noise_volume) = 0;
-
- protected:
- virtual ~SpeechRecognizerDelegate() {}
-};
-
-} // namespace content
-
-#endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_DELEGATE_H_