Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/omnibox_field_trial.h" | 5 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 if (typed_value_str.empty()) | 436 if (typed_value_str.empty()) |
| 437 return 20; | 437 return 20; |
| 438 // This is a best-effort conversion; we trust the hand-crafted parameters | 438 // This is a best-effort conversion; we trust the hand-crafted parameters |
| 439 // downloaded from the server to be perfect. There's no need for handle | 439 // downloaded from the server to be perfect. There's no need for handle |
| 440 // errors smartly. | 440 // errors smartly. |
| 441 double typed_value; | 441 double typed_value; |
| 442 base::StringToDouble(typed_value_str, &typed_value); | 442 base::StringToDouble(typed_value_str, &typed_value); |
| 443 return typed_value; | 443 return typed_value; |
| 444 } | 444 } |
| 445 | 445 |
| 446 void OmniboxFieldTrial::HQPGetNumMatchesMultipliers( | |
| 447 NumMatchesMultipliers* num_matches_multipliers) { | |
| 448 std::string str = variations::GetVariationParamValue( | |
| 449 kBundledExperimentFieldTrialName, kHQPNumMatchesMultipliersRule); | |
| 450 // The parameter is a comma-separated list of (number, value) pairs. | |
| 451 // e.g., "1:3,2:2.5,3:2,4:1.5" | |
|
Peter Kasting
2016/12/01 07:07:53
Super nitpicky nit:
"pairs, e.g. "..."."
(comma
Mark P
2016/12/04 01:06:41
Done.
| |
| 452 // This is a best-effort conversion; we trust the hand-crafted parameters | |
| 453 // downloaded from the server to be perfect. There's no need for handle | |
|
Peter Kasting
2016/12/01 07:07:53
Nit: for -> to
Mark P
2016/12/04 01:06:41
Done.
| |
| 454 // errors smartly. | |
| 455 base::StringPairs kv_pairs; | |
| 456 if (!base::SplitStringIntoKeyValuePairs(str, ':', ',', &kv_pairs)) | |
| 457 return; | |
| 458 for (base::StringPairs::const_iterator it = kv_pairs.begin(); | |
| 459 it != kv_pairs.end(); ++it) { | |
|
Peter Kasting
2016/12/01 07:07:53
Nit: Range-based for?
Mark P
2016/12/04 01:06:41
Now moot.
| |
| 460 size_t num; | |
| 461 double multiplier; | |
| 462 base::StringToSizeT(it->first, &num); | |
| 463 base::StringToDouble(it->second, &multiplier); | |
| 464 DCHECK(num_matches_multipliers->find(num) == | |
| 465 num_matches_multipliers->end()); | |
|
Peter Kasting
2016/12/01 07:07:53
Nit: DCHECK(!base::ContainsKey(num_matches_multipl
Mark P
2016/12/04 01:06:41
Did something similar.
(Between this duplicates-t
| |
| 466 (*num_matches_multipliers)[num] = multiplier; | |
| 467 } | |
| 468 } | |
| 469 | |
| 446 size_t OmniboxFieldTrial::HQPNumTitleWordsToAllow() { | 470 size_t OmniboxFieldTrial::HQPNumTitleWordsToAllow() { |
| 447 // The value of the rule is a string that encodes an integer (actually | 471 // The value of the rule is a string that encodes an integer (actually |
| 448 // size_t) containing the number of words. | 472 // size_t) containing the number of words. |
| 449 size_t num_title_words; | 473 size_t num_title_words; |
| 450 if (!base::StringToSizeT( | 474 if (!base::StringToSizeT( |
| 451 variations::GetVariationParamValue(kBundledExperimentFieldTrialName, | 475 variations::GetVariationParamValue(kBundledExperimentFieldTrialName, |
| 452 kHQPNumTitleWordsRule), | 476 kHQPNumTitleWordsRule), |
| 453 &num_title_words)) | 477 &num_title_words)) |
| 454 return 20; | 478 return 20; |
| 455 return num_title_words; | 479 return num_title_words; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 "DisableResultsCaching"; | 565 "DisableResultsCaching"; |
| 542 const char | 566 const char |
| 543 OmniboxFieldTrial::kMeasureSuggestPollingDelayFromLastKeystrokeRule[] = | 567 OmniboxFieldTrial::kMeasureSuggestPollingDelayFromLastKeystrokeRule[] = |
| 544 "MeasureSuggestPollingDelayFromLastKeystroke"; | 568 "MeasureSuggestPollingDelayFromLastKeystroke"; |
| 545 const char OmniboxFieldTrial::kSuggestPollingDelayMsRule[] = | 569 const char OmniboxFieldTrial::kSuggestPollingDelayMsRule[] = |
| 546 "SuggestPollingDelayMs"; | 570 "SuggestPollingDelayMs"; |
| 547 const char OmniboxFieldTrial::kHQPFixFewVisitsBugRule[] = "HQPFixFewVisitsBug"; | 571 const char OmniboxFieldTrial::kHQPFixFewVisitsBugRule[] = "HQPFixFewVisitsBug"; |
| 548 const char OmniboxFieldTrial::kHQPFreqencyUsesSumRule[] = "HQPFreqencyUsesSum"; | 572 const char OmniboxFieldTrial::kHQPFreqencyUsesSumRule[] = "HQPFreqencyUsesSum"; |
| 549 const char OmniboxFieldTrial::kHQPMaxVisitsToScoreRule[] = | 573 const char OmniboxFieldTrial::kHQPMaxVisitsToScoreRule[] = |
| 550 "HQPMaxVisitsToScoreRule"; | 574 "HQPMaxVisitsToScoreRule"; |
| 575 const char OmniboxFieldTrial::kHQPNumMatchesMultipliersRule[] = | |
| 576 "HQPNumMatchesMultipliers"; | |
| 551 const char OmniboxFieldTrial::kHQPNumTitleWordsRule[] = "HQPNumTitleWords"; | 577 const char OmniboxFieldTrial::kHQPNumTitleWordsRule[] = "HQPNumTitleWords"; |
| 552 const char OmniboxFieldTrial::kHQPAlsoDoHUPLikeScoringRule[] = | 578 const char OmniboxFieldTrial::kHQPAlsoDoHUPLikeScoringRule[] = |
| 553 "HQPAlsoDoHUPLikeScoring"; | 579 "HQPAlsoDoHUPLikeScoring"; |
| 554 const char OmniboxFieldTrial::kHUPSearchDatabaseRule[] = | 580 const char OmniboxFieldTrial::kHUPSearchDatabaseRule[] = |
| 555 "HUPSearchDatabase"; | 581 "HUPSearchDatabase"; |
| 556 const char OmniboxFieldTrial::kKeywordRequiresRegistryRule[] = | 582 const char OmniboxFieldTrial::kKeywordRequiresRegistryRule[] = |
| 557 "KeywordRequiresRegistry"; | 583 "KeywordRequiresRegistry"; |
| 558 const char OmniboxFieldTrial::kKeywordRequiresPrefixMatchRule[] = | 584 const char OmniboxFieldTrial::kKeywordRequiresPrefixMatchRule[] = |
| 559 "KeywordRequiresPrefixMatch"; | 585 "KeywordRequiresPrefixMatch"; |
| 560 const char OmniboxFieldTrial::kKeywordScoreForSufficientlyCompleteMatchRule[] = | 586 const char OmniboxFieldTrial::kKeywordScoreForSufficientlyCompleteMatchRule[] = |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 if (it != params.end()) | 672 if (it != params.end()) |
| 647 return it->second; | 673 return it->second; |
| 648 // Fall back to the global instant extended context. | 674 // Fall back to the global instant extended context. |
| 649 it = params.find(rule + ":" + page_classification_str + ":*"); | 675 it = params.find(rule + ":" + page_classification_str + ":*"); |
| 650 if (it != params.end()) | 676 if (it != params.end()) |
| 651 return it->second; | 677 return it->second; |
| 652 // Look up rule in the global context. | 678 // Look up rule in the global context. |
| 653 it = params.find(rule + ":*:*"); | 679 it = params.find(rule + ":*:*"); |
| 654 return (it != params.end()) ? it->second : std::string(); | 680 return (it != params.end()) ? it->second : std::string(); |
| 655 } | 681 } |
| OLD | NEW |