From 52617df3c0d6b2f57763d52dd3c24dab32154d61 Mon Sep 17 00:00:00 2001
From: "willchan@chromium.org"
 <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Fri, 24 Dec 2010 07:30:01 +0000
Subject: [PATCH] Don't leak proxy script fetcher's http transaction factories.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6012008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70140 0039d316-1c4b-4281-b951-d872f2087c98
---
 chrome/browser/io_thread.cc                   | 28 ++++++++++---------
 chrome/browser/io_thread.h                    |  3 ++
 .../browser/net/connection_tester_unittest.cc |  4 ++-
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index e337ba597ac49..f20c8a6c507cd 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -189,19 +189,7 @@ ConstructProxyScriptFetcherContext(IOThread::Globals* globals,
       globals->http_auth_handler_factory.get());
   context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get());
   context->set_http_transaction_factory(
-      new net::HttpNetworkLayer(
-          globals->client_socket_factory,
-          globals->host_resolver.get(),
-          globals->cert_verifier.get(),
-          globals->dnsrr_resolver.get(),
-          NULL /* dns_cert_checker */,
-          NULL /* ssl_host_info_factory */,
-          globals->proxy_script_fetcher_proxy_service.get(),
-          globals->ssl_config_service.get(),
-          new net::SpdySessionPool(globals->ssl_config_service.get()),
-          globals->http_auth_handler_factory.get(),
-          &globals->network_delegate,
-          net_log));
+      globals->proxy_script_fetcher_http_transaction_factory.get());
   // In-memory cookie store.
   context->set_cookie_store(new net::CookieMonster(NULL, NULL));
   return context;
@@ -345,6 +333,20 @@ void IOThread::Init() {
   // For the ProxyScriptFetcher, we use a direct ProxyService.
   globals_->proxy_script_fetcher_proxy_service =
       net::ProxyService::CreateDirectWithNetLog(net_log_);
+  globals_->proxy_script_fetcher_http_transaction_factory.reset(
+      new net::HttpNetworkLayer(
+          globals_->client_socket_factory,
+          globals_->host_resolver.get(),
+          globals_->cert_verifier.get(),
+          globals_->dnsrr_resolver.get(),
+          NULL /* dns_cert_checker */,
+          NULL /* ssl_host_info_factory */,
+          globals_->proxy_script_fetcher_proxy_service.get(),
+          globals_->ssl_config_service.get(),
+          new net::SpdySessionPool(globals_->ssl_config_service.get()),
+          globals_->http_auth_handler_factory.get(),
+          &globals_->network_delegate,
+          net_log_));
 
   scoped_refptr<URLRequestContext> proxy_script_fetcher_context =
       ConstructProxyScriptFetcherContext(globals_, net_log_);
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h
index 8e52ca087f303..2f47a42a5e256 100644
--- a/chrome/browser/io_thread.h
+++ b/chrome/browser/io_thread.h
@@ -34,6 +34,7 @@ class ClientSocketFactory;
 class DnsRRResolver;
 class HostResolver;
 class HttpAuthHandlerFactory;
+class HttpTransactionFactory;
 class ProxyScriptFetcher;
 class ProxyService;
 class SSLConfigService;
@@ -53,6 +54,8 @@ class IOThread : public BrowserProcessSubThread {
     scoped_refptr<net::SSLConfigService> ssl_config_service;
     scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory;
     scoped_refptr<net::ProxyService> proxy_script_fetcher_proxy_service;
+    scoped_ptr<net::HttpTransactionFactory>
+        proxy_script_fetcher_http_transaction_factory;
     scoped_ptr<net::URLSecurityManager> url_security_manager;
     ChromeNetworkDelegate network_delegate;
     scoped_refptr<URLRequestContext> proxy_script_fetcher_context;
diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc
index 0ee05d2087542..6735599b08711 100644
--- a/chrome/browser/net/connection_tester_unittest.cc
+++ b/chrome/browser/net/connection_tester_unittest.cc
@@ -117,7 +117,7 @@ class ConnectionTesterTest : public PlatformTest {
     proxy_service_ = net::ProxyService::CreateDirect();
     proxy_script_fetcher_context_->set_proxy_service(proxy_service_);
     ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
-    proxy_script_fetcher_context_->set_http_transaction_factory(
+    http_transaction_factory_.reset(
         new net::HttpNetworkLayer(
             client_socket_factory_,
             &host_resolver_,
@@ -131,6 +131,8 @@ class ConnectionTesterTest : public PlatformTest {
             &http_auth_handler_factory_,
             NULL /* NetworkDelegate */,
             NULL /* NetLog */));
+    proxy_script_fetcher_context_->set_http_transaction_factory(
+        http_transaction_factory_.get());
     // In-memory cookie store.
     proxy_script_fetcher_context_->set_cookie_store(
         new net::CookieMonster(NULL, NULL));
-- 
GitLab