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

Side by Side Diff: content/browser/speech/google_one_shot_remote_engine.cc

Issue 10412050: Change most content::URLFetcher references to net::URLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChromeOS, address comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/speech/google_one_shot_remote_engine.h" 5 #include "content/browser/speech/google_one_shot_remote_engine.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "content/browser/speech/audio_buffer.h" 13 #include "content/browser/speech/audio_buffer.h"
14 #include "content/common/net/url_fetcher_impl.h"
15 #include "content/public/common/speech_recognition_error.h" 14 #include "content/public/common/speech_recognition_error.h"
16 #include "content/public/common/speech_recognition_result.h" 15 #include "content/public/common/speech_recognition_result.h"
16 #include "content/public/common/url_fetcher.h"
17 #include "net/base/escape.h" 17 #include "net/base/escape.h"
18 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
19 #include "net/url_request/url_request_context.h" 19 #include "net/url_request/url_request_context.h"
20 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
21 #include "net/url_request/url_request_status.h" 21 #include "net/url_request/url_request_status.h"
22 22
23 using content::SpeechRecognitionError; 23 using content::SpeechRecognitionError;
24 using content::SpeechRecognitionHypothesis; 24 using content::SpeechRecognitionHypothesis;
25 using content::SpeechRecognitionResult; 25 using content::SpeechRecognitionResult;
26 26
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 true)); 200 true));
201 parts.push_back("maxresults=" + base::IntToString(kMaxResults)); 201 parts.push_back("maxresults=" + base::IntToString(kMaxResults));
202 parts.push_back(config_.filter_profanities ? "pfilter=2" : "pfilter=0"); 202 parts.push_back(config_.filter_profanities ? "pfilter=2" : "pfilter=0");
203 203
204 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); 204 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&'));
205 205
206 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec, 206 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec,
207 config_.audio_sample_rate, 207 config_.audio_sample_rate,
208 config_.audio_num_bits_per_sample)); 208 config_.audio_num_bits_per_sample));
209 DCHECK(encoder_.get()); 209 DCHECK(encoder_.get());
210 url_fetcher_.reset(URLFetcherImpl::Create(url_fetcher_id_for_tests, 210 url_fetcher_.reset(content::URLFetcher::Create(url_fetcher_id_for_tests,
211 url, 211 url,
212 URLFetcherImpl::POST, 212 net::URLFetcher::POST,
213 this)); 213 this));
214 url_fetcher_->SetChunkedUpload(encoder_->mime_type()); 214 url_fetcher_->SetChunkedUpload(encoder_->mime_type());
215 url_fetcher_->SetRequestContext(url_context_); 215 url_fetcher_->SetRequestContext(url_context_);
216 url_fetcher_->SetReferrer(config_.origin_url); 216 url_fetcher_->SetReferrer(config_.origin_url);
217 217
218 // The speech recognition API does not require user identification as part 218 // The speech recognition API does not require user identification as part
219 // of requests, so we don't send cookies or auth data for these requests to 219 // of requests, so we don't send cookies or auth data for these requests to
220 // prevent any accidental connection between users who are logged into the 220 // prevent any accidental connection between users who are logged into the
221 // domain for other services (e.g. bookmark sync) with the speech requests. 221 // domain for other services (e.g. bookmark sync) with the speech requests.
222 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | 222 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES |
223 net::LOAD_DO_NOT_SEND_COOKIES | 223 net::LOAD_DO_NOT_SEND_COOKIES |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { 286 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const {
287 return url_fetcher_ != NULL; 287 return url_fetcher_ != NULL;
288 } 288 }
289 289
290 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { 290 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const {
291 return kAudioPacketIntervalMs; 291 return kAudioPacketIntervalMs;
292 } 292 }
293 293
294 } // namespace speech 294 } // namespace speech
OLDNEW
« no previous file with comments | « content/browser/speech/google_one_shot_remote_engine.h ('k') | content/common/net/url_fetcher_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698