summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorjkarlin@google.com <jkarlin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 20:31:52 +0000
committerjkarlin@google.com <jkarlin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 20:31:52 +0000
commit54c1529f8d9906e174a4578a5dbdef30b23d21d8 (patch)
tree0490797063f9261c17bf5f4ad06f5c712c418d4f /net
parent352fa30b2d8de684b4c09f97018b0c6144efaa56 (diff)
downloadchromium_src-54c1529f8d9906e174a4578a5dbdef30b23d21d8.zip
chromium_src-54c1529f8d9906e174a4578a5dbdef30b23d21d8.tar.gz
chromium_src-54c1529f8d9906e174a4578a5dbdef30b23d21d8.tar.bz2
Allows prefetch and other detachable requests to live beyond the renderer by delaying LinkLoader::Cancel requests by a few seconds and through the use of a new DetachedResourceHandler.
The general concept of a detachable resource should be useful for <a ping> as well. BUG=286186 Review URL: https://codereview.chromium.org/25772002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231910 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/url_request/url_request_test_job.cc25
-rw-r--r--net/url_request/url_request_test_job.h10
2 files changed, 33 insertions, 2 deletions
diff --git a/net/url_request/url_request_test_job.cc b/net/url_request/url_request_test_job.cc
index e0a32b3..31a07fe 100644
--- a/net/url_request/url_request_test_job.cc
+++ b/net/url_request/url_request_test_job.cc
@@ -36,9 +36,15 @@ GURL URLRequestTestJob::test_url_2() {
GURL URLRequestTestJob::test_url_3() {
return GURL("test:url3");
}
+GURL URLRequestTestJob::test_url_4() {
+ return GURL("test:url4");
+}
GURL URLRequestTestJob::test_url_error() {
return GURL("test:error");
}
+GURL URLRequestTestJob::test_url_redirect_to_url_2() {
+ return GURL("test:redirect_to_2");
+}
// static getters for known URL responses
std::string URLRequestTestJob::test_data_1() {
@@ -50,6 +56,9 @@ std::string URLRequestTestJob::test_data_2() {
std::string URLRequestTestJob::test_data_3() {
return std::string("<html><title>Test Three Three Three</title></html>");
}
+std::string URLRequestTestJob::test_data_4() {
+ return std::string("<html><title>Test Four Four Four Four</title></html>");
+}
// static getter for simple response headers
std::string URLRequestTestJob::test_headers() {
@@ -69,6 +78,17 @@ std::string URLRequestTestJob::test_redirect_headers() {
return std::string(kHeaders, arraysize(kHeaders));
}
+// static getter for redirect response headers
+std::string URLRequestTestJob::test_redirect_to_url_2_headers() {
+ std::string headers = "HTTP/1.1 302 MOVED";
+ headers.push_back('\0');
+ headers += "Location: ";
+ headers += test_url_2().spec();
+ headers.push_back('\0');
+ headers.push_back('\0');
+ return headers;
+}
+
// static getter for error response headers
std::string URLRequestTestJob::test_error_headers() {
static const char kHeaders[] =
@@ -162,6 +182,11 @@ void URLRequestTestJob::StartAsync() {
response_data_ = test_data_2();
} else if (request_->url().spec() == test_url_3().spec()) {
response_data_ = test_data_3();
+ } else if (request_->url().spec() == test_url_4().spec()) {
+ response_data_ = test_data_4();
+ } else if (request_->url().spec() == test_url_redirect_to_url_2().spec()) {
+ response_headers_ =
+ new HttpResponseHeaders(test_redirect_to_url_2_headers());
} else {
AdvanceJob();
diff --git a/net/url_request/url_request_test_job.h b/net/url_request/url_request_test_job.h
index d7f33d7..717cc0f 100644
--- a/net/url_request/url_request_test_job.h
+++ b/net/url_request/url_request_test_job.h
@@ -18,7 +18,7 @@ namespace net {
// probably want to inherit from it to set up the state you want. Then install
// it as the protocol handler for the "test" scheme.
//
-// It will respond to three URLs, which you can retrieve using the test_url*
+// It will respond to several URLs, which you can retrieve using the test_url*
// getters, which will in turn respond with the corresponding responses returned
// by test_data*. Any other URLs that begin with "test:" will return an error,
// which might also be useful, you can use test_url_error() to retreive a
@@ -57,18 +57,21 @@ class NET_EXPORT_PRIVATE URLRequestTestJob : public URLRequestJob {
const std::string& response_data,
bool auto_advance);
- // The three canned URLs this handler will respond to without having been
+ // The canned URLs this handler will respond to without having been
// explicitly initialized with response headers and data.
// FIXME(brettw): we should probably also have a redirect one
static GURL test_url_1();
static GURL test_url_2();
static GURL test_url_3();
+ static GURL test_url_4();
static GURL test_url_error();
+ static GURL test_url_redirect_to_url_2();
// The data that corresponds to each of the URLs above
static std::string test_data_1();
static std::string test_data_2();
static std::string test_data_3();
+ static std::string test_data_4();
// The headers that correspond to each of the URLs above
static std::string test_headers();
@@ -76,6 +79,9 @@ class NET_EXPORT_PRIVATE URLRequestTestJob : public URLRequestJob {
// The headers for a redirect response
static std::string test_redirect_headers();
+ // The headers for a redirect response to the second test url.
+ static std::string test_redirect_to_url_2_headers();
+
// The headers for a server error response
static std::string test_error_headers();