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

Side by Side Diff: components/omnibox/browser/zero_suggest_provider.cc

Issue 1330443002: Report data usage UMA for Chrome services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Fix calling Init function in sync_client.cc Created 5 years, 3 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
« no previous file with comments | « components/omnibox/browser/search_provider.cc ('k') | components/policy/core/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/omnibox/browser/zero_suggest_provider.h" 5 #include "components/omnibox/browser/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"
11 #include "base/metrics/user_metrics.h" 11 #include "base/metrics/user_metrics.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "components/data_use_measurement/core/data_use_user_data.h"
17 #include "components/history/core/browser/history_types.h" 18 #include "components/history/core/browser/history_types.h"
18 #include "components/history/core/browser/top_sites.h" 19 #include "components/history/core/browser/top_sites.h"
19 #include "components/metrics/proto/omnibox_input_type.pb.h" 20 #include "components/metrics/proto/omnibox_input_type.pb.h"
20 #include "components/omnibox/browser/autocomplete_classifier.h" 21 #include "components/omnibox/browser/autocomplete_classifier.h"
21 #include "components/omnibox/browser/autocomplete_input.h" 22 #include "components/omnibox/browser/autocomplete_input.h"
22 #include "components/omnibox/browser/autocomplete_match.h" 23 #include "components/omnibox/browser/autocomplete_match.h"
23 #include "components/omnibox/browser/autocomplete_provider_listener.h" 24 #include "components/omnibox/browser/autocomplete_provider_listener.h"
24 #include "components/omnibox/browser/history_url_provider.h" 25 #include "components/omnibox/browser/history_url_provider.h"
25 #include "components/omnibox/browser/omnibox_field_trial.h" 26 #include "components/omnibox/browser/omnibox_field_trial.h"
26 #include "components/omnibox/browser/omnibox_pref_names.h" 27 #include "components/omnibox/browser/omnibox_pref_names.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (ts) { 313 if (ts) {
313 waiting_for_most_visited_urls_request_ = true; 314 waiting_for_most_visited_urls_request_ = true;
314 ts->GetMostVisitedURLs( 315 ts->GetMostVisitedURLs(
315 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable, 316 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable,
316 weak_ptr_factory_.GetWeakPtr()), false); 317 weak_ptr_factory_.GetWeakPtr()), false);
317 } 318 }
318 } else { 319 } else {
319 const int kFetcherID = 1; 320 const int kFetcherID = 1;
320 fetcher_ = net::URLFetcher::Create(kFetcherID, suggest_url, 321 fetcher_ = net::URLFetcher::Create(kFetcherID, suggest_url,
321 net::URLFetcher::GET, this); 322 net::URLFetcher::GET, this);
323 data_use_measurement::DataUseUserData::AttachToFetcher(
324 fetcher_.get(), data_use_measurement::DataUseUserData::OMNIBOX);
322 fetcher_->SetRequestContext(client()->GetRequestContext()); 325 fetcher_->SetRequestContext(client()->GetRequestContext());
323 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 326 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
324 // Add Chrome experiment state to the request headers. 327 // Add Chrome experiment state to the request headers.
325 net::HttpRequestHeaders headers; 328 net::HttpRequestHeaders headers;
326 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( 329 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
327 fetcher_->GetOriginalURL(), client()->IsOffTheRecord(), false, 330 fetcher_->GetOriginalURL(), client()->IsOffTheRecord(), false,
328 &headers); 331 &headers);
329 fetcher_->SetExtraRequestHeaders(headers.ToString()); 332 fetcher_->SetExtraRequestHeaders(headers.ToString());
330 fetcher_->Start(); 333 fetcher_->Start();
331 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT); 334 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 if (!json_data.empty()) { 463 if (!json_data.empty()) {
461 scoped_ptr<base::Value> data( 464 scoped_ptr<base::Value> data(
462 SearchSuggestionParser::DeserializeJsonData(json_data)); 465 SearchSuggestionParser::DeserializeJsonData(json_data));
463 if (data && ParseSuggestResults( 466 if (data && ParseSuggestResults(
464 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 467 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
465 ConvertResultsToAutocompleteMatches(); 468 ConvertResultsToAutocompleteMatches();
466 results_from_cache_ = !matches_.empty(); 469 results_from_cache_ = !matches_.empty();
467 } 470 }
468 } 471 }
469 } 472 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/search_provider.cc ('k') | components/policy/core/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698