summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 18:24:21 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 18:24:21 +0000
commitfba87b5c6d4181c147455078c44f80d39f262b2f (patch)
tree4be75b3046cb5ef6fa0a1f6479639996df0565f0 /net
parentc59d845257c5245a476ffd4284c506ef58fe008d (diff)
downloadchromium_src-fba87b5c6d4181c147455078c44f80d39f262b2f.zip
chromium_src-fba87b5c6d4181c147455078c44f80d39f262b2f.tar.gz
chromium_src-fba87b5c6d4181c147455078c44f80d39f262b2f.tar.bz2
Reland r74561 after fixing ChromeOS build breakage.
Introduce OffTheRecordProfileIOData and ProfileImplIOData. They both inherit from ProfileIOData. The former is for the off the record (incognito) profile. The latter is for the normal ProfileImpl profile. All of the IO related Profile objects are now initialized at the same time, in the subtype implementations of ProfileIOData::LazyInitializeInternal(). I also took this opportunity to clean URLRequestContext up so it is a class and keeps its member variables private. This required touching a fair number of files. TODO: Remove lots of the refcounting of member variables, since they can now be owned by ProfileIOData. BUG=67237 TEST=none Review URL: http://codereview.chromium.org/6500002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74632 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_policy.h5
-rw-r--r--net/proxy/proxy_script_fetcher_impl_unittest.cc28
-rw-r--r--net/spdy/spdy_test_util.cc36
-rw-r--r--net/url_request/url_request_context.cc10
-rw-r--r--net/url_request/url_request_context.h63
-rw-r--r--net/url_request/url_request_test_util.cc56
-rw-r--r--net/url_request/url_request_test_util.h4
-rw-r--r--net/url_request/view_cache_helper_unittest.cc2
-rw-r--r--net/websockets/websocket_job_unittest.cc4
9 files changed, 111 insertions, 97 deletions
diff --git a/net/base/cookie_policy.h b/net/base/cookie_policy.h
index c32c8a9..43b689f 100644
--- a/net/base/cookie_policy.h
+++ b/net/base/cookie_policy.h
@@ -21,6 +21,8 @@ enum {
class CookiePolicy {
public:
+ virtual ~CookiePolicy() {}
+
// Determines if the URL's cookies may be read.
//
// Returns:
@@ -57,9 +59,6 @@ class CookiePolicy {
const GURL& first_party_for_cookies,
const std::string& cookie_line,
CompletionCallback* callback) = 0;
-
- protected:
- virtual ~CookiePolicy() {}
};
} // namespace net
diff --git a/net/proxy/proxy_script_fetcher_impl_unittest.cc b/net/proxy/proxy_script_fetcher_impl_unittest.cc
index ce92986..e0f0c906 100644
--- a/net/proxy/proxy_script_fetcher_impl_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_impl_unittest.cc
@@ -41,30 +41,30 @@ class RequestContext : public URLRequestContext {
public:
RequestContext() {
ProxyConfig no_proxy;
- host_resolver_ =
+ set_host_resolver(
CreateSystemHostResolver(HostResolver::kDefaultParallelism,
- NULL, NULL);
- cert_verifier_ = new CertVerifier;
- proxy_service_ = ProxyService::CreateFixed(no_proxy);
- ssl_config_service_ = new SSLConfigServiceDefaults;
+ NULL, NULL));
+ set_cert_verifier(new CertVerifier);
+ set_proxy_service(ProxyService::CreateFixed(no_proxy));
+ set_ssl_config_service(new SSLConfigServiceDefaults);
HttpNetworkSession::Params params;
- params.host_resolver = host_resolver_;
- params.cert_verifier = cert_verifier_;
- params.proxy_service = proxy_service_;
- params.ssl_config_service = ssl_config_service_;
+ params.host_resolver = host_resolver();
+ params.cert_verifier = cert_verifier();
+ params.proxy_service = proxy_service();
+ params.ssl_config_service = ssl_config_service();
scoped_refptr<HttpNetworkSession> network_session(
new HttpNetworkSession(params));
- http_transaction_factory_ = new HttpCache(
+ set_http_transaction_factory(new HttpCache(
network_session,
- HttpCache::DefaultBackend::InMemory(0));
+ HttpCache::DefaultBackend::InMemory(0)));
}
private:
~RequestContext() {
- delete http_transaction_factory_;
- delete cert_verifier_;
- delete host_resolver_;
+ delete http_transaction_factory();
+ delete cert_verifier();
+ delete host_resolver();
}
};
diff --git a/net/spdy/spdy_test_util.cc b/net/spdy/spdy_test_util.cc
index 5340f22..6342b16 100644
--- a/net/spdy/spdy_test_util.cc
+++ b/net/spdy/spdy_test_util.cc
@@ -914,32 +914,32 @@ HttpNetworkSession* SpdySessionDependencies::SpdyCreateSessionDeterministic(
}
SpdyURLRequestContext::SpdyURLRequestContext() {
- host_resolver_ = new MockHostResolver();
- cert_verifier_ = new CertVerifier;
- proxy_service_ = ProxyService::CreateDirect();
- ssl_config_service_ = new SSLConfigServiceDefaults;
- http_auth_handler_factory_ = HttpAuthHandlerFactory::CreateDefault(
- host_resolver_);
+ set_host_resolver(new MockHostResolver());
+ set_cert_verifier(new CertVerifier);
+ set_proxy_service(ProxyService::CreateDirect());
+ set_ssl_config_service(new SSLConfigServiceDefaults);
+ set_http_auth_handler_factory(HttpAuthHandlerFactory::CreateDefault(
+ host_resolver()));
net::HttpNetworkSession::Params params;
params.client_socket_factory = &socket_factory_;
- params.host_resolver = host_resolver_;
- params.cert_verifier = cert_verifier_;
- params.proxy_service = proxy_service_;
- params.ssl_config_service = ssl_config_service_;
- params.http_auth_handler_factory = http_auth_handler_factory_;
- params.network_delegate = network_delegate_;
+ params.host_resolver = host_resolver();
+ params.cert_verifier = cert_verifier();
+ params.proxy_service = proxy_service();
+ params.ssl_config_service = ssl_config_service();
+ params.http_auth_handler_factory = http_auth_handler_factory();
+ params.network_delegate = network_delegate();
scoped_refptr<HttpNetworkSession> network_session(
new HttpNetworkSession(params));
- http_transaction_factory_ = new HttpCache(
+ set_http_transaction_factory(new HttpCache(
network_session,
- HttpCache::DefaultBackend::InMemory(0));
+ HttpCache::DefaultBackend::InMemory(0)));
}
SpdyURLRequestContext::~SpdyURLRequestContext() {
- delete http_transaction_factory_;
- delete http_auth_handler_factory_;
- delete cert_verifier_;
- delete host_resolver_;
+ delete http_transaction_factory();
+ delete http_auth_handler_factory();
+ delete cert_verifier();
+ delete host_resolver();
}
const SpdyHeaderInfo make_spdy_header(spdy::SpdyControlType type) {
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc
index 6eb075c..2f558cc 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -7,22 +7,24 @@
#include "base/string_util.h"
#include "net/base/cookie_store.h"
#include "net/base/host_resolver.h"
+#include "net/ftp/ftp_transaction_factory.h"
+#include "net/http/http_transaction_factory.h"
namespace net {
URLRequestContext::URLRequestContext()
- : net_log_(NULL),
+ : is_main_(false),
+ net_log_(NULL),
host_resolver_(NULL),
cert_verifier_(NULL),
dnsrr_resolver_(NULL),
dns_cert_checker_(NULL),
- http_transaction_factory_(NULL),
- ftp_transaction_factory_(NULL),
http_auth_handler_factory_(NULL),
network_delegate_(NULL),
cookie_policy_(NULL),
transport_security_state_(NULL),
- is_main_(false) {
+ http_transaction_factory_(NULL),
+ ftp_transaction_factory_(NULL) {
}
void URLRequestContext::set_cookie_store(CookieStore* cookie_store) {
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 18315dc..45240d7 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -75,21 +75,22 @@ class URLRequestContext
}
DnsCertProvenanceChecker* dns_cert_checker() const {
- return dns_cert_checker_.get();
+ return dns_cert_checker_;
}
-
- // Get the proxy service for this context.
- ProxyService* proxy_service() const {
- return proxy_service_;
+ void set_dns_cert_checker(net::DnsCertProvenanceChecker* dns_cert_checker) {
+ dns_cert_checker_ = dns_cert_checker;
}
+ // Get the proxy service for this context.
+ ProxyService* proxy_service() const { return proxy_service_; }
void set_proxy_service(ProxyService* proxy_service) {
proxy_service_ = proxy_service;
}
// Get the ssl config service for this context.
- SSLConfigService* ssl_config_service() const {
- return ssl_config_service_;
+ SSLConfigService* ssl_config_service() const { return ssl_config_service_; }
+ void set_ssl_config_service(net::SSLConfigService* service) {
+ ssl_config_service_ = service;
}
// Gets the HTTP Authentication Handler Factory for this context.
@@ -105,7 +106,6 @@ class URLRequestContext
HttpTransactionFactory* http_transaction_factory() const {
return http_transaction_factory_;
}
-
void set_http_transaction_factory(HttpTransactionFactory* factory) {
http_transaction_factory_ = factory;
}
@@ -114,33 +114,49 @@ class URLRequestContext
FtpTransactionFactory* ftp_transaction_factory() {
return ftp_transaction_factory_;
}
+ void set_ftp_transaction_factory(net::FtpTransactionFactory* factory) {
+ ftp_transaction_factory_ = factory;
+ }
void set_network_delegate(HttpNetworkDelegate* network_delegate) {
network_delegate_ = network_delegate;
}
- HttpNetworkDelegate* network_delegate() { return network_delegate_; }
+ HttpNetworkDelegate* network_delegate() const { return network_delegate_; }
// Gets the cookie store for this context (may be null, in which case
// cookies are not stored).
- CookieStore* cookie_store() { return cookie_store_.get(); }
-
+ CookieStore* cookie_store() const { return cookie_store_.get(); }
void set_cookie_store(CookieStore* cookie_store);
// Gets the cookie policy for this context (may be null, in which case
// cookies are allowed).
- CookiePolicy* cookie_policy() { return cookie_policy_; }
+ CookiePolicy* cookie_policy() const { return cookie_policy_; }
+ void set_cookie_policy(CookiePolicy* cookie_policy) {
+ cookie_policy_ = cookie_policy;
+ }
- TransportSecurityState* transport_security_state() {
- return transport_security_state_; }
+ TransportSecurityState* transport_security_state() const {
+ return transport_security_state_;
+ }
+ void set_transport_security_state(
+ net::TransportSecurityState* state) {
+ transport_security_state_ = state;
+ }
// Gets the FTP authentication cache for this context.
FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; }
// Gets the value of 'Accept-Charset' header field.
const std::string& accept_charset() const { return accept_charset_; }
+ void set_accept_charset(const std::string& accept_charset) {
+ accept_charset_ = accept_charset;
+ }
// Gets the value of 'Accept-Language' header field.
const std::string& accept_language() const { return accept_language_; }
+ void set_accept_language(const std::string& accept_language) {
+ accept_language_ = accept_language;
+ }
// Gets the UA string to use for the given URL. Pass an invalid URL (such as
// GURL()) to get the default UA string. Subclasses should override this
@@ -164,18 +180,20 @@ class URLRequestContext
virtual ~URLRequestContext();
- // The following members are expected to be initialized and owned by
- // subclasses.
+ private:
+ // Indicates whether or not this is the main URLRequestContext.
+ bool is_main_;
+
+ // Ownership for these members are not defined here. Clients should either
+ // provide storage elsewhere or have a subclass take ownership.
NetLog* net_log_;
HostResolver* host_resolver_;
CertVerifier* cert_verifier_;
DnsRRResolver* dnsrr_resolver_;
- scoped_ptr<DnsCertProvenanceChecker> dns_cert_checker_;
+ DnsCertProvenanceChecker* dns_cert_checker_;
+ HttpAuthHandlerFactory* http_auth_handler_factory_;
scoped_refptr<ProxyService> proxy_service_;
scoped_refptr<SSLConfigService> ssl_config_service_;
- HttpTransactionFactory* http_transaction_factory_;
- FtpTransactionFactory* ftp_transaction_factory_;
- HttpAuthHandlerFactory* http_auth_handler_factory_;
HttpNetworkDelegate* network_delegate_;
scoped_refptr<CookieStore> cookie_store_;
CookiePolicy* cookie_policy_;
@@ -188,9 +206,8 @@ class URLRequestContext
// filename for file download.
std::string referrer_charset_;
- private:
- // Indicates whether or not this is the main URLRequestContext.
- bool is_main_;
+ HttpTransactionFactory* http_transaction_factory_;
+ FtpTransactionFactory* ftp_transaction_factory_;
DISALLOW_COPY_AND_ASSIGN(URLRequestContext);
};
diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc
index 3e93648..b20cfc7 100644
--- a/net/url_request/url_request_test_util.cc
+++ b/net/url_request/url_request_test_util.cc
@@ -79,52 +79,52 @@ void TestCookiePolicy::DoSetCookiePolicy(const GURL& url,
TestURLRequestContext::TestURLRequestContext() {
- host_resolver_ =
+ set_host_resolver(
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
- NULL, NULL);
- proxy_service_ = net::ProxyService::CreateDirect();
+ NULL, NULL));
+ set_proxy_service(net::ProxyService::CreateDirect());
Init();
}
TestURLRequestContext::TestURLRequestContext(const std::string& proxy) {
- host_resolver_ =
+ set_host_resolver(
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
- NULL, NULL);
+ NULL, NULL));
net::ProxyConfig proxy_config;
proxy_config.proxy_rules().ParseFromString(proxy);
- proxy_service_ = net::ProxyService::CreateFixed(proxy_config);
+ set_proxy_service(net::ProxyService::CreateFixed(proxy_config));
Init();
}
TestURLRequestContext::~TestURLRequestContext() {
- delete ftp_transaction_factory_;
- delete http_transaction_factory_;
- delete http_auth_handler_factory_;
- delete cert_verifier_;
- delete host_resolver_;
+ delete ftp_transaction_factory();
+ delete http_transaction_factory();
+ delete http_auth_handler_factory();
+ delete cert_verifier();
+ delete host_resolver();
}
void TestURLRequestContext::Init() {
- cert_verifier_ = new net::CertVerifier;
- ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
- ssl_config_service_ = new net::SSLConfigServiceDefaults;
- http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault(
- host_resolver_);
+ set_cert_verifier(new net::CertVerifier);
+ 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()));
net::HttpNetworkSession::Params params;
- params.host_resolver = host_resolver_;
- params.cert_verifier = cert_verifier_;
- params.proxy_service = proxy_service_;
- params.ssl_config_service = ssl_config_service_;
- params.http_auth_handler_factory = http_auth_handler_factory_;
- params.network_delegate = network_delegate_;
-
- http_transaction_factory_ = new net::HttpCache(
+ params.host_resolver = host_resolver();
+ params.cert_verifier = cert_verifier();
+ params.proxy_service = proxy_service();
+ params.ssl_config_service = ssl_config_service();
+ params.http_auth_handler_factory = http_auth_handler_factory();
+ params.network_delegate = network_delegate();
+
+ set_http_transaction_factory(new net::HttpCache(
new net::HttpNetworkSession(params),
- net::HttpCache::DefaultBackend::InMemory(0));
+ net::HttpCache::DefaultBackend::InMemory(0)));
// In-memory cookie store.
- cookie_store_ = new net::CookieMonster(NULL, NULL);
- accept_language_ = "en-us,fr";
- accept_charset_ = "iso-8859-1,*,utf-8";
+ set_cookie_store(new net::CookieMonster(NULL, NULL));
+ set_accept_language("en-us,fr");
+ set_accept_charset("iso-8859-1,*,utf-8");
}
diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h
index ab71db1..3f8b4b4 100644
--- a/net/url_request/url_request_test_util.h
+++ b/net/url_request/url_request_test_util.h
@@ -76,10 +76,6 @@ class TestURLRequestContext : public net::URLRequestContext {
TestURLRequestContext();
explicit TestURLRequestContext(const std::string& proxy);
- void set_cookie_policy(net::CookiePolicy* policy) {
- cookie_policy_ = policy;
- }
-
protected:
virtual ~TestURLRequestContext();
diff --git a/net/url_request/view_cache_helper_unittest.cc b/net/url_request/view_cache_helper_unittest.cc
index 5a656f2..e9e497b 100644
--- a/net/url_request/view_cache_helper_unittest.cc
+++ b/net/url_request/view_cache_helper_unittest.cc
@@ -28,7 +28,7 @@ class TestURLRequestContext : public net::URLRequestContext {
TestURLRequestContext::TestURLRequestContext()
: cache_(reinterpret_cast<net::HttpTransactionFactory*>(NULL), NULL,
net::HttpCache::DefaultBackend::InMemory(0)) {
- http_transaction_factory_ = &cache_;
+ set_http_transaction_factory(&cache_);
}
void WriteHeaders(disk_cache::Entry* entry, int flags, const std::string data) {
diff --git a/net/websockets/websocket_job_unittest.cc b/net/websockets/websocket_job_unittest.cc
index 2133cfa..37013b9 100644
--- a/net/websockets/websocket_job_unittest.cc
+++ b/net/websockets/websocket_job_unittest.cc
@@ -181,8 +181,8 @@ class MockURLRequestContext : public URLRequestContext {
public:
MockURLRequestContext(CookieStore* cookie_store,
CookiePolicy* cookie_policy) {
- cookie_store_ = cookie_store;
- cookie_policy_ = cookie_policy;
+ set_cookie_store(cookie_store);
+ set_cookie_policy(cookie_policy);
}
private: