summaryrefslogtreecommitdiffstats
path: root/chrome/service/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 21:37:12 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-27 21:37:12 +0000
commit6104ea5d0b3eb19a923ae94a5f7fcae8e0e091e2 (patch)
tree93a11c09778f638718cd19be3249e54defd1f90f /chrome/service/net
parent418e953e7285de2f29f6523c741cbca951f26562 (diff)
downloadchromium_src-6104ea5d0b3eb19a923ae94a5f7fcae8e0e091e2.zip
chromium_src-6104ea5d0b3eb19a923ae94a5f7fcae8e0e091e2.tar.gz
chromium_src-6104ea5d0b3eb19a923ae94a5f7fcae8e0e091e2.tar.bz2
Stop refcounting ProxyService.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6873096 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service/net')
-rw-r--r--chrome/service/net/service_url_request_context.cc54
-rw-r--r--chrome/service/net/service_url_request_context.h7
2 files changed, 32 insertions, 29 deletions
diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc
index b3f47f6..9e876d9 100644
--- a/chrome/service/net/service_url_request_context.cc
+++ b/chrome/service/net/service_url_request_context.cc
@@ -8,6 +8,7 @@
#include <sys/utsname.h>
#endif
+#include "base/compiler_specific.h"
#include "base/message_loop_proxy.h"
#include "base/string_util.h"
#include "base/sys_info.h"
@@ -105,17 +106,20 @@ std::string MakeUserAgentForServiceProcess() {
ServiceURLRequestContext::ServiceURLRequestContext(
const std::string& user_agent,
- net::ProxyService* net_proxy_service) : user_agent_(user_agent) {
- set_host_resolver(
+ net::ProxyService* net_proxy_service)
+ : user_agent_(user_agent),
+ ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
+ storage_.set_host_resolver(
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
NULL));
- set_proxy_service(net_proxy_service);
- set_cert_verifier(new net::CertVerifier);
- set_dnsrr_resolver(new net::DnsRRResolver);
- set_ftp_transaction_factory(new net::FtpNetworkLayer(host_resolver()));
- set_ssl_config_service(new net::SSLConfigServiceDefaults);
- set_http_auth_handler_factory(net::HttpAuthHandlerFactory::CreateDefault(
- host_resolver()));
+ storage_.set_proxy_service(net_proxy_service);
+ storage_.set_cert_verifier(new net::CertVerifier);
+ storage_.set_dnsrr_resolver(new net::DnsRRResolver);
+ storage_.set_ftp_transaction_factory(
+ new net::FtpNetworkLayer(host_resolver()));
+ storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults);
+ storage_.set_http_auth_handler_factory(
+ net::HttpAuthHandlerFactory::CreateDefault(host_resolver()));
net::HttpNetworkSession::Params session_params;
session_params.host_resolver = host_resolver();
@@ -126,12 +130,12 @@ ServiceURLRequestContext::ServiceURLRequestContext(
session_params.http_auth_handler_factory = http_auth_handler_factory();
scoped_refptr<net::HttpNetworkSession> network_session(
new net::HttpNetworkSession(session_params));
- set_http_transaction_factory(
+ storage_.set_http_transaction_factory(
new net::HttpCache(
network_session,
net::HttpCache::DefaultBackend::InMemory(0)));
// In-memory cookie store.
- set_cookie_store(new net::CookieMonster(NULL, NULL));
+ storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
set_accept_language("en-us,fr");
set_accept_charset("iso-8859-1,*,utf-8");
}
@@ -145,12 +149,6 @@ const std::string& ServiceURLRequestContext::GetUserAgent(
}
ServiceURLRequestContext::~ServiceURLRequestContext() {
- delete ftp_transaction_factory();
- delete http_transaction_factory();
- delete http_auth_handler_factory();
- delete cert_verifier();
- delete dnsrr_resolver();
- delete host_resolver();
}
ServiceURLRequestContextGetter::ServiceURLRequestContextGetter()
@@ -162,19 +160,23 @@ ServiceURLRequestContextGetter::ServiceURLRequestContextGetter()
#if defined(OS_LINUX)
// Create the proxy service now, at initialization time, on the main thread,
// only for Linux, which requires that.
- CreateProxyService();
+ CreateProxyConfigService();
#endif
}
net::URLRequestContext*
ServiceURLRequestContextGetter::GetURLRequestContext() {
#if !defined(OS_LINUX)
- if (!proxy_service_)
- CreateProxyService();
+ if (!proxy_config_service_.get())
+ CreateProxyConfigService();
#endif
- if (!url_request_context_)
+ if (!url_request_context_) {
+ net::ProxyService* proxy_service =
+ net::ProxyService::CreateUsingSystemProxyResolver(
+ proxy_config_service_.release(), 0u, NULL);
url_request_context_ = new ServiceURLRequestContext(user_agent_,
- proxy_service_);
+ proxy_service);
+ }
return url_request_context_;
}
@@ -185,14 +187,12 @@ ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const {
ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {}
-void ServiceURLRequestContextGetter::CreateProxyService() {
+void ServiceURLRequestContextGetter::CreateProxyConfigService() {
// TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a
// MessageLoopProxy* instead of MessageLoop*.
DCHECK(g_service_process);
- net::ProxyConfigService * proxy_config_service =
+ proxy_config_service_.reset(
net::ProxyService::CreateSystemProxyConfigService(
g_service_process->io_thread()->message_loop(),
- g_service_process->file_thread()->message_loop());
- proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver(
- proxy_config_service, 0u, NULL);
+ g_service_process->file_thread()->message_loop()));
}
diff --git a/chrome/service/net/service_url_request_context.h b/chrome/service/net/service_url_request_context.h
index 6d3463d..3cf286e 100644
--- a/chrome/service/net/service_url_request_context.h
+++ b/chrome/service/net/service_url_request_context.h
@@ -20,6 +20,7 @@
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_context_storage.h"
namespace base {
class MessageLoopProxy;
@@ -31,6 +32,7 @@ class MessageLoopProxy;
//
class ServiceURLRequestContext : public net::URLRequestContext {
public:
+ // This context takes ownership of |net_proxy_service|.
explicit ServiceURLRequestContext(const std::string& user_agent,
net::ProxyService* net_proxy_service);
@@ -42,6 +44,7 @@ class ServiceURLRequestContext : public net::URLRequestContext {
private:
std::string user_agent_;
+ net::URLRequestContextStorage storage_;
};
class ServiceURLRequestContextGetter : public net::URLRequestContextGetter {
@@ -61,12 +64,12 @@ class ServiceURLRequestContextGetter : public net::URLRequestContextGetter {
ServiceURLRequestContextGetter();
virtual ~ServiceURLRequestContextGetter();
- void CreateProxyService();
+ void CreateProxyConfigService();
std::string user_agent_;
scoped_refptr<net::URLRequestContext> url_request_context_;
scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
- scoped_refptr<net::ProxyService> proxy_service_;
+ scoped_ptr<net::ProxyConfigService> proxy_config_service_;
};
#endif // CHROME_SERVICE_NET_SERVICE_URL_REQUEST_CONTEXT_H_