summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
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, 97 insertions, 111 deletions
diff --git a/net/base/cookie_policy.h b/net/base/cookie_policy.h
index 43b689f..c32c8a9 100644
--- a/net/base/cookie_policy.h
+++ b/net/base/cookie_policy.h
@@ -21,8 +21,6 @@ enum {
class CookiePolicy {
public:
- virtual ~CookiePolicy() {}
-
// Determines if the URL's cookies may be read.
//
// Returns:
@@ -59,6 +57,9 @@ 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 e0f0c906..ce92986 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;
- set_host_resolver(
+ host_resolver_ =
CreateSystemHostResolver(HostResolver::kDefaultParallelism,
- NULL, NULL));
- set_cert_verifier(new CertVerifier);
- set_proxy_service(ProxyService::CreateFixed(no_proxy));
- set_ssl_config_service(new SSLConfigServiceDefaults);
+ NULL, NULL);
+ cert_verifier_ = new CertVerifier;
+ proxy_service_ = ProxyService::CreateFixed(no_proxy);
+ 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));
- set_http_transaction_factory(new HttpCache(
+ 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 6342b16..5340f22 100644
--- a/net/spdy/spdy_test_util.cc
+++ b/net/spdy/spdy_test_util.cc
@@ -914,32 +914,32 @@ HttpNetworkSession* SpdySessionDependencies::SpdyCreateSessionDeterministic(
}
SpdyURLRequestContext::SpdyURLRequestContext() {
- 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()));
+ 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_);
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));
- set_http_transaction_factory(new HttpCache(
+ 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 2f558cc..6eb075c 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -7,24 +7,22 @@
#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()
- : is_main_(false),
- net_log_(NULL),
+ : 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),
- http_transaction_factory_(NULL),
- ftp_transaction_factory_(NULL) {
+ is_main_(false) {
}
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 45240d7..18315dc 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -75,22 +75,21 @@ class URLRequestContext
}
DnsCertProvenanceChecker* dns_cert_checker() const {
- return dns_cert_checker_;
- }
- void set_dns_cert_checker(net::DnsCertProvenanceChecker* dns_cert_checker) {
- dns_cert_checker_ = dns_cert_checker;
+ return dns_cert_checker_.get();
}
// Get the proxy service for this context.
- ProxyService* proxy_service() const { return proxy_service_; }
+ 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_; }
- void set_ssl_config_service(net::SSLConfigService* service) {
- ssl_config_service_ = service;
+ SSLConfigService* ssl_config_service() const {
+ return ssl_config_service_;
}
// Gets the HTTP Authentication Handler Factory for this context.
@@ -106,6 +105,7 @@ class URLRequestContext
HttpTransactionFactory* http_transaction_factory() const {
return http_transaction_factory_;
}
+
void set_http_transaction_factory(HttpTransactionFactory* factory) {
http_transaction_factory_ = factory;
}
@@ -114,49 +114,33 @@ 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() const { return network_delegate_; }
+ HttpNetworkDelegate* network_delegate() { return network_delegate_; }
// Gets the cookie store for this context (may be null, in which case
// cookies are not stored).
- CookieStore* cookie_store() const { return cookie_store_.get(); }
+ CookieStore* cookie_store() { 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() const { return cookie_policy_; }
- void set_cookie_policy(CookiePolicy* cookie_policy) {
- cookie_policy_ = cookie_policy;
- }
+ CookiePolicy* cookie_policy() { return cookie_policy_; }
- TransportSecurityState* transport_security_state() const {
- return transport_security_state_;
- }
- void set_transport_security_state(
- net::TransportSecurityState* state) {
- transport_security_state_ = state;
- }
+ TransportSecurityState* transport_security_state() {
+ return transport_security_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
@@ -180,20 +164,18 @@ class URLRequestContext
virtual ~URLRequestContext();
- 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.
+ // The following members are expected to be initialized and owned by
+ // subclasses.
NetLog* net_log_;
HostResolver* host_resolver_;
CertVerifier* cert_verifier_;
DnsRRResolver* dnsrr_resolver_;
- DnsCertProvenanceChecker* dns_cert_checker_;
- HttpAuthHandlerFactory* http_auth_handler_factory_;
+ scoped_ptr<DnsCertProvenanceChecker> dns_cert_checker_;
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_;
@@ -206,8 +188,9 @@ class URLRequestContext
// filename for file download.
std::string referrer_charset_;
- HttpTransactionFactory* http_transaction_factory_;
- FtpTransactionFactory* ftp_transaction_factory_;
+ private:
+ // Indicates whether or not this is the main URLRequestContext.
+ bool is_main_;
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 b20cfc7..3e93648 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() {
- set_host_resolver(
+ host_resolver_ =
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
- NULL, NULL));
- set_proxy_service(net::ProxyService::CreateDirect());
+ NULL, NULL);
+ proxy_service_ = net::ProxyService::CreateDirect();
Init();
}
TestURLRequestContext::TestURLRequestContext(const std::string& proxy) {
- set_host_resolver(
+ host_resolver_ =
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
- NULL, NULL));
+ NULL, NULL);
net::ProxyConfig proxy_config;
proxy_config.proxy_rules().ParseFromString(proxy);
- set_proxy_service(net::ProxyService::CreateFixed(proxy_config));
+ 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() {
- 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()));
+ 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_);
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();
-
- set_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_;
+
+ http_transaction_factory_ = new net::HttpCache(
new net::HttpNetworkSession(params),
- net::HttpCache::DefaultBackend::InMemory(0)));
+ net::HttpCache::DefaultBackend::InMemory(0));
// In-memory cookie store.
- set_cookie_store(new net::CookieMonster(NULL, NULL));
- set_accept_language("en-us,fr");
- set_accept_charset("iso-8859-1,*,utf-8");
+ cookie_store_ = new net::CookieMonster(NULL, NULL);
+ accept_language_ = "en-us,fr";
+ 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 3f8b4b4..ab71db1 100644
--- a/net/url_request/url_request_test_util.h
+++ b/net/url_request/url_request_test_util.h
@@ -76,6 +76,10 @@ 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 e9e497b..5a656f2 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)) {
- set_http_transaction_factory(&cache_);
+ 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 37013b9..2133cfa 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) {
- set_cookie_store(cookie_store);
- set_cookie_policy(cookie_policy);
+ cookie_store_ = cookie_store;
+ cookie_policy_ = cookie_policy;
}
private: