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

Side by Side Diff: chrome/browser/chrome_browser_field_trials.cc

Issue 10831277: [net] Change factory methods for HostResolver and HostCache to return a scoped_ptr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add ChromeBrowserFieldTrials::AsyncDnsFieldTrial Created 8 years, 4 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 | Annotate | Revision Log
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 "chrome/browser/chrome_browser_field_trials.h" 5 #include "chrome/browser/chrome_browser_field_trials.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 SpdyFieldTrial(); 117 SpdyFieldTrial();
118 ConnectBackupJobsFieldTrial(); 118 ConnectBackupJobsFieldTrial();
119 WarmConnectionFieldTrial(); 119 WarmConnectionFieldTrial();
120 PredictorFieldTrial(); 120 PredictorFieldTrial();
121 DefaultAppsFieldTrial(); 121 DefaultAppsFieldTrial();
122 AutoLaunchChromeFieldTrial(); 122 AutoLaunchChromeFieldTrial();
123 gpu_util::InitializeCompositingFieldTrial(); 123 gpu_util::InitializeCompositingFieldTrial();
124 SetupUniformityFieldTrials(); 124 SetupUniformityFieldTrials();
125 AutocompleteFieldTrial::Activate(); 125 AutocompleteFieldTrial::Activate();
126 DisableNewTabFieldTrialIfNecesssary(); 126 DisableNewTabFieldTrialIfNecesssary();
127 AsyncDnsFieldTrial();
127 } 128 }
128 129
129 // This is an A/B test for the maximum number of persistent connections per 130 // This is an A/B test for the maximum number of persistent connections per
130 // host. Currently Chrome, Firefox, and IE8 have this value set at 6. Safari 131 // host. Currently Chrome, Firefox, and IE8 have this value set at 6. Safari
131 // uses 4, and Fasterfox (a plugin for Firefox that supposedly configures it to 132 // uses 4, and Fasterfox (a plugin for Firefox that supposedly configures it to
132 // run faster) uses 8. We would like to see how much of an effect this value has 133 // run faster) uses 8. We would like to see how much of an effect this value has
133 // on browsing. Too large a value might cause us to run into SYN flood detection 134 // on browsing. Too large a value might cause us to run into SYN flood detection
134 // mechanisms. 135 // mechanisms.
135 void ChromeBrowserFieldTrials::ConnectionFieldTrial() { 136 void ChromeBrowserFieldTrials::ConnectionFieldTrial() {
136 const base::FieldTrial::Probability kConnectDivisor = 100; 137 const base::FieldTrial::Probability kConnectDivisor = 100;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 if (trial) { 576 if (trial) {
576 bool using_hidpi_assets = false; 577 bool using_hidpi_assets = false;
577 #if defined(ENABLE_HIDPI) && defined(OS_WIN) 578 #if defined(ENABLE_HIDPI) && defined(OS_WIN)
578 // Mirrors logic in resource_bundle_win.cc. 579 // Mirrors logic in resource_bundle_win.cc.
579 using_hidpi_assets = ui::GetDPIScale() > 1.5; 580 using_hidpi_assets = ui::GetDPIScale() > 1.5;
580 #endif 581 #endif
581 if (ui::GetDisplayLayout() != ui::LAYOUT_DESKTOP || using_hidpi_assets) 582 if (ui::GetDisplayLayout() != ui::LAYOUT_DESKTOP || using_hidpi_assets)
582 trial->Disable(); 583 trial->Disable();
583 } 584 }
584 } 585 }
586
587 // When --enable-async-dns is not set, users will be in A/B test for DnsClient.
cbentzel 2012/08/16 20:09:21 Do you want to move this to a ternary (enabled/dis
szym 2012/08/16 20:38:55 I'm okay with that. I'm not sure what this means f
588 // group A (async enabled): Use DnsClient if DnsConfig is known. Fall back to
589 // getaddrinfo on failures.
590 // group B (async disabled): Never use DnsClient.
591 void ChromeBrowserFieldTrials::AsyncDnsFieldTrial() {
592 // Use the concurrency override from the command-line, if any.
593 if (parsed_command_line_.HasSwitch(switches::kHostResolverParallelism)) {
594 std::string s = parsed_command_line_.GetSwitchValueASCII(
595 switches::kHostResolverParallelism);
596
597 // Parse the switch (it should be a positive integer formatted as decimal).
598 int n;
599 if (base::StringToInt(s, &n) && n > 0) {
600 net::HostResolver::set_default_max_concurrent_resolves(
601 static_cast<size_t>(n));
602 } else {
603 LOG(ERROR) << "Invalid switch for host resolver parallelism: " << s;
604 }
605 }
606
607 // Use the retry attempts override from the command-line, if any.
608 if (parsed_command_line_.HasSwitch(switches::kHostResolverRetryAttempts)) {
609 std::string s = parsed_command_line_.GetSwitchValueASCII(
610 switches::kHostResolverRetryAttempts);
611 // Parse the switch (it should be a non-negative integer).
612 int n;
613 if (base::StringToInt(s, &n) && n >= 0) {
614 net::HostResolver::set_default_max_retry_attempts(static_cast<size_t>(n));
615 } else {
616 LOG(ERROR) << "Invalid switch for host resolver retry attempts: " << s;
617 }
618 }
619
620 bool use_async = parsed_command_line_.HasSwitch(switches::kEnableAsyncDns);
621 if (use_async) {
622 net::HostResolver::set_default_enable_async(true);
623 return; // Trial disabled.
624 }
625
626 const base::FieldTrial::Probability kAsyncDnsDivisor = 100;
627 base::FieldTrial::Probability enabled_probability = 50;
628
629 scoped_refptr<base::FieldTrial> trial(
630 base::FieldTrialList::FactoryGetFieldTrial(
631 "AsyncDns", kAsyncDnsDivisor, "disabled", 2012, 9, 30, NULL));
632
633 int enabled_group = trial->AppendGroup("enabled", enabled_probability);
634 net::HostResolver::set_default_enable_async(trial->group() == enabled_group);
635 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698