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

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

Issue 10828373: [net] Add AsyncDns field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better var names 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/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 virtual ~SystemURLRequestContext() { 102 virtual ~SystemURLRequestContext() {
103 #if defined(USE_NSS) 103 #if defined(USE_NSS)
104 net::SetURLRequestContextForNSSHttpIO(NULL); 104 net::SetURLRequestContextForNSSHttpIO(NULL);
105 #endif // defined(USE_NSS) 105 #endif // defined(USE_NSS)
106 } 106 }
107 }; 107 };
108 108
109 net::HostResolver* CreateGlobalHostResolver(net::NetLog* net_log) { 109 net::HostResolver* CreateGlobalHostResolver(net::NetLog* net_log) {
110 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 110 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
111 111
112 bool allow_async_dns_field_trial = true;
113
112 size_t parallelism = net::HostResolver::kDefaultParallelism; 114 size_t parallelism = net::HostResolver::kDefaultParallelism;
113 115
114 // Use the concurrency override from the command-line, if any. 116 // Use the concurrency override from the command-line, if any.
115 if (command_line.HasSwitch(switches::kHostResolverParallelism)) { 117 if (command_line.HasSwitch(switches::kHostResolverParallelism)) {
cbentzel 2012/08/20 11:45:56 Did you see if we could just get rid of the kHostR
szym 2012/08/20 17:54:21 Judging from the old bugs which established our cu
118 allow_async_dns_field_trial = false;
116 std::string s = 119 std::string s =
117 command_line.GetSwitchValueASCII(switches::kHostResolverParallelism); 120 command_line.GetSwitchValueASCII(switches::kHostResolverParallelism);
118 121
119 // Parse the switch (it should be a positive integer formatted as decimal). 122 // Parse the switch (it should be a positive integer formatted as decimal).
120 int n; 123 int n;
121 if (base::StringToInt(s, &n) && n > 0) { 124 if (base::StringToInt(s, &n) && n > 0) {
122 parallelism = static_cast<size_t>(n); 125 parallelism = static_cast<size_t>(n);
123 } else { 126 } else {
124 LOG(ERROR) << "Invalid switch for host resolver parallelism: " << s; 127 LOG(ERROR) << "Invalid switch for host resolver parallelism: " << s;
125 } 128 }
126 } 129 }
127 130
128 size_t retry_attempts = net::HostResolver::kDefaultRetryAttempts; 131 size_t retry_attempts = net::HostResolver::kDefaultRetryAttempts;
129 132
130 // Use the retry attempts override from the command-line, if any. 133 // Use the retry attempts override from the command-line, if any.
131 if (command_line.HasSwitch(switches::kHostResolverRetryAttempts)) { 134 if (command_line.HasSwitch(switches::kHostResolverRetryAttempts)) {
135 allow_async_dns_field_trial = false;
132 std::string s = 136 std::string s =
133 command_line.GetSwitchValueASCII(switches::kHostResolverRetryAttempts); 137 command_line.GetSwitchValueASCII(switches::kHostResolverRetryAttempts);
134 // Parse the switch (it should be a non-negative integer). 138 // Parse the switch (it should be a non-negative integer).
135 int n; 139 int n;
136 if (base::StringToInt(s, &n) && n >= 0) { 140 if (base::StringToInt(s, &n) && n >= 0) {
137 retry_attempts = static_cast<size_t>(n); 141 retry_attempts = static_cast<size_t>(n);
138 } else { 142 } else {
139 LOG(ERROR) << "Invalid switch for host resolver retry attempts: " << s; 143 LOG(ERROR) << "Invalid switch for host resolver retry attempts: " << s;
140 } 144 }
141 } 145 }
142 146
143 net::HostResolver* global_host_resolver = NULL; 147 net::HostResolver* global_host_resolver = NULL;
148 bool use_async = false;
144 if (command_line.HasSwitch(switches::kEnableAsyncDns)) { 149 if (command_line.HasSwitch(switches::kEnableAsyncDns)) {
cbentzel 2012/08/20 11:45:56 Why isn't this just --async-dns=[enabled|disabled|
szym 2012/08/20 17:54:21 I followed the existing flags. There's currently 8
cbentzel 2012/08/21 10:50:53 No - it sounds different from common practice.
150 allow_async_dns_field_trial = false;
151 use_async = true;
152 } else if (command_line.HasSwitch(switches::kDisableAsyncDns)) {
153 allow_async_dns_field_trial = false;
154 use_async = false;
155 }
156
157 if (allow_async_dns_field_trial)
158 use_async = net::ConfigureAsyncDnsFieldTrial();
159
160 if (use_async) {
145 global_host_resolver = 161 global_host_resolver =
146 net::CreateAsyncHostResolver(parallelism, retry_attempts, net_log); 162 net::CreateAsyncHostResolver(parallelism, retry_attempts, net_log);
147 } 163 } else {
148
149 if (!global_host_resolver) {
150 global_host_resolver = 164 global_host_resolver =
151 net::CreateSystemHostResolver(parallelism, retry_attempts, net_log); 165 net::CreateSystemHostResolver(parallelism, retry_attempts, net_log);
152 } 166 }
153 167
154 // Determine if we should disable IPv6 support. 168 // Determine if we should disable IPv6 support.
155 if (!command_line.HasSwitch(switches::kEnableIPv6)) { 169 if (!command_line.HasSwitch(switches::kEnableIPv6)) {
156 if (command_line.HasSwitch(switches::kDisableIPv6)) { 170 if (command_line.HasSwitch(switches::kDisableIPv6)) {
157 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); 171 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
158 } else { 172 } else {
159 global_host_resolver->ProbeIPv6Support(); 173 global_host_resolver->ProbeIPv6Support();
160 } 174 }
161 } 175 }
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 new net::HttpNetworkLayer( 644 new net::HttpNetworkLayer(
631 new net::HttpNetworkSession(system_params))); 645 new net::HttpNetworkSession(system_params)));
632 globals_->system_ftp_transaction_factory.reset( 646 globals_->system_ftp_transaction_factory.reset(
633 new net::FtpNetworkLayer(globals_->host_resolver.get())); 647 new net::FtpNetworkLayer(globals_->host_resolver.get()));
634 globals_->system_request_context.reset( 648 globals_->system_request_context.reset(
635 ConstructSystemRequestContext(globals_, net_log_)); 649 ConstructSystemRequestContext(globals_, net_log_));
636 650
637 sdch_manager_->set_sdch_fetcher( 651 sdch_manager_->set_sdch_fetcher(
638 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 652 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
639 } 653 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698