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

Side by Side Diff: components/omnibox/omnibox_field_trial.cc

Issue 645303003: Parametrize Suggest polling strategy and delay. Also add a parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added more tests. Created 6 years, 2 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/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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 kBundledExperimentFieldTrialName, 329 kBundledExperimentFieldTrialName,
330 kAddUWYTMatchEvenIfPromotedURLsRule) == "true"; 330 kAddUWYTMatchEvenIfPromotedURLsRule) == "true";
331 } 331 }
332 332
333 bool OmniboxFieldTrial::DisplayHintTextWhenPossible() { 333 bool OmniboxFieldTrial::DisplayHintTextWhenPossible() {
334 return variations::GetVariationParamValue( 334 return variations::GetVariationParamValue(
335 kBundledExperimentFieldTrialName, 335 kBundledExperimentFieldTrialName,
336 kDisplayHintTextWhenPossibleRule) == "true"; 336 kDisplayHintTextWhenPossibleRule) == "true";
337 } 337 }
338 338
339 bool OmniboxFieldTrial::DisableResultsCaching() {
340 return variations::GetVariationParamValue(
341 kBundledExperimentFieldTrialName,
342 kDisableResultsCachingRule) == "true";
343 }
344
345 void OmniboxFieldTrial::GetSuggestPollingStrategy(bool* from_last_keystroke,
346 int* polling_delay_ms) {
347 *from_last_keystroke = variations::GetVariationParamValue(
348 kBundledExperimentFieldTrialName,
349 kMeasureSuggestPollingDelayFromLastKeystrokeRule) == "true";
350
351 const std::string& polling_delay_string = variations::GetVariationParamValue(
352 kBundledExperimentFieldTrialName,
353 kSuggestPollingDelayMsRule);
354 if (polling_delay_string.empty() ||
355 !base::StringToInt(polling_delay_string, polling_delay_ms) ||
356 (*polling_delay_ms <= 0)) {
357 *polling_delay_ms = kDefaultMinimumTimeBetweenSuggestQueriesMs;
358 }
359 }
360
339 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = 361 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
340 "OmniboxBundledExperimentV1"; 362 "OmniboxBundledExperimentV1";
341 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = 363 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] =
342 "ShortcutsScoringMaxRelevance"; 364 "ShortcutsScoringMaxRelevance";
343 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; 365 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory";
344 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; 366 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType";
345 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] = 367 const char OmniboxFieldTrial::kHQPBookmarkValueRule[] =
346 "HQPBookmarkValue"; 368 "HQPBookmarkValue";
347 const char OmniboxFieldTrial::kHQPAllowMatchInTLDRule[] = "HQPAllowMatchInTLD"; 369 const char OmniboxFieldTrial::kHQPAllowMatchInTLDRule[] = "HQPAllowMatchInTLD";
348 const char OmniboxFieldTrial::kHQPAllowMatchInSchemeRule[] = 370 const char OmniboxFieldTrial::kHQPAllowMatchInSchemeRule[] =
349 "HQPAllowMatchInScheme"; 371 "HQPAllowMatchInScheme";
350 const char OmniboxFieldTrial::kZeroSuggestRule[] = "ZeroSuggest"; 372 const char OmniboxFieldTrial::kZeroSuggestRule[] = "ZeroSuggest";
351 const char OmniboxFieldTrial::kZeroSuggestVariantRule[] = "ZeroSuggestVariant"; 373 const char OmniboxFieldTrial::kZeroSuggestVariantRule[] = "ZeroSuggestVariant";
352 const char OmniboxFieldTrial::kDisableInliningRule[] = "DisableInlining"; 374 const char OmniboxFieldTrial::kDisableInliningRule[] = "DisableInlining";
353 const char OmniboxFieldTrial::kAnswersInSuggestRule[] = "AnswersInSuggest"; 375 const char OmniboxFieldTrial::kAnswersInSuggestRule[] = "AnswersInSuggest";
354 const char OmniboxFieldTrial::kAddUWYTMatchEvenIfPromotedURLsRule[] = 376 const char OmniboxFieldTrial::kAddUWYTMatchEvenIfPromotedURLsRule[] =
355 "AddUWYTMatchEvenIfPromotedURLs"; 377 "AddUWYTMatchEvenIfPromotedURLs";
356 const char OmniboxFieldTrial::kDisplayHintTextWhenPossibleRule[] = 378 const char OmniboxFieldTrial::kDisplayHintTextWhenPossibleRule[] =
357 "DisplayHintTextWhenPossible"; 379 "DisplayHintTextWhenPossible";
380 const char OmniboxFieldTrial::kDisableResultsCachingRule[] =
381 "DisableResultsCaching";
382 const char
383 OmniboxFieldTrial::kMeasureSuggestPollingDelayFromLastKeystrokeRule[] =
384 "MeasureSuggestPollingDelayFromLastKeystroke";
385 const char OmniboxFieldTrial::kSuggestPollingDelayMsRule[] =
386 "SuggestPollingDelayMs";
358 387
359 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] = 388 const char OmniboxFieldTrial::kHUPNewScoringEnabledParam[] =
360 "HUPExperimentalScoringEnabled"; 389 "HUPExperimentalScoringEnabled";
361 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] = 390 const char OmniboxFieldTrial::kHUPNewScoringTypedCountRelevanceCapParam[] =
362 "TypedCountRelevanceCap"; 391 "TypedCountRelevanceCap";
363 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] = 392 const char OmniboxFieldTrial::kHUPNewScoringTypedCountHalfLifeTimeParam[] =
364 "TypedCountHalfLifeTime"; 393 "TypedCountHalfLifeTime";
365 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] = 394 const char OmniboxFieldTrial::kHUPNewScoringTypedCountScoreBucketsParam[] =
366 "TypedCountScoreBuckets"; 395 "TypedCountScoreBuckets";
367 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] = 396 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountRelevanceCapParam[] =
368 "VisitedCountRelevanceCap"; 397 "VisitedCountRelevanceCap";
369 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] = 398 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountHalfLifeTimeParam[] =
370 "VisitedCountHalfLifeTime"; 399 "VisitedCountHalfLifeTime";
371 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] = 400 const char OmniboxFieldTrial::kHUPNewScoringVisitedCountScoreBucketsParam[] =
372 "VisitedCountScoreBuckets"; 401 "VisitedCountScoreBuckets";
373 402
403 // static
404 int OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs = 100;
405
374 // Background and implementation details: 406 // Background and implementation details:
375 // 407 //
376 // Each experiment group in any field trial can come with an optional set of 408 // Each experiment group in any field trial can come with an optional set of
377 // parameters (key-value pairs). In the bundled omnibox experiment 409 // parameters (key-value pairs). In the bundled omnibox experiment
378 // (kBundledExperimentFieldTrialName), each experiment group comes with a 410 // (kBundledExperimentFieldTrialName), each experiment group comes with a
379 // list of parameters in the form: 411 // list of parameters in the form:
380 // key=<Rule>: 412 // key=<Rule>:
381 // <OmniboxEventProto::PageClassification (as an int)>: 413 // <OmniboxEventProto::PageClassification (as an int)>:
382 // <whether Instant Extended is enabled (as a 1 or 0)> 414 // <whether Instant Extended is enabled (as a 1 or 0)>
383 // (note that there are no linebreaks in keys; this format is for 415 // (note that there are no linebreaks in keys; this format is for
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (it != params.end()) 458 if (it != params.end())
427 return it->second; 459 return it->second;
428 // Fall back to the global instant extended context. 460 // Fall back to the global instant extended context.
429 it = params.find(rule + ":" + page_classification_str + ":*"); 461 it = params.find(rule + ":" + page_classification_str + ":*");
430 if (it != params.end()) 462 if (it != params.end())
431 return it->second; 463 return it->second;
432 // Look up rule in the global context. 464 // Look up rule in the global context.
433 it = params.find(rule + ":*:*"); 465 it = params.find(rule + ":*:*");
434 return (it != params.end()) ? it->second : std::string(); 466 return (it != params.end()) ? it->second : std::string();
435 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698