| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/debug/leak_tracker.h" | 12 #include "base/debug/leak_tracker.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/field_trial.h" | |
| 15 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 16 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 17 #include "base/string_split.h" | 16 #include "base/string_split.h" |
| 18 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 19 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 20 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 21 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/extensions/extension_event_router_forwarder.h" | 22 #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
| 24 #include "chrome/browser/media/media_internals.h" | 23 #include "chrome/browser/media/media_internals.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 std::string s = | 113 std::string s = |
| 115 command_line.GetSwitchValueASCII(switches::kHostResolverParallelism); | 114 command_line.GetSwitchValueASCII(switches::kHostResolverParallelism); |
| 116 | 115 |
| 117 // Parse the switch (it should be a positive integer formatted as decimal). | 116 // Parse the switch (it should be a positive integer formatted as decimal). |
| 118 int n; | 117 int n; |
| 119 if (base::StringToInt(s, &n) && n > 0) { | 118 if (base::StringToInt(s, &n) && n > 0) { |
| 120 parallelism = static_cast<size_t>(n); | 119 parallelism = static_cast<size_t>(n); |
| 121 } else { | 120 } else { |
| 122 LOG(ERROR) << "Invalid switch for host resolver parallelism: " << s; | 121 LOG(ERROR) << "Invalid switch for host resolver parallelism: " << s; |
| 123 } | 122 } |
| 124 } else { | |
| 125 // Set up a field trial to see what impact the total number of concurrent | |
| 126 // resolutions have on DNS resolutions. | |
| 127 base::FieldTrial::Probability kDivisor = 1000; | |
| 128 // For each option (i.e., non-default), we have a fixed probability. | |
| 129 base::FieldTrial::Probability kProbabilityPerGroup = 100; // 10%. | |
| 130 | |
| 131 // After June 30, 2011 builds, it will always be in default group | |
| 132 // (parallel_default). | |
| 133 scoped_refptr<base::FieldTrial> trial( | |
| 134 new base::FieldTrial( | |
| 135 "DnsParallelism", kDivisor, "parallel_default", 2011, 6, 30)); | |
| 136 | |
| 137 // List options with different counts. | |
| 138 // Firefox limits total to 8 in parallel, and default is currently 50. | |
| 139 int parallel_6 = trial->AppendGroup("parallel_6", kProbabilityPerGroup); | |
| 140 int parallel_7 = trial->AppendGroup("parallel_7", kProbabilityPerGroup); | |
| 141 int parallel_8 = trial->AppendGroup("parallel_8", kProbabilityPerGroup); | |
| 142 int parallel_9 = trial->AppendGroup("parallel_9", kProbabilityPerGroup); | |
| 143 int parallel_10 = trial->AppendGroup("parallel_10", kProbabilityPerGroup); | |
| 144 int parallel_14 = trial->AppendGroup("parallel_14", kProbabilityPerGroup); | |
| 145 int parallel_20 = trial->AppendGroup("parallel_20", kProbabilityPerGroup); | |
| 146 | |
| 147 if (trial->group() == parallel_6) | |
| 148 parallelism = 6; | |
| 149 else if (trial->group() == parallel_7) | |
| 150 parallelism = 7; | |
| 151 else if (trial->group() == parallel_8) | |
| 152 parallelism = 8; | |
| 153 else if (trial->group() == parallel_9) | |
| 154 parallelism = 9; | |
| 155 else if (trial->group() == parallel_10) | |
| 156 parallelism = 10; | |
| 157 else if (trial->group() == parallel_14) | |
| 158 parallelism = 14; | |
| 159 else if (trial->group() == parallel_20) | |
| 160 parallelism = 20; | |
| 161 } | 123 } |
| 162 | 124 |
| 163 size_t retry_attempts = net::HostResolver::kDefaultRetryAttempts; | 125 size_t retry_attempts = net::HostResolver::kDefaultRetryAttempts; |
| 164 | 126 |
| 165 // Use the retry attempts override from the command-line, if any. | 127 // Use the retry attempts override from the command-line, if any. |
| 166 if (command_line.HasSwitch(switches::kHostResolverRetryAttempts)) { | 128 if (command_line.HasSwitch(switches::kHostResolverRetryAttempts)) { |
| 167 std::string s = | 129 std::string s = |
| 168 command_line.GetSwitchValueASCII(switches::kHostResolverRetryAttempts); | 130 command_line.GetSwitchValueASCII(switches::kHostResolverRetryAttempts); |
| 169 // Parse the switch (it should be a non-negative integer). | 131 // Parse the switch (it should be a non-negative integer). |
| 170 int n; | 132 int n; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 system_params.network_delegate = globals_->system_network_delegate.get(); | 632 system_params.network_delegate = globals_->system_network_delegate.get(); |
| 671 system_params.net_log = net_log_; | 633 system_params.net_log = net_log_; |
| 672 globals_->system_http_transaction_factory.reset( | 634 globals_->system_http_transaction_factory.reset( |
| 673 new net::HttpNetworkLayer( | 635 new net::HttpNetworkLayer( |
| 674 new net::HttpNetworkSession(system_params))); | 636 new net::HttpNetworkSession(system_params))); |
| 675 globals_->system_ftp_transaction_factory.reset( | 637 globals_->system_ftp_transaction_factory.reset( |
| 676 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 638 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 677 globals_->system_request_context = | 639 globals_->system_request_context = |
| 678 ConstructSystemRequestContext(globals_, net_log_); | 640 ConstructSystemRequestContext(globals_, net_log_); |
| 679 } | 641 } |
| OLD | NEW |