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

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
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..d5acbb9df8a273bc7bd71241f707e75f247bdca5 100644
--- a/net/url_request/test_url_fetcher_factory.cc
+++ b/net/url_request/test_url_fetcher_factory.cc
@@ -283,13 +283,14 @@ 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,
+ response_code == HTTP_OK ? URLRequestStatus::SUCCESS :
+ URLRequestStatus::FAILED,
mmenke 2013/11/01 21:05:02 I don't believe this is correct. I think we actua
Raghu Simha 2013/11/01 21:55:16 Good point. The logic I was using worked because t
akalin 2013/11/01 22:36:59 This sounds reasonable, but you probably should do
mmenke 2013/11/01 23:10:56 I think the point about updating callsites is vali
0));
- set_response_code(success ? 200 : 500);
+ set_response_code(response_code);
SetResponseString(response_data);
}
@@ -327,10 +328,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 +363,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() {

Powered by Google App Engine
This is Rietveld 408576698