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

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

Issue 2728663005: Add a histogram for omnibox answer suggestion types. (Closed)
Patch Set: Created 3 years, 9 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/omnibox/browser/search_suggestion_parser.h" 5 #include "components/omnibox/browser/search_suggestion_parser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 suggestion_detail->GetString("q", &suggest_query_params); 517 suggestion_detail->GetString("q", &suggest_query_params);
518 518
519 // Extract the Answer, if provided. 519 // Extract the Answer, if provided.
520 const base::DictionaryValue* answer_json = NULL; 520 const base::DictionaryValue* answer_json = NULL;
521 if (suggestion_detail->GetDictionary("ansa", &answer_json) && 521 if (suggestion_detail->GetDictionary("ansa", &answer_json) &&
522 suggestion_detail->GetString("ansb", &answer_type_str)) { 522 suggestion_detail->GetString("ansb", &answer_type_str)) {
523 bool answer_parsed_successfully = false; 523 bool answer_parsed_successfully = false;
524 answer = SuggestionAnswer::ParseAnswer(answer_json); 524 answer = SuggestionAnswer::ParseAnswer(answer_json);
525 int answer_type = 0; 525 int answer_type = 0;
526 if (answer && base::StringToInt(answer_type_str, &answer_type)) { 526 if (answer && base::StringToInt(answer_type_str, &answer_type)) {
527 UMA_HISTOGRAM_SPARSE_SLOWLY("Omnibox.AnswerType", answer_type);
Justin Donnelly 2017/03/02 19:00:13 Is this the right way to log this? These type IDs
Mark P 2017/03/02 20:59:35 Aren't there almost always zero or only one answer
Ilya Sherman 2017/03/02 21:17:32 I recommend sparse histograms over enumerated hist
Justin Donnelly 2017/03/02 21:21:25 Yes, there's always zero or one. When there's an a
Mark P 2017/03/02 23:28:48 No "implication." It just means that you're not c
527 answer_parsed_successfully = true; 528 answer_parsed_successfully = true;
528 529
529 answer->set_type(answer_type); 530 answer->set_type(answer_type);
530 answer->AddImageURLsTo(&results->answers_image_urls); 531 answer->AddImageURLsTo(&results->answers_image_urls);
531 532
532 std::string contents; 533 std::string contents;
533 base::JSONWriter::Write(*answer_json, &contents); 534 base::JSONWriter::Write(*answer_json, &contents);
534 answer_contents = base::UTF8ToUTF16(contents); 535 answer_contents = base::UTF8ToUTF16(contents);
535 } else { 536 } else {
536 answer_type_str = base::string16(); 537 answer_type_str = base::string16();
(...skipping 10 matching lines...) Expand all
547 base::CollapseWhitespace(match_contents, false), 548 base::CollapseWhitespace(match_contents, false),
548 match_contents_prefix, annotation, answer_contents, answer_type_str, 549 match_contents_prefix, annotation, answer_contents, answer_type_str,
549 std::move(answer), suggest_query_params, deletion_url, 550 std::move(answer), suggest_query_params, deletion_url,
550 is_keyword_result, relevance, relevances != NULL, should_prefetch, 551 is_keyword_result, relevance, relevances != NULL, should_prefetch,
551 trimmed_input)); 552 trimmed_input));
552 } 553 }
553 } 554 }
554 results->relevances_from_server = relevances != NULL; 555 results->relevances_from_server = relevances != NULL;
555 return true; 556 return true;
556 } 557 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698