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

Unified Diff: net/http/http_transaction_unittest.cc

Issue 10872044: Retry failed network requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix bug Created 8 years, 4 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 | « net/http/http_transaction_unittest.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_transaction_unittest.cc
===================================================================
--- net/http/http_transaction_unittest.cc (revision 152798)
+++ net/http/http_transaction_unittest.cc (working copy)
@@ -27,6 +27,7 @@
// mock transaction data
const MockTransaction kSimpleGET_Transaction = {
+ net::OK,
"http://www.google.com/",
"GET",
base::Time(),
@@ -42,6 +43,7 @@
};
const MockTransaction kSimplePOST_Transaction = {
+ net::OK,
"http://bugdatabase.com/edit",
"POST",
base::Time(),
@@ -57,6 +59,7 @@
};
const MockTransaction kTypicalGET_Transaction = {
+ net::OK,
"http://www.example.com/~foo/bar.html",
"GET",
base::Time(),
@@ -73,6 +76,7 @@
};
const MockTransaction kETagGET_Transaction = {
+ net::OK,
"http://www.google.com/foopy",
"GET",
base::Time(),
@@ -89,6 +93,7 @@
};
const MockTransaction kRangeGET_Transaction = {
+ net::OK,
"http://www.google.com/",
"GET",
base::Time(),
@@ -126,6 +131,9 @@
}
void AddMockTransaction(const MockTransaction* trans) {
+ // To return a result asynchronously, set the TEST_MODE_SYNC_NET_START bit
+ // of |test_mode|.
+ ASSERT_NE(net::ERR_IO_PENDING, trans->start_result);
mock_transactions[GURL(trans->url).spec()] = trans;
}
@@ -230,35 +238,38 @@
if (!t)
return net::ERR_FAILED;
- std::string resp_status = t->status;
- std::string resp_headers = t->response_headers;
- std::string resp_data = t->data;
- if (t->handler)
- (t->handler)(request, &resp_status, &resp_headers, &resp_data);
+ net::Error result = t->start_result;
+ test_mode_ = t->test_mode;
+ if (result == net::OK) {
+ std::string resp_status = t->status;
+ std::string resp_headers = t->response_headers;
+ std::string resp_data = t->data;
+ if (t->handler)
+ (t->handler)(request, &resp_status, &resp_headers, &resp_data);
- std::string header_data = base::StringPrintf(
- "%s\n%s\n", resp_status.c_str(), resp_headers.c_str());
- std::replace(header_data.begin(), header_data.end(), '\n', '\0');
+ std::string header_data = base::StringPrintf(
+ "%s\n%s\n", resp_status.c_str(), resp_headers.c_str());
+ std::replace(header_data.begin(), header_data.end(), '\n', '\0');
- response_.request_time = base::Time::Now();
- if (!t->request_time.is_null())
- response_.request_time = t->request_time;
+ response_.request_time = base::Time::Now();
+ if (!t->request_time.is_null())
+ response_.request_time = t->request_time;
- response_.was_cached = false;
+ response_.was_cached = false;
- response_.response_time = base::Time::Now();
- if (!t->response_time.is_null())
- response_.response_time = t->response_time;
+ response_.response_time = base::Time::Now();
+ if (!t->response_time.is_null())
+ response_.response_time = t->response_time;
- response_.headers = new net::HttpResponseHeaders(header_data);
- response_.ssl_info.cert_status = t->cert_status;
- data_ = resp_data;
- test_mode_ = t->test_mode;
+ response_.headers = new net::HttpResponseHeaders(header_data);
+ response_.ssl_info.cert_status = t->cert_status;
+ data_ = resp_data;
+ }
if (test_mode_ & TEST_MODE_SYNC_NET_START)
- return net::OK;
+ return result;
- CallbackLater(callback, net::OK);
+ CallbackLater(callback, result);
return net::ERR_IO_PENDING;
}
« no previous file with comments | « net/http/http_transaction_unittest.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698