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

Side by Side Diff: chrome/browser/speech/speech_recognizer.cc

Issue 6308009: If user had consented for metrics reporting, send speech input request origin to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/speech/speech_recognizer.h" 5 #include "chrome/browser/speech/speech_recognizer.h"
6 6
7 #include "base/ref_counted.h" 7 #include "base/ref_counted.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/browser_thread.h" 10 #include "chrome/browser/browser_thread.h"
(...skipping 21 matching lines...) Expand all
32 const int SpeechRecognizer::kAudioPacketIntervalMs = 100; 32 const int SpeechRecognizer::kAudioPacketIntervalMs = 100;
33 const int SpeechRecognizer::kNumAudioChannels = 1; 33 const int SpeechRecognizer::kNumAudioChannels = 1;
34 const int SpeechRecognizer::kNumBitsPerAudioSample = 16; 34 const int SpeechRecognizer::kNumBitsPerAudioSample = 16;
35 const int SpeechRecognizer::kNoSpeechTimeoutSec = 8; 35 const int SpeechRecognizer::kNoSpeechTimeoutSec = 8;
36 const int SpeechRecognizer::kEndpointerEstimationTimeMs = 300; 36 const int SpeechRecognizer::kEndpointerEstimationTimeMs = 300;
37 37
38 SpeechRecognizer::SpeechRecognizer(Delegate* delegate, 38 SpeechRecognizer::SpeechRecognizer(Delegate* delegate,
39 int caller_id, 39 int caller_id,
40 const std::string& language, 40 const std::string& language,
41 const std::string& grammar, 41 const std::string& grammar,
42 const std::string& hardware_info) 42 const std::string& hardware_info,
43 const std::string& origin_url)
43 : delegate_(delegate), 44 : delegate_(delegate),
44 caller_id_(caller_id), 45 caller_id_(caller_id),
45 language_(language), 46 language_(language),
46 grammar_(grammar), 47 grammar_(grammar),
47 hardware_info_(hardware_info), 48 hardware_info_(hardware_info),
49 origin_url_(origin_url),
48 codec_(AudioEncoder::CODEC_SPEEX), 50 codec_(AudioEncoder::CODEC_SPEEX),
49 encoder_(NULL), 51 encoder_(NULL),
50 endpointer_(kAudioSampleRate), 52 endpointer_(kAudioSampleRate),
51 num_samples_recorded_(0), 53 num_samples_recorded_(0),
52 audio_level_(0.0f) { 54 audio_level_(0.0f) {
53 endpointer_.set_speech_input_complete_silence_length( 55 endpointer_.set_speech_input_complete_silence_length(
54 base::Time::kMicrosecondsPerSecond / 2); 56 base::Time::kMicrosecondsPerSecond / 2);
55 endpointer_.set_long_speech_input_complete_silence_length( 57 endpointer_.set_long_speech_input_complete_silence_length(
56 base::Time::kMicrosecondsPerSecond); 58 base::Time::kMicrosecondsPerSecond);
57 endpointer_.set_long_speech_length(3 * base::Time::kMicrosecondsPerSecond); 59 endpointer_.set_long_speech_length(3 * base::Time::kMicrosecondsPerSecond);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // And If we haven't got any audio yet end the recognition sequence here. 131 // And If we haven't got any audio yet end the recognition sequence here.
130 string data; 132 string data;
131 if (!encoder_->GetEncodedData(&data)) { 133 if (!encoder_->GetEncodedData(&data)) {
132 // Guard against the delegate freeing us until we finish our job. 134 // Guard against the delegate freeing us until we finish our job.
133 scoped_refptr<SpeechRecognizer> me(this); 135 scoped_refptr<SpeechRecognizer> me(this);
134 delegate_->DidCompleteRecognition(caller_id_); 136 delegate_->DidCompleteRecognition(caller_id_);
135 } else { 137 } else {
136 DCHECK(!request_.get()); 138 DCHECK(!request_.get());
137 request_.reset(new SpeechRecognitionRequest( 139 request_.reset(new SpeechRecognitionRequest(
138 Profile::GetDefaultRequestContext(), this)); 140 Profile::GetDefaultRequestContext(), this));
139 request_->Send(language_, grammar_, hardware_info_, encoder_->mime_type(), 141 request_->Send(language_, grammar_, hardware_info_, origin_url_,
140 data); 142 encoder_->mime_type(), data);
141 } 143 }
142 encoder_.reset(); 144 encoder_.reset();
143 } 145 }
144 146
145 void SpeechRecognizer::ReleaseAudioBuffers() { 147 void SpeechRecognizer::ReleaseAudioBuffers() {
146 } 148 }
147 149
148 // Invoked in the audio thread. 150 // Invoked in the audio thread.
149 void SpeechRecognizer::OnError(AudioInputController* controller, 151 void SpeechRecognizer::OnError(AudioInputController* controller,
150 int error_code) { 152 int error_code) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 252
251 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) { 253 void SpeechRecognizer::InformErrorAndCancelRecognition(ErrorCode error) {
252 CancelRecognition(); 254 CancelRecognition();
253 255
254 // Guard against the delegate freeing us until we finish our job. 256 // Guard against the delegate freeing us until we finish our job.
255 scoped_refptr<SpeechRecognizer> me(this); 257 scoped_refptr<SpeechRecognizer> me(this);
256 delegate_->OnRecognizerError(caller_id_, error); 258 delegate_->OnRecognizerError(caller_id_, error);
257 } 259 }
258 260
259 } // namespace speech_input 261 } // namespace speech_input
OLDNEW
« no previous file with comments | « chrome/browser/speech/speech_recognizer.h ('k') | chrome/browser/speech/speech_recognizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698