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

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

Issue 1006001: Refine IPv6 probe to require that the client has an IPv6 address on an interf... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | net/base/host_resolver_impl.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/net/chrome_net_log.h" 11 #include "chrome/browser/net/chrome_net_log.h"
12 #include "chrome/browser/net/dns_global.h" 12 #include "chrome/browser/net/dns_global.h"
13 #include "chrome/browser/net/passive_log_collector.h" 13 #include "chrome/browser/net/passive_log_collector.h"
14 #include "chrome/browser/net/url_fetcher.h" 14 #include "chrome/browser/net/url_fetcher.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "net/base/mapped_host_resolver.h" 16 #include "net/base/mapped_host_resolver.h"
17 #include "net/base/host_cache.h" 17 #include "net/base/host_cache.h"
18 #include "net/base/host_resolver.h" 18 #include "net/base/host_resolver.h"
19 #include "net/base/host_resolver_impl.h" 19 #include "net/base/host_resolver_impl.h"
20 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
21 #include "net/base/network_change_notifier.h" 21 #include "net/base/network_change_notifier.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/url_request/url_request.h" 24 #include "net/url_request/url_request.h"
25 25
26 namespace { 26 namespace {
27 27
28 net::HostResolver* CreateGlobalHostResolver( 28 net::HostResolver* CreateGlobalHostResolver(
29 net::NetworkChangeNotifier* network_change_notifier) { 29 net::NetworkChangeNotifier* network_change_notifier) {
30 net::HostResolver* global_host_resolver = NULL;
31
32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 30 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
33 31 net::HostResolver* global_host_resolver =
34 global_host_resolver =
35 net::CreateSystemHostResolver(network_change_notifier); 32 net::CreateSystemHostResolver(network_change_notifier);
36 33
34 // Determine if we should disable IPv6 support.
37 if (!command_line.HasSwitch(switches::kEnableIPv6)) { 35 if (!command_line.HasSwitch(switches::kEnableIPv6)) {
38 // Measure impact of allowing IPv6 support without probing. 36 if (command_line.HasSwitch(switches::kDisableIPv6)) {
39 const FieldTrial::Probability kDivisor = 100; 37 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
40 const FieldTrial::Probability kProbability = 50; // 50% probability. 38 } else {
41 FieldTrial* trial = new FieldTrial("IPv6_Probe", kDivisor); 39 net::HostResolverImpl* host_resolver_impl =
42 int skip_group = trial->AppendGroup("_IPv6_probe_skipped", kProbability); 40 global_host_resolver->GetAsHostResolverImpl();
43 trial->AppendGroup("_IPv6_probe_done", 41 if (host_resolver_impl != NULL) {
44 FieldTrial::kAllRemainingProbability); 42 // (optionally) Use probe to decide if support is warranted.
45 bool use_ipv6_probe = (trial->group() != skip_group);
46 43
47 // Perform probe, and then optionally use result to disable IPv6. 44 // Measure impact of probing to allow IPv6.
48 // Some users report confused OS handling of IPv6, leading to large 45 // Some users report confused OS handling of IPv6, leading to large
49 // latency. If we can show that IPv6 is not supported, then disabliing it 46 // latency. If we can show that IPv6 is not supported, then disabliing
50 // will work around such problems. 47 // it will work around such problems.
51 if ((!net::IPv6Supported() && use_ipv6_probe) || 48 const FieldTrial::Probability kDivisor = 100;
52 command_line.HasSwitch(switches::kDisableIPv6)) 49 const FieldTrial::Probability kProbability = 50; // 50% probability.
53 global_host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); 50 FieldTrial* trial = new FieldTrial("IPv6_Probe", kDivisor);
51 int skip_group = trial->AppendGroup("_IPv6_probe_skipped",
52 kProbability);
53 trial->AppendGroup("_IPv6_probe_done",
54 FieldTrial::kAllRemainingProbability);
55 bool use_ipv6_probe = (trial->group() != skip_group);
56 if (use_ipv6_probe)
57 host_resolver_impl->ProbeIPv6Support();
58 }
59 }
54 } 60 }
55 61
56 // If hostname remappings were specified on the command-line, layer these 62 // If hostname remappings were specified on the command-line, layer these
57 // rules on top of the real host resolver. This allows forwarding all requests 63 // rules on top of the real host resolver. This allows forwarding all requests
58 // through a designated test server. 64 // through a designated test server.
59 if (command_line.HasSwitch(switches::kHostResolverRules)) { 65 if (!command_line.HasSwitch(switches::kHostResolverRules))
60 net::MappedHostResolver* remapped_resolver = 66 return global_host_resolver;
61 new net::MappedHostResolver(global_host_resolver);
62 global_host_resolver = remapped_resolver;
63 remapped_resolver->SetRulesFromString(
64 command_line.GetSwitchValueASCII(switches::kHostResolverRules));
65 }
66 67
67 return global_host_resolver; 68 net::MappedHostResolver* remapped_resolver =
69 new net::MappedHostResolver(global_host_resolver);
70 remapped_resolver->SetRulesFromString(
71 command_line.GetSwitchValueASCII(switches::kHostResolverRules));
72 return remapped_resolver;
68 } 73 }
69 74
70 } // namespace 75 } // namespace
71 76
72 // The IOThread object must outlive any tasks posted to the IO thread before the 77 // The IOThread object must outlive any tasks posted to the IO thread before the
73 // Quit task. 78 // Quit task.
74 template <> 79 template <>
75 struct RunnableMethodTraits<IOThread> { 80 struct RunnableMethodTraits<IOThread> {
76 void RetainCallee(IOThread* /* io_thread */) {} 81 void RetainCallee(IOThread* /* io_thread */) {}
77 void ReleaseCallee(IOThread* /* io_thread */) {} 82 void ReleaseCallee(IOThread* /* io_thread */) {}
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 net::HostCache* host_cache = 247 net::HostCache* host_cache =
243 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); 248 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache();
244 if (host_cache) 249 if (host_cache)
245 host_cache->clear(); 250 host_cache->clear();
246 } 251 }
247 // Clear all of the passively logged data. 252 // Clear all of the passively logged data.
248 // TODO(eroman): this is a bit heavy handed, really all we need to do is 253 // TODO(eroman): this is a bit heavy handed, really all we need to do is
249 // clear the data pertaining to off the record context. 254 // clear the data pertaining to off the record context.
250 globals_->net_log->passive_collector()->Clear(); 255 globals_->net_log->passive_collector()->Clear();
251 } 256 }
OLDNEW
« no previous file with comments | « no previous file | net/base/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698