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

Side by Side Diff: chrome/browser/autocomplete/zero_suggest_provider.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 "chrome/browser/autocomplete/zero_suggest_provider.h" 5 #include "chrome/browser/autocomplete/zero_suggest_provider.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/i18n/case_conversion.h" 8 #include "base/i18n/case_conversion.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 scoped_refptr<history::TopSites> ts = 323 scoped_refptr<history::TopSites> ts =
324 TopSitesFactory::GetForProfile(profile_); 324 TopSitesFactory::GetForProfile(profile_);
325 if (ts) { 325 if (ts) {
326 waiting_for_most_visited_urls_request_ = true; 326 waiting_for_most_visited_urls_request_ = true;
327 ts->GetMostVisitedURLs( 327 ts->GetMostVisitedURLs(
328 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable, 328 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable,
329 weak_ptr_factory_.GetWeakPtr()), false); 329 weak_ptr_factory_.GetWeakPtr()), false);
330 } 330 }
331 } else { 331 } else {
332 const int kFetcherID = 1; 332 const int kFetcherID = 1;
333 fetcher_.reset( 333 fetcher_ = net::URLFetcher::Create(kFetcherID, suggest_url,
334 net::URLFetcher::Create(kFetcherID, 334 net::URLFetcher::GET, this);
335 suggest_url,
336 net::URLFetcher::GET, this));
337 fetcher_->SetRequestContext(profile_->GetRequestContext()); 335 fetcher_->SetRequestContext(profile_->GetRequestContext());
338 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 336 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
339 // Add Chrome experiment state to the request headers. 337 // Add Chrome experiment state to the request headers.
340 net::HttpRequestHeaders headers; 338 net::HttpRequestHeaders headers;
341 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( 339 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
342 fetcher_->GetOriginalURL(), profile_->IsOffTheRecord(), false, 340 fetcher_->GetOriginalURL(), profile_->IsOffTheRecord(), false,
343 &headers); 341 &headers);
344 fetcher_->SetExtraRequestHeaders(headers.ToString()); 342 fetcher_->SetExtraRequestHeaders(headers.ToString());
345 fetcher_->Start(); 343 fetcher_->Start();
346 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); 344 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 if (!json_data.empty()) { 481 if (!json_data.empty()) {
484 scoped_ptr<base::Value> data( 482 scoped_ptr<base::Value> data(
485 SearchSuggestionParser::DeserializeJsonData(json_data)); 483 SearchSuggestionParser::DeserializeJsonData(json_data));
486 if (data && ParseSuggestResults( 484 if (data && ParseSuggestResults(
487 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 485 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
488 ConvertResultsToAutocompleteMatches(); 486 ConvertResultsToAutocompleteMatches();
489 results_from_cache_ = !matches_.empty(); 487 results_from_cache_ = !matches_.empty();
490 } 488 }
491 } 489 }
492 } 490 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/drive/drive_app_converter.cc ('k') | chrome/browser/bitmap_fetcher/bitmap_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698