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

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

Issue 3019007: Add a command line flag to change the default number of parallel DNS requests... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address jar's comments Created 10 years, 5 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
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/leak_tracker.h" 7 #include "base/leak_tracker.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_thread.h" 10 #include "chrome/browser/chrome_thread.h"
11 #include "chrome/browser/gpu_process_host.h" 11 #include "chrome/browser/gpu_process_host.h"
12 #include "chrome/browser/net/chrome_net_log.h" 12 #include "chrome/browser/net/chrome_net_log.h"
13 #include "chrome/browser/net/predictor_api.h" 13 #include "chrome/browser/net/predictor_api.h"
14 #include "chrome/browser/net/passive_log_collector.h" 14 #include "chrome/browser/net/passive_log_collector.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/net/url_fetcher.h" 16 #include "chrome/common/net/url_fetcher.h"
17 #include "net/base/mapped_host_resolver.h" 17 #include "net/base/mapped_host_resolver.h"
18 #include "net/base/host_cache.h" 18 #include "net/base/host_cache.h"
19 #include "net/base/host_resolver.h" 19 #include "net/base/host_resolver.h"
20 #include "net/base/host_resolver_impl.h" 20 #include "net/base/host_resolver_impl.h"
21 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
22 #include "net/http/http_auth_filter.h" 22 #include "net/http/http_auth_filter.h"
23 #include "net/http/http_auth_handler_factory.h" 23 #include "net/http/http_auth_handler_factory.h"
24 #include "net/http/http_auth_handler_negotiate.h" 24 #include "net/http/http_auth_handler_negotiate.h"
25 25
26 namespace { 26 namespace {
27 27
28 net::HostResolver* CreateGlobalHostResolver() { 28 net::HostResolver* CreateGlobalHostResolver() {
29 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 29 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
30 net::HostResolver* global_host_resolver = net::CreateSystemHostResolver(); 30
31 size_t parallelism = net::HostResolver::kDefaultParallelism;
32
33 // Use the concurrency override from the command-line, if any.
34 if (command_line.HasSwitch(switches::kHostResolverParallelism)) {
35 std::string s =
36 command_line.GetSwitchValueASCII(switches::kHostResolverParallelism);
37
38 // Parse the switch (it should be a positive integer formatted as decimal).
39 int n;
40 if (StringToInt(s, &n) && n > 0) {
41 parallelism = static_cast<size_t>(n);
42 } else {
43 LOG(ERROR) << "Invalid switch for host resolver parallelism: " << s;
44 }
45 }
46
47 net::HostResolver* global_host_resolver =
48 net::CreateSystemHostResolver(parallelism);
31 49
32 // Determine if we should disable IPv6 support. 50 // Determine if we should disable IPv6 support.
33 if (!command_line.HasSwitch(switches::kEnableIPv6)) { 51 if (!command_line.HasSwitch(switches::kEnableIPv6)) {
34 if (command_line.HasSwitch(switches::kDisableIPv6)) { 52 if (command_line.HasSwitch(switches::kDisableIPv6)) {
35 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); 53 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
36 } else { 54 } else {
37 net::HostResolverImpl* host_resolver_impl = 55 net::HostResolverImpl* host_resolver_impl =
38 global_host_resolver->GetAsHostResolverImpl(); 56 global_host_resolver->GetAsHostResolverImpl();
39 if (host_resolver_impl != NULL) { 57 if (host_resolver_impl != NULL) {
40 // (optionally) Use probe to decide if support is warranted. 58 // (optionally) Use probe to decide if support is warranted.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 net::HostCache* host_cache = 369 net::HostCache* host_cache =
352 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); 370 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache();
353 if (host_cache) 371 if (host_cache)
354 host_cache->clear(); 372 host_cache->clear();
355 } 373 }
356 // Clear all of the passively logged data. 374 // Clear all of the passively logged data.
357 // TODO(eroman): this is a bit heavy handed, really all we need to do is 375 // TODO(eroman): this is a bit heavy handed, really all we need to do is
358 // clear the data pertaining to off the record context. 376 // clear the data pertaining to off the record context.
359 globals_->net_log->passive_collector()->Clear(); 377 globals_->net_log->passive_collector()->Clear();
360 } 378 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698