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

Side by Side Diff: components/suggestions/suggestions_service.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/suggestions/suggestions_service.h" 5 #include "components/suggestions/suggestions_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 suggestion->set_expiry_ts(default_timestamp_usec); 212 suggestion->set_expiry_ts(default_timestamp_usec);
213 } 213 }
214 } 214 }
215 } 215 }
216 216
217 void SuggestionsService::IssueRequestIfNoneOngoing(const GURL& url) { 217 void SuggestionsService::IssueRequestIfNoneOngoing(const GURL& url) {
218 // If there is an ongoing request, let it complete. 218 // If there is an ongoing request, let it complete.
219 if (pending_request_.get()) { 219 if (pending_request_.get()) {
220 return; 220 return;
221 } 221 }
222 pending_request_.reset(CreateSuggestionsRequest(url)); 222 pending_request_ = CreateSuggestionsRequest(url);
223 pending_request_->Start(); 223 pending_request_->Start();
224 last_request_started_time_ = TimeTicks::Now(); 224 last_request_started_time_ = TimeTicks::Now();
225 } 225 }
226 226
227 net::URLFetcher* SuggestionsService::CreateSuggestionsRequest(const GURL& url) { 227 scoped_ptr<net::URLFetcher> SuggestionsService::CreateSuggestionsRequest(
228 net::URLFetcher* request = 228 const GURL& url) {
229 scoped_ptr<net::URLFetcher> request =
229 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); 230 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this);
230 request->SetLoadFlags(net::LOAD_DISABLE_CACHE); 231 request->SetLoadFlags(net::LOAD_DISABLE_CACHE);
231 request->SetRequestContext(url_request_context_); 232 request->SetRequestContext(url_request_context_);
232 // Add Chrome experiment state to the request headers. 233 // Add Chrome experiment state to the request headers.
233 net::HttpRequestHeaders headers; 234 net::HttpRequestHeaders headers;
234 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( 235 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
235 request->GetOriginalURL(), false, false, &headers); 236 request->GetOriginalURL(), false, false, &headers);
236 request->SetExtraRequestHeaders(headers.ToString()); 237 request->SetExtraRequestHeaders(headers.ToString());
237 return request; 238 return request;
238 } 239 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); 359 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec);
359 } else { 360 } else {
360 TimeDelta candidate_delay = 361 TimeDelta candidate_delay =
361 scheduling_delay_ * kSchedulingBackoffMultiplier; 362 scheduling_delay_ * kSchedulingBackoffMultiplier;
362 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) 363 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec))
363 scheduling_delay_ = candidate_delay; 364 scheduling_delay_ = candidate_delay;
364 } 365 }
365 } 366 }
366 367
367 } // namespace suggestions 368 } // namespace suggestions
OLDNEW
« no previous file with comments | « components/suggestions/suggestions_service.h ('k') | components/translate/core/browser/translate_url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698