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

Unified Diff: net/url_request/test_url_fetcher_factory.cc

Issue 48713008: [sync] Allow FakeURLFetcher to return arbitrary HTTP response codes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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/url_request/test_url_fetcher_factory.h ('k') | remoting/host/token_validator_factory_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/test_url_fetcher_factory.cc
diff --git a/net/url_request/test_url_fetcher_factory.cc b/net/url_request/test_url_fetcher_factory.cc
index e4a47d7728080adf5fbcfb14ffb6bd4e0d76b21c..62fbb074691064bc01e45a6b3d6c29c370f0de47 100644
--- a/net/url_request/test_url_fetcher_factory.cc
+++ b/net/url_request/test_url_fetcher_factory.cc
@@ -283,13 +283,15 @@ void TestURLFetcherFactory::SetDelegateForTests(
FakeURLFetcher::FakeURLFetcher(const GURL& url,
URLFetcherDelegate* d,
const std::string& response_data,
- bool success)
+ HttpStatusCode response_code)
: TestURLFetcher(0, url, d),
weak_factory_(this) {
set_status(URLRequestStatus(
- success ? URLRequestStatus::SUCCESS : URLRequestStatus::FAILED,
+ // Status is FAILED for HTTP/5xx server errors, and SUCCESS otherwise.
+ response_code >= HTTP_INTERNAL_SERVER_ERROR ? URLRequestStatus::FAILED :
+ URLRequestStatus::SUCCESS,
0));
- set_response_code(success ? 200 : 500);
+ set_response_code(response_code);
SetResponseString(response_data);
}
@@ -327,10 +329,12 @@ FakeURLFetcherFactory::FakeURLFetcherFactory(
scoped_ptr<FakeURLFetcher> FakeURLFetcherFactory::DefaultFakeURLFetcherCreator(
const GURL& url,
URLFetcherDelegate* delegate,
- const std::string& response,
- bool success) {
- return scoped_ptr<FakeURLFetcher>(new FakeURLFetcher(url, delegate,
- response, success));
+ const std::string& response_data,
+ HttpStatusCode response_code) {
+ return scoped_ptr<FakeURLFetcher>(new FakeURLFetcher(url,
+ delegate,
+ response_data,
+ response_code));
}
FakeURLFetcherFactory::~FakeURLFetcherFactory() {}
@@ -360,9 +364,9 @@ URLFetcher* FakeURLFetcherFactory::CreateURLFetcher(
void FakeURLFetcherFactory::SetFakeResponse(
const GURL& url,
const std::string& response_data,
- bool success) {
+ HttpStatusCode response_code) {
// Overwrite existing URL if it already exists.
- fake_responses_[url] = std::make_pair(response_data, success);
+ fake_responses_[url] = std::make_pair(response_data, response_code);
}
void FakeURLFetcherFactory::ClearFakeResponses() {
« no previous file with comments | « net/url_request/test_url_fetcher_factory.h ('k') | remoting/host/token_validator_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698