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

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

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 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
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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 std::string api_key = google_apis::GetAPIKey(); 204 std::string api_key = google_apis::GetAPIKey();
205 parts.push_back("key=" + net::EscapeQueryParamValue(api_key, true)); 205 parts.push_back("key=" + net::EscapeQueryParamValue(api_key, true));
206 206
207 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&')); 207 GURL url(std::string(kDefaultSpeechRecognitionUrl) + JoinString(parts, '&'));
208 208
209 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec, 209 encoder_.reset(AudioEncoder::Create(kDefaultAudioCodec,
210 config_.audio_sample_rate, 210 config_.audio_sample_rate,
211 config_.audio_num_bits_per_sample)); 211 config_.audio_num_bits_per_sample));
212 DCHECK(encoder_.get()); 212 DCHECK(encoder_.get());
213 url_fetcher_.reset(net::URLFetcher::Create(url_fetcher_id_for_tests, 213 url_fetcher_ = net::URLFetcher::Create(url_fetcher_id_for_tests, url,
214 url, 214 net::URLFetcher::POST, this);
215 net::URLFetcher::POST,
216 this));
217 url_fetcher_->SetChunkedUpload(encoder_->mime_type()); 215 url_fetcher_->SetChunkedUpload(encoder_->mime_type());
218 url_fetcher_->SetRequestContext(url_context_.get()); 216 url_fetcher_->SetRequestContext(url_context_.get());
219 url_fetcher_->SetReferrer(config_.origin_url); 217 url_fetcher_->SetReferrer(config_.origin_url);
220 218
221 // The speech recognition API does not require user identification as part 219 // The speech recognition API does not require user identification as part
222 // of requests, so we don't send cookies or auth data for these requests to 220 // of requests, so we don't send cookies or auth data for these requests to
223 // prevent any accidental connection between users who are logged into the 221 // prevent any accidental connection between users who are logged into the
224 // domain for other services (e.g. bookmark sync) with the speech requests. 222 // domain for other services (e.g. bookmark sync) with the speech requests.
225 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | 223 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES |
226 net::LOAD_DO_NOT_SEND_COOKIES | 224 net::LOAD_DO_NOT_SEND_COOKIES |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 286
289 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { 287 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const {
290 return url_fetcher_ != NULL; 288 return url_fetcher_ != NULL;
291 } 289 }
292 290
293 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { 291 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const {
294 return kAudioPacketIntervalMs; 292 return kAudioPacketIntervalMs;
295 } 293 }
296 294
297 } // namespace content 295 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/geolocation/network_location_request.cc ('k') | content/browser/speech/google_streaming_remote_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698