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

Unified Diff: net/url_request/url_request_unittest.h

Issue 501082: Implement delaying resource requests until privacy blacklists are ready. (Closed)
Patch Set: don't get stuck on errors Created 10 years, 12 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 | « chrome/chrome_tests.gypi ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.h
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 88aa3aee78a07d64be82f95cb96ce4517f947a8d..abd94aa6c01481cbd120db47e1501b2f01a36c29 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -21,11 +21,15 @@
#include "base/thread.h"
#include "base/time.h"
#include "base/waitable_event.h"
+#include "net/base/cookie_monster.h"
#include "net/base/host_resolver.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/net_test_constants.h"
#include "net/base/ssl_config_service_defaults.h"
+#include "net/disk_cache/disk_cache.h"
+#include "net/ftp/ftp_network_layer.h"
+#include "net/http/http_cache.h"
#include "net/http/http_network_layer.h"
#include "net/socket/ssl_test_util.h"
#include "net/url_request/url_request.h"
@@ -41,16 +45,12 @@ const std::string kDefaultHostName("localhost");
using base::TimeDelta;
-// This URLRequestContext does not use a local cache.
class TestURLRequestContext : public URLRequestContext {
public:
TestURLRequestContext() {
host_resolver_ = net::CreateSystemHostResolver();
proxy_service_ = net::ProxyService::CreateNull();
- ssl_config_service_ = new net::SSLConfigServiceDefaults;
- http_transaction_factory_ =
- net::HttpNetworkLayer::CreateFactory(host_resolver_,
- proxy_service_, ssl_config_service_);
+ Init();
}
explicit TestURLRequestContext(const std::string& proxy) {
@@ -58,16 +58,40 @@ class TestURLRequestContext : public URLRequestContext {
net::ProxyConfig proxy_config;
proxy_config.proxy_rules.ParseFromString(proxy);
proxy_service_ = net::ProxyService::CreateFixed(proxy_config);
- ssl_config_service_ = new net::SSLConfigServiceDefaults;
- http_transaction_factory_ =
- net::HttpNetworkLayer::CreateFactory(host_resolver_,
- proxy_service_, ssl_config_service_);
+ Init();
}
protected:
- ~TestURLRequestContext() {
+ virtual ~TestURLRequestContext() {
+ delete ftp_transaction_factory_;
delete http_transaction_factory_;
}
+
+ private:
+ void Init() {
+ ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
+ ssl_config_service_ = new net::SSLConfigServiceDefaults;
+ http_transaction_factory_ =
+ new net::HttpCache(
+ net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_,
+ ssl_config_service_),
+ disk_cache::CreateInMemoryCacheBackend(0));
+ // In-memory cookie store.
+ cookie_store_ = new net::CookieMonster();
+ accept_language_ = "en-us,fr";
+ accept_charset_ = "iso-8859-1,*,utf-8";
+ }
+};
+
+// TODO(phajdan.jr): Migrate callers to the new name and remove the typedef.
+typedef TestURLRequestContext URLRequestTestContext;
+
+class TestURLRequest : public URLRequest {
+ public:
+ TestURLRequest(const GURL& url, Delegate* delegate)
+ : URLRequest(url, delegate) {
+ set_context(new TestURLRequestContext());
+ }
};
class TestDelegate : public URLRequest::Delegate {
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | net/url_request/url_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698