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

Unified Diff: content/browser/speech/speech_recognizer.cc

Issue 9433006: Remove GetAudioManager and GetMediaStreamManager from ResourceContext. The reason is the content mo… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head Created 8 years, 10 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.cc
===================================================================
--- content/browser/speech/speech_recognizer.cc (revision 123165)
+++ content/browser/speech/speech_recognizer.cc (working copy)
@@ -6,11 +6,13 @@
#include "base/bind.h"
#include "base/time.h"
+#include "content/browser/browser_main_loop.h"
#include "content/public/browser/speech_recognizer_delegate.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/speech_input_result.h"
#include "net/url_request/url_request_context_getter.h"
+using content::BrowserMainLoop;
using content::BrowserThread;
using media::AudioInputController;
using std::string;
@@ -62,7 +64,6 @@
const std::string& language,
const std::string& grammar,
net::URLRequestContextGetter* context_getter,
- AudioManager* audio_manager,
bool filter_profanities,
const std::string& hardware_info,
const std::string& origin_url)
@@ -74,12 +75,12 @@
hardware_info_(hardware_info),
origin_url_(origin_url),
context_getter_(context_getter),
- audio_manager_(audio_manager),
codec_(AudioEncoder::CODEC_FLAC),
encoder_(NULL),
endpointer_(kAudioSampleRate),
num_samples_recorded_(0),
- audio_level_(0.0f) {
+ audio_level_(0.0f),
+ audio_manager_(NULL) {
endpointer_.set_speech_input_complete_silence_length(
base::Time::kMicrosecondsPerSecond / 2);
endpointer_.set_long_speech_input_complete_silence_length(
@@ -114,8 +115,9 @@
AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout,
kAudioSampleRate, kNumBitsPerAudioSample,
samples_per_packet);
- audio_controller_ = AudioInputController::Create(audio_manager_, this,
- params);
+ audio_controller_ = AudioInputController::Create(
+ audio_manager_ ? audio_manager_ : BrowserMainLoop::GetAudioManager(),
tommi (sloooow) - chröme 2012/02/23 07:50:59 when will audio_manager_ not be the same as GetAud
+ this, params);
DCHECK(audio_controller_.get());
VLOG(1) << "SpeechRecognizer starting record.";
num_samples_recorded_ = 0;
@@ -319,4 +321,8 @@
audio_controller_ = NULL; // Releases the ref ptr.
}
+void SpeechRecognizer::SetAudioManagerForTesting(AudioManager* audio_manager) {
+ audio_manager_ = audio_manager;
tommi (sloooow) - chröme 2012/02/23 07:50:59 ah, I see... Instead of adding a 'ForTesting' meth
jam 2012/02/23 08:05:09 I tend to avoid inheritance unless necessary, whic
+}
+
} // namespace speech_input

Powered by Google App Engine
This is Rietveld 408576698