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

Unified Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 118100: Avoid doing concurrent DNS resolves of the same hostname (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Get compiling on mac Created 11 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/net/dns_global.cc » ('j') | net/base/address_list.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/chrome_url_request_context.cc
===================================================================
--- chrome/browser/net/chrome_url_request_context.cc (revision 18213)
+++ chrome/browser/net/chrome_url_request_context.cc (working copy)
@@ -10,6 +10,7 @@
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/user_script_master.h"
+#include "chrome/browser/net/dns_global.h"
#include "chrome/browser/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
@@ -109,11 +110,15 @@
DCHECK(!profile->IsOffTheRecord());
ChromeURLRequestContext* context = new ChromeURLRequestContext(profile);
+ // Global host resolver for the context.
+ context->host_resolver_ = chrome_browser_net::GetGlobalHostResolver();
+
context->proxy_service_ = CreateProxyService(
context, *CommandLine::ForCurrentProcess());
net::HttpCache* cache =
- new net::HttpCache(context->proxy_service_,
+ new net::HttpCache(context->host_resolver_,
+ context->proxy_service_,
disk_cache_path.ToWStringHack(), 0);
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
@@ -133,9 +138,11 @@
// implementations on Windows.
#if defined(OS_WIN)
if (command_line.HasSwitch(switches::kNewFtp))
- context->ftp_transaction_factory_ = new net::FtpNetworkLayer;
+ context->ftp_transaction_factory_ =
+ new net::FtpNetworkLayer(context->host_resolver_);
#else
- context->ftp_transaction_factory_ = new net::FtpNetworkLayer;
+ context->ftp_transaction_factory_ =
+ new net::FtpNetworkLayer(context->host_resolver_);
#endif
// setup cookie store
@@ -183,14 +190,16 @@
DCHECK(profile->IsOffTheRecord());
ChromeURLRequestContext* context = new ChromeURLRequestContext(profile);
- // Share the same proxy service as the original profile. This proxy
- // service's lifespan is dependent on the lifespan of the original profile,
- // which we reference (see above).
+ // Share the same proxy service and host resolver as the original profile.
+ // This proxy service's lifespan is dependent on the lifespan of the original
+ // profile which we reference (see above).
+ context->host_resolver_ =
+ profile->GetOriginalProfile()->GetRequestContext()->host_resolver();
context->proxy_service_ =
profile->GetOriginalProfile()->GetRequestContext()->proxy_service();
context->http_transaction_factory_ =
- new net::HttpCache(context->proxy_service_, 0);
+ new net::HttpCache(context->host_resolver_, context->proxy_service_, 0);
context->cookie_store_ = new net::CookieMonster;
return context;
@@ -241,7 +250,8 @@
} else {
// If original HttpCache doesn't exist, simply construct one with a whole
// new set of network stack.
- cache = new net::HttpCache(original_context->proxy_service(),
+ cache = new net::HttpCache(original_context->host_resolver(),
+ original_context->proxy_service(),
disk_cache_path.ToWStringHack(), 0);
}
@@ -417,4 +427,7 @@
// it is owned by the original URLRequestContext.
if (!is_off_the_record_ && !is_media_)
delete proxy_service_;
+
+ // Do not delete host_resolver_; it will be freed by FreeGlobalHostResolver()
+ // during the teardown of DNS prefetching.
}
« no previous file with comments | « no previous file | chrome/browser/net/dns_global.cc » ('j') | net/base/address_list.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698