| 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/omnibox_field_trial.h" | 5 #include "components/omnibox/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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 if (bookmark_value_str.empty()) | 282 if (bookmark_value_str.empty()) |
| 283 return 10; | 283 return 10; |
| 284 // This is a best-effort conversion; we trust the hand-crafted parameters | 284 // This is a best-effort conversion; we trust the hand-crafted parameters |
| 285 // downloaded from the server to be perfect. There's no need for handle | 285 // downloaded from the server to be perfect. There's no need for handle |
| 286 // errors smartly. | 286 // errors smartly. |
| 287 int bookmark_value; | 287 int bookmark_value; |
| 288 base::StringToInt(bookmark_value_str, &bookmark_value); | 288 base::StringToInt(bookmark_value_str, &bookmark_value); |
| 289 return bookmark_value; | 289 return bookmark_value; |
| 290 } | 290 } |
| 291 | 291 |
| 292 bool OmniboxFieldTrial::HQPExperimentalScoringEnabled() { |
| 293 return variations::GetVariationParamValue( |
| 294 kBundledExperimentFieldTrialName, |
| 295 kHQPExperimentalScoringEnabledParam) == "true"; |
| 296 } |
| 297 |
| 298 std::string OmniboxFieldTrial::HQPExperimentalScoringBuckets() { |
| 299 if (!HQPExperimentalScoringEnabled()) |
| 300 return ""; |
| 301 |
| 302 return variations::GetVariationParamValue( |
| 303 kBundledExperimentFieldTrialName, |
| 304 kHQPExperimentalScoringBucketsParam); |
| 305 } |
| 306 |
| 307 float OmniboxFieldTrial::HQPExperimentalTopicalityThreshold() { |
| 308 if (!HQPExperimentalScoringEnabled()) |
| 309 return -1; |
| 310 |
| 311 std::string topicality_threhold_str = |
| 312 variations::GetVariationParamValue( |
| 313 kBundledExperimentFieldTrialName, |
| 314 kHQPExperimentalScoringTopicalityThresholdParam); |
| 315 |
| 316 double topicality_threshold; |
| 317 if (!base::StringToDouble(topicality_threhold_str, &topicality_threshold)) |
| 318 return -1; |
| 319 |
| 320 return static_cast<float>(topicality_threshold); |
| 321 } |
| 322 |
| 292 bool OmniboxFieldTrial::HQPAllowMatchInTLDValue() { | 323 bool OmniboxFieldTrial::HQPAllowMatchInTLDValue() { |
| 293 return variations::GetVariationParamValue( | 324 return variations::GetVariationParamValue( |
| 294 kBundledExperimentFieldTrialName, | 325 kBundledExperimentFieldTrialName, |
| 295 kHQPAllowMatchInTLDRule) == "true"; | 326 kHQPAllowMatchInTLDRule) == "true"; |
| 296 } | 327 } |
| 297 | 328 |
| 298 bool OmniboxFieldTrial::HQPAllowMatchInSchemeValue() { | 329 bool OmniboxFieldTrial::HQPAllowMatchInSchemeValue() { |
| 299 return variations::GetVariationParamValue( | 330 return variations::GetVariationParamValue( |
| 300 kBundledExperimentFieldTrialName, | 331 kBundledExperimentFieldTrialName, |
| 301 kHQPAllowMatchInSchemeRule) == "true"; | 332 kHQPAllowMatchInSchemeRule) == "true"; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 "TypedCountHalfLifeTime"; | 405 "TypedCountHalfLifeTime"; |
| 375 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = | 406 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = |
| 376 "TypedCountScoreBuckets"; | 407 "TypedCountScoreBuckets"; |
| 377 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = | 408 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = |
| 378 "VisitedCountRelevanceCap"; | 409 "VisitedCountRelevanceCap"; |
| 379 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = | 410 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = |
| 380 "VisitedCountHalfLifeTime"; | 411 "VisitedCountHalfLifeTime"; |
| 381 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = | 412 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = |
| 382 "VisitedCountScoreBuckets"; | 413 "VisitedCountScoreBuckets"; |
| 383 | 414 |
| 415 const char OmniboxFieldTrial::kHQPExperimentalScoringEnabledParam[] = |
| 416 "HQPExperimentalScoringEnabled"; |
| 417 const char OmniboxFieldTrial::kHQPExperimentalScoringBucketsParam[] = |
| 418 "HQPExperimentalScoringBuckets"; |
| 419 const char |
| 420 OmniboxFieldTrial::kHQPExperimentalScoringTopicalityThresholdParam[] = |
| 421 "HQPExperimentalScoringTopicalityThreshold"; |
| 422 |
| 384 // static | 423 // static |
| 385 int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 100; | 424 int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 100; |
| 386 | 425 |
| 387 // Background and implementation details: | 426 // Background and implementation details: |
| 388 // | 427 // |
| 389 // Each experiment group in any field trial can come with an optional set of | 428 // Each experiment group in any field trial can come with an optional set of |
| 390 // parameters (key-value pairs). In the bundled omnibox experiment | 429 // parameters (key-value pairs). In the bundled omnibox experiment |
| 391 // (kBundledExperimentFieldTrialName), each experiment group comes with a | 430 // (kBundledExperimentFieldTrialName), each experiment group comes with a |
| 392 // list of parameters in the form: | 431 // list of parameters in the form: |
| 393 // key=<Rule>: | 432 // key=<Rule>: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 if (it != params.end()) | 478 if (it != params.end()) |
| 440 return it->second; | 479 return it->second; |
| 441 // Fall back to the global instant extended context. | 480 // Fall back to the global instant extended context. |
| 442 it = params.find(rule + ":" + page_classification_str + ":*"); | 481 it = params.find(rule + ":" + page_classification_str + ":*"); |
| 443 if (it != params.end()) | 482 if (it != params.end()) |
| 444 return it->second; | 483 return it->second; |
| 445 // Look up rule in the global context. | 484 // Look up rule in the global context. |
| 446 it = params.find(rule + ":*:*"); | 485 it = params.find(rule + ":*:*"); |
| 447 return (it != params.end()) ? it->second : std::string(); | 486 return (it != params.end()) ? it->second : std::string(); |
| 448 } | 487 } |
| OLD | NEW |