| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/net/dns_global.h" | 5 #include "chrome/browser/net/dns_global.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 static void DnsMotivatedPrefetch(const std::string& hostname, | 38 static void DnsMotivatedPrefetch(const std::string& hostname, |
| 39 DnsHostInfo::ResolutionMotivation motivation); | 39 DnsHostInfo::ResolutionMotivation motivation); |
| 40 static void DnsPrefetchMotivatedList( | 40 static void DnsPrefetchMotivatedList( |
| 41 const NameList& hostnames, | 41 const NameList& hostnames, |
| 42 DnsHostInfo::ResolutionMotivation motivation); | 42 DnsHostInfo::ResolutionMotivation motivation); |
| 43 | 43 |
| 44 // static | 44 // static |
| 45 const size_t DnsGlobalInit::kMaxPrefetchConcurrentLookups = 8; | 45 const size_t DnsGlobalInit::kMaxPrefetchConcurrentLookups = 8; |
| 46 | 46 |
| 47 // static | 47 // static |
| 48 const int DnsGlobalInit::kMaxPrefetchQueueingDelayMs = 1000; | 48 const int DnsGlobalInit::kMaxPrefetchQueueingDelayMs = 500; |
| 49 | 49 |
| 50 // Host resolver shared by DNS prefetcher, and the main URLRequestContext. | 50 // Host resolver shared by DNS prefetcher, and the main URLRequestContext. |
| 51 static net::HostResolver* global_host_resolver = NULL; | 51 static net::HostResolver* global_host_resolver = NULL; |
| 52 | 52 |
| 53 //------------------------------------------------------------------------------ | 53 //------------------------------------------------------------------------------ |
| 54 // This section contains all the globally accessable API entry points for the | 54 // This section contains all the globally accessable API entry points for the |
| 55 // DNS Prefetching feature. | 55 // DNS Prefetching feature. |
| 56 //------------------------------------------------------------------------------ | 56 //------------------------------------------------------------------------------ |
| 57 | 57 |
| 58 // Status of prefetch feature, controlling whether any prefetching is done. | 58 // Status of prefetch feature, controlling whether any prefetching is done. |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 // Methods for the helper class that is used to startup and teardown the whole | 614 // Methods for the helper class that is used to startup and teardown the whole |
| 615 // DNS prefetch system. | 615 // DNS prefetch system. |
| 616 | 616 |
| 617 DnsGlobalInit::DnsGlobalInit(PrefService* user_prefs, | 617 DnsGlobalInit::DnsGlobalInit(PrefService* user_prefs, |
| 618 PrefService* local_state) { | 618 PrefService* local_state) { |
| 619 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 619 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 620 // Set up a field trial to see what disabling DNS pre-resolution does to | 620 // Set up a field trial to see what disabling DNS pre-resolution does to |
| 621 // latency of page loads. | 621 // latency of page loads. |
| 622 FieldTrial::Probability kDivisor = 100; | 622 FieldTrial::Probability kDivisor = 100; |
| 623 // For each option (i.e., non-default), we have a fixed probability. | 623 // For each option (i.e., non-default), we have a fixed probability. |
| 624 FieldTrial::Probability kProbabilityPerGroup = 10; // 10% probability. | 624 FieldTrial::Probability kProbabilityPerGroup = 3; // 3% probability. |
| 625 | 625 |
| 626 trial_ = new FieldTrial("DnsImpact", kDivisor); | 626 trial_ = new FieldTrial("DnsImpact", kDivisor); |
| 627 | 627 |
| 628 // First option is to disable prefetching completely. | 628 // First option is to disable prefetching completely. |
| 629 int disabled_prefetch = trial_->AppendGroup("_disabled_prefetch", | 629 int disabled_prefetch = trial_->AppendGroup("_disabled_prefetch", |
| 630 kProbabilityPerGroup); | 630 kProbabilityPerGroup); |
| 631 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second | 631 // Set congestion detection at 250, 500, or 750ms, rather than the 1 second |
| 632 // default. | 632 // default. |
| 633 int max_250ms_prefetch = trial_->AppendGroup("_max_250ms_queue_prefetch", | 633 int max_250ms_prefetch = trial_->AppendGroup("_max_250ms_queue_prefetch", |
| 634 kProbabilityPerGroup); | 634 kProbabilityPerGroup); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 RestoreSubresourceReferrers(local_state); | 673 RestoreSubresourceReferrers(local_state); |
| 674 } | 674 } |
| 675 } | 675 } |
| 676 | 676 |
| 677 DnsGlobalInit::~DnsGlobalInit() { | 677 DnsGlobalInit::~DnsGlobalInit() { |
| 678 if (dns_master) | 678 if (dns_master) |
| 679 FreeDnsPrefetchResources(); | 679 FreeDnsPrefetchResources(); |
| 680 } | 680 } |
| 681 | 681 |
| 682 } // namespace chrome_browser_net | 682 } // namespace chrome_browser_net |
| OLD | NEW |