summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 18:14:49 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-05 18:14:49 +0000
commit363119947a1e9111c19c326a2844bc60a29fabba (patch)
treea008f948a2591ffec99b7b25040d6c74815b6a01 /net/url_request
parent4f67d8a72d73ca17ae35434e3301e708fddd2970 (diff)
downloadchromium_src-363119947a1e9111c19c326a2844bc60a29fabba.zip
chromium_src-363119947a1e9111c19c326a2844bc60a29fabba.tar.gz
chromium_src-363119947a1e9111c19c326a2844bc60a29fabba.tar.bz2
Implement delaying resource requests until privacy blacklists are ready.
Associate a BlacklistRequestInfo with each URLRequest started by ResourceDispatcherHost so that in various places we get access to the right BlacklistManager (each Profile has its own), and lazily cache a Blacklist::Match. BlacklistListener controls delaying requests until the privacy blacklist is ready for the request. BlacklistInterceptor handles substituting real response with a blocking page or blocking image. I've temporarily removed support for unblocking things. It was too hacky. This change also removes a large block of blacklist-related code from RDH to more focused classes. Should make it a little more readable. This should also make BlacklistManagerBrowserTest not flaky. TEST=Covered by browser_tests and unit_tests. BUG=21541, 29113 Review URL: http://codereview.chromium.org/501082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35538 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_unittest.cc33
-rw-r--r--net/url_request/url_request_unittest.h44
2 files changed, 34 insertions, 43 deletions
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index ca4a6b2..5e9f253 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -49,39 +49,6 @@ using base::Time;
namespace {
-class URLRequestTestContext : public URLRequestContext {
- public:
- URLRequestTestContext() {
- host_resolver_ = net::CreateSystemHostResolver();
- proxy_service_ = net::ProxyService::CreateNull();
- 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";
- }
-
- private:
- virtual ~URLRequestTestContext() {
- delete ftp_transaction_factory_;
- delete http_transaction_factory_;
- }
-};
-
-class TestURLRequest : public URLRequest {
- public:
- TestURLRequest(const GURL& url, Delegate* delegate)
- : URLRequest(url, delegate) {
- set_context(new URLRequestTestContext());
- }
-};
-
base::StringPiece TestNetResourceProvider(int key) {
return "header";
}
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 88aa3ae..abd94aa 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 {