summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 00:49:38 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 00:49:38 +0000
commit8a00f00ab5d68ffcc998fd04d2ca343af7cdf190 (patch)
treefd464ba49db4271c76c1cf8f769a22120ad631af /net/url_request
parent77ae132c1bfdd986228b6f1c0d8c63baa441afdf (diff)
downloadchromium_src-8a00f00ab5d68ffcc998fd04d2ca343af7cdf190.zip
chromium_src-8a00f00ab5d68ffcc998fd04d2ca343af7cdf190.tar.gz
chromium_src-8a00f00ab5d68ffcc998fd04d2ca343af7cdf190.tar.bz2
* Avoid doing concurrent DNS resolves of the same hostname in HostResolver.
* Add a 1 minute cache for host resolves. * Refactor HostResolver to handle multiple requests. * Make HostResolver a dependency of URLRequestContext. operate the HostResolver in async mode for proxy resolver (bridging to IO thread). TEST=unittests BUG=13163 Review URL: http://codereview.chromium.org/118100 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18236 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_context.h9
-rw-r--r--net/url_request/url_request_unittest.cc7
-rw-r--r--net/url_request/url_request_unittest.h10
3 files changed, 21 insertions, 5 deletions
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 8e32c97..2c9f6fa 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -19,6 +19,7 @@ namespace net {
class CookieMonster;
class ForceTLSState;
class FtpTransactionFactory;
+class HostResolver;
class HttpTransactionFactory;
class ProxyService;
}
@@ -28,13 +29,18 @@ class URLRequestContext :
public base::RefCountedThreadSafe<URLRequestContext> {
public:
URLRequestContext()
- : proxy_service_(NULL),
+ : host_resolver_(NULL),
+ proxy_service_(NULL),
http_transaction_factory_(NULL),
ftp_transaction_factory_(NULL),
cookie_store_(NULL),
force_tls_state_(NULL) {
}
+ net::HostResolver* host_resolver() const {
+ return host_resolver_;
+ }
+
// Get the proxy service for this context.
net::ProxyService* proxy_service() const {
return proxy_service_;
@@ -88,6 +94,7 @@ class URLRequestContext :
// The following members are expected to be initialized and owned by
// subclasses.
+ net::HostResolver* host_resolver_;
net::ProxyService* proxy_service_;
net::HttpTransactionFactory* http_transaction_factory_;
net::FtpTransactionFactory* ftp_transaction_factory_;
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 6551df1..18ff111 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -45,10 +45,12 @@ namespace {
class URLRequestHttpCacheContext : public URLRequestContext {
public:
URLRequestHttpCacheContext() {
+ host_resolver_ = new net::HostResolver;
proxy_service_ = net::ProxyService::CreateNull();
http_transaction_factory_ =
- new net::HttpCache(net::HttpNetworkLayer::CreateFactory(proxy_service_),
- disk_cache::CreateInMemoryCacheBackend(0));
+ new net::HttpCache(
+ net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_),
+ disk_cache::CreateInMemoryCacheBackend(0));
// In-memory cookie store.
cookie_store_ = new net::CookieMonster();
}
@@ -57,6 +59,7 @@ class URLRequestHttpCacheContext : public URLRequestContext {
delete cookie_store_;
delete http_transaction_factory_;
delete proxy_service_;
+ delete host_resolver_;
}
};
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index d4e2b82..1c880fd 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -21,6 +21,7 @@
#include "base/thread.h"
#include "base/time.h"
#include "base/waitable_event.h"
+#include "net/base/host_resolver.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/ssl_test_util.h"
@@ -42,22 +43,27 @@ using base::TimeDelta;
class TestURLRequestContext : public URLRequestContext {
public:
TestURLRequestContext() {
+ host_resolver_ = new net::HostResolver;
proxy_service_ = net::ProxyService::CreateNull();
http_transaction_factory_ =
- net::HttpNetworkLayer::CreateFactory(proxy_service_);
+ net::HttpNetworkLayer::CreateFactory(host_resolver_,
+ proxy_service_);
}
explicit TestURLRequestContext(const std::string& proxy) {
+ host_resolver_ = new net::HostResolver;
net::ProxyConfig proxy_config;
proxy_config.proxy_rules.ParseFromString(proxy);
proxy_service_ = net::ProxyService::CreateFixed(proxy_config);
http_transaction_factory_ =
- net::HttpNetworkLayer::CreateFactory(proxy_service_);
+ net::HttpNetworkLayer::CreateFactory(host_resolver_,
+ proxy_service_);
}
virtual ~TestURLRequestContext() {
delete http_transaction_factory_;
delete proxy_service_;
+ delete host_resolver_;
}
};