diff options
-rw-r--r-- | chrome/browser/chrome_benchmarking_message_filter.cc | 12 | ||||
-rw-r--r-- | chrome/browser/io_thread.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/webui/net_internals_ui.cc | 25 | ||||
-rw-r--r-- | net/base/host_resolver.cc | 4 | ||||
-rw-r--r-- | net/base/host_resolver.h | 10 | ||||
-rw-r--r-- | net/base/host_resolver_impl.cc | 3 | ||||
-rw-r--r-- | net/base/host_resolver_impl.h | 4 | ||||
-rw-r--r-- | net/base/mapped_host_resolver.cc | 6 | ||||
-rw-r--r-- | net/base/mapped_host_resolver.h | 1 | ||||
-rw-r--r-- | net/dns/async_host_resolver.cc | 4 | ||||
-rw-r--r-- | net/dns/async_host_resolver.h | 2 | ||||
-rw-r--r-- | net/dns/dns_transaction.cc | 8 | ||||
-rw-r--r-- | net/dns/dns_transaction.h | 6 |
13 files changed, 49 insertions, 45 deletions
diff --git a/chrome/browser/chrome_benchmarking_message_filter.cc b/chrome/browser/chrome_benchmarking_message_filter.cc index ff5bed7..577679c 100644 --- a/chrome/browser/chrome_benchmarking_message_filter.cc +++ b/chrome/browser/chrome_benchmarking_message_filter.cc @@ -10,7 +10,8 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/benchmarking_messages.h" #include "chrome/common/chrome_switches.h" -#include "net/base/host_resolver_impl.h" +#include "net/base/host_cache.h" +#include "net/base/host_resolver.h" #include "net/base/net_errors.h" #include "net/disk_cache/disk_cache.h" #include "net/http/http_cache.h" @@ -159,12 +160,9 @@ void ChromeBenchmarkingMessageFilter::OnClearHostResolverCache(int* result) { return; } *result = -1; - net::HostResolverImpl* host_resolver_impl = - request_context_->GetURLRequestContext()-> - host_resolver()->GetAsHostResolverImpl(); - if (host_resolver_impl) { - net::HostCache* cache = host_resolver_impl->cache(); - DCHECK(cache); + net::HostCache* cache = + request_context_->GetURLRequestContext()->host_resolver()->GetHostCache(); + if (cache) { cache->clear(); *result = 0; } diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 3fce1ca..e07e891 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -567,12 +567,9 @@ net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( void IOThread::ClearHostCache() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (globals_->host_resolver->GetAsHostResolverImpl()) { - net::HostCache* host_cache = - globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); - if (host_cache) - host_cache->clear(); - } + net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); + if (host_cache) + host_cache->clear(); } net::SSLConfigService* IOThread::GetSSLConfigService() { diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc index 723990c..a4ced0b 100644 --- a/chrome/browser/ui/webui/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals_ui.cc @@ -45,7 +45,8 @@ #include "grit/generated_resources.h" #include "grit/net_internals_resources.h" #include "net/base/escape.h" -#include "net/base/host_resolver_impl.h" +#include "net/base/host_cache.h" +#include "net/base/host_resolver.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" #include "net/base/sys_addrinfo.h" @@ -85,13 +86,7 @@ const int kLogFormatVersion = 1; // Returns the HostCache for |context|'s primary HostResolver, or NULL if // there is none. net::HostCache* GetHostResolverCache(net::URLRequestContext* context) { - net::HostResolverImpl* host_resolver_impl = - context->host_resolver()->GetAsHostResolverImpl(); - - if (!host_resolver_impl) - return NULL; - - return host_resolver_impl->cache(); + return context->host_resolver()->GetHostCache(); } // Returns the disk cache backend for |context| if there is one, or NULL. @@ -881,11 +876,9 @@ void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( const ListValue* list) { net::URLRequestContext* context = context_getter_->GetURLRequestContext(); - net::HostResolverImpl* host_resolver_impl = - context->host_resolver()->GetAsHostResolverImpl(); net::HostCache* cache = GetHostResolverCache(context); - if (!host_resolver_impl || !cache) { + if (!cache) { SendJavascriptCommand(L"receivedHostResolverInfo", NULL); return; } @@ -894,7 +887,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( dict->SetInteger( "default_address_family", - static_cast<int>(host_resolver_impl->GetDefaultAddressFamily())); + static_cast<int>(context->host_resolver()->GetDefaultAddressFamily())); DictionaryValue* cache_info_dict = new DictionaryValue(); @@ -963,13 +956,9 @@ void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6( const ListValue* list) { net::URLRequestContext* context = context_getter_->GetURLRequestContext(); - net::HostResolverImpl* host_resolver_impl = - context->host_resolver()->GetAsHostResolverImpl(); + net::HostResolver* host_resolver = context->host_resolver(); - if (host_resolver_impl) { - host_resolver_impl->SetDefaultAddressFamily( - net::ADDRESS_FAMILY_UNSPECIFIED); - } + host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); // Cause the renderer to be notified of the new value. OnGetHostResolverInfo(NULL); diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc index 01dfd41..f5d7f53 100644 --- a/net/base/host_resolver.cc +++ b/net/base/host_resolver.cc @@ -26,6 +26,10 @@ HostResolverImpl* HostResolver::GetAsHostResolverImpl() { return NULL; } +HostCache* HostResolver::GetHostCache() { + return NULL; +} + HostResolver::HostResolver() { } diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index ea0f891..11823f4 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -21,6 +21,7 @@ namespace net { class AddressList; class BoundNetLog; +class HostCache; class HostResolverImpl; class HostResolverProc; class NetLog; @@ -190,9 +191,16 @@ class NET_EXPORT HostResolver { // Returns |this| cast to a HostResolverImpl*, or NULL if the subclass // is not compatible with HostResolverImpl. Used primarily to expose - // additional functionality on the about:net-internals page. + // ProbeIPv6Support. + // TODO(mmenke): Get rid of this function, so there's no externally visible + // difference between using a HostResolverImpl and an + // AsyncHostResolver. virtual HostResolverImpl* GetAsHostResolverImpl(); + // Returns the HostResolverCache |this| uses, or NULL if there isn't one. + // Used primarily to clear the cache and for getting debug information. + virtual HostCache* GetHostCache(); + protected: HostResolver(); diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 6cfd788..bc212cf 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -1304,6 +1304,9 @@ HostResolverImpl* HostResolverImpl::GetAsHostResolverImpl() { return this; } +HostCache* HostResolverImpl::GetHostCache() { + return cache_.get(); +} bool HostResolverImpl::ResolveAsIP(const Key& key, const RequestInfo& info, diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h index 36f6fc54..7f8c0b5 100644 --- a/net/base/host_resolver_impl.h +++ b/net/base/host_resolver_impl.h @@ -115,9 +115,6 @@ class NET_EXPORT HostResolverImpl // address family to IPv4 iff IPv6 is not supported. void ProbeIPv6Support(); - // Returns the cache this resolver uses, or NULL if caching is disabled. - HostCache* cache() { return cache_.get(); } - // Applies a set of constraints for requests that belong to the specified // pool. NOTE: Don't call this after requests have been already been started. // @@ -151,6 +148,7 @@ class NET_EXPORT HostResolverImpl virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; virtual HostResolverImpl* GetAsHostResolverImpl() OVERRIDE; + virtual HostCache* GetHostCache() OVERRIDE; private: // Allow tests to access our innards for testing purposes. diff --git a/net/base/mapped_host_resolver.cc b/net/base/mapped_host_resolver.cc index 7364f9e..6e0d2f8 100644 --- a/net/base/mapped_host_resolver.cc +++ b/net/base/mapped_host_resolver.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -57,4 +57,8 @@ HostResolverImpl* MappedHostResolver::GetAsHostResolverImpl() { return impl_->GetAsHostResolverImpl(); } +HostCache* MappedHostResolver::GetHostCache() { + return impl_->GetHostCache(); +} + } // namespace net diff --git a/net/base/mapped_host_resolver.h b/net/base/mapped_host_resolver.h index 26459e9..08755a8 100644 --- a/net/base/mapped_host_resolver.h +++ b/net/base/mapped_host_resolver.h @@ -56,6 +56,7 @@ class NET_EXPORT MappedHostResolver : public HostResolver { virtual void AddObserver(Observer* observer) OVERRIDE; virtual void RemoveObserver(Observer* observer) OVERRIDE; virtual HostResolverImpl* GetAsHostResolverImpl() OVERRIDE; + virtual HostCache* GetHostCache() OVERRIDE; private: scoped_ptr<HostResolver> impl_; diff --git a/net/dns/async_host_resolver.cc b/net/dns/async_host_resolver.cc index ed0d70f..70c9277 100644 --- a/net/dns/async_host_resolver.cc +++ b/net/dns/async_host_resolver.cc @@ -351,8 +351,8 @@ AddressFamily AsyncHostResolver::GetDefaultAddressFamily() const { return ADDRESS_FAMILY_IPV4; } -HostResolverImpl* AsyncHostResolver::GetAsHostResolverImpl() { - return NULL; +HostCache* AsyncHostResolver::GetHostCache() { + return cache_.get(); } void AsyncHostResolver::OnTransactionComplete( diff --git a/net/dns/async_host_resolver.h b/net/dns/async_host_resolver.h index 9906720..f7e5c53 100644 --- a/net/dns/async_host_resolver.h +++ b/net/dns/async_host_resolver.h @@ -52,7 +52,7 @@ class NET_EXPORT AsyncHostResolver virtual void RemoveObserver(HostResolver::Observer* observer) OVERRIDE; virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; - virtual HostResolverImpl* GetAsHostResolverImpl() OVERRIDE; + virtual HostCache* GetHostCache() OVERRIDE; // DnsTransaction::Delegate interface virtual void OnTransactionComplete( diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc index 30fd7bf..a7fa922 100644 --- a/net/dns/dns_transaction.cc +++ b/net/dns/dns_transaction.cc @@ -84,7 +84,8 @@ class DnsTransactionStartParameters : public NetLog::EventParameters { dict->SetString("dns_server", dns_server_.ToString()); dict->SetString("hostname", hostname); dict->SetInteger("query_type", key_.second); - dict->Set("source_dependency", source_.ToValue()); + if (source_.is_valid()) + dict->Set("source_dependency", source_.ToValue()); return dict; } @@ -107,7 +108,8 @@ class DnsTransactionFinishParameters : public NetLog::EventParameters { list->Append(Value::CreateStringValue(IPAddressToString(*it))); DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger("net_error", net_error_); + if (net_error_) + dict->SetInteger("net_error", net_error_); dict->Set("address_list", list); return dict; } @@ -247,7 +249,7 @@ int DnsTransaction::DoConnect() { socket_.reset(socket_factory_->CreateDatagramClientSocket( DatagramSocket::RANDOM_BIND, base::Bind(&base::RandInt), - NULL, + net_log_.net_log(), net_log_.source())); net_log_.AddEvent( diff --git a/net/dns/dns_transaction.h b/net/dns/dns_transaction.h index 27da32a..c126193 100644 --- a/net/dns/dns_transaction.h +++ b/net/dns/dns_transaction.h @@ -29,15 +29,15 @@ class DnsQuery; class DnsResponse; // Performs (with fixed retries) a single asynchronous DNS transaction, -// which consists of sending out a DNS query, waiting for response, and +// which consists of sending out a DNS query, waiting for a response, and // parsing and returning the IP addresses that it matches. class NET_EXPORT_PRIVATE DnsTransaction : NON_EXPORTED_BASE(public base::NonThreadSafe) { public: typedef std::pair<std::string, uint16> Key; - // Interface that should implemented by DnsTransaction consumer and - // passed to |Start| method to be notified when the transaction has + // Interface that should be implemented by DnsTransaction consumers and + // passed to the |Start| method to be notified when the transaction has // completed. class NET_EXPORT_PRIVATE Delegate { public: |