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

Unified Diff: content/browser/loader/mock_resource_loader.cc

Issue 2626663002: Update MimeSniffingResourceHandler tests to use MockResourceLoader. (Closed)
Patch Set: Fix double-cancel tests Created 3 years, 11 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
Index: content/browser/loader/mock_resource_loader.cc
diff --git a/content/browser/loader/mock_resource_loader.cc b/content/browser/loader/mock_resource_loader.cc
index 8be87a46ad775887c3ec03b40809f182561ba49c..d211f38e4be646eaacd1c5ff04a382b24b50600c 100644
--- a/content/browser/loader/mock_resource_loader.cc
+++ b/content/browser/loader/mock_resource_loader.cc
@@ -35,6 +35,9 @@ MockResourceLoader::Status MockResourceLoader::OnWillStart(const GURL& url) {
EXPECT_TRUE(status_ == Status::CALLING_HANDLER ||
(result == false && status_ == Status::CANCELED));
if (!result) {
+ // In the case of double-cancels, keep the old error code.
+ if (status_ != Status::CANCELED)
+ error_code_ = net::ERR_ABORTED;
status_ = Status::CANCELED;
} else if (defer) {
status_ = Status::CALLBACK_PENDING;
@@ -58,6 +61,9 @@ MockResourceLoader::Status MockResourceLoader::OnRequestRedirected(
EXPECT_TRUE(status_ == Status::CALLING_HANDLER ||
(result == false && status_ == Status::CANCELED));
if (!result) {
+ // In the case of double-cancels, keep the old error code.
+ if (status_ != Status::CANCELED)
+ error_code_ = net::ERR_ABORTED;
status_ = Status::CANCELED;
} else if (defer) {
status_ = Status::CALLBACK_PENDING;
@@ -79,6 +85,9 @@ MockResourceLoader::Status MockResourceLoader::OnResponseStarted(
EXPECT_TRUE(status_ == Status::CALLING_HANDLER ||
(result == false && status_ == Status::CANCELED));
if (!result) {
+ // In the case of double-cancels, keep the old error code.
+ if (status_ != Status::CANCELED)
+ error_code_ = net::ERR_ABORTED;
status_ = Status::CANCELED;
} else if (defer) {
status_ = Status::CALLBACK_PENDING;
@@ -105,6 +114,7 @@ MockResourceLoader::Status MockResourceLoader::OnWillRead(int min_size) {
EXPECT_EQ(0, io_buffer_size_);
EXPECT_FALSE(io_buffer_);
status_ = Status::CANCELED;
+ error_code_ = net::ERR_ABORTED;
} else {
EXPECT_LE(min_size, io_buffer_size_);
EXPECT_LT(0, io_buffer_size_);
@@ -132,6 +142,9 @@ MockResourceLoader::Status MockResourceLoader::OnReadCompleted(
EXPECT_TRUE(status_ == Status::CALLING_HANDLER ||
(result == false && status_ == Status::CANCELED));
if (!result) {
+ // In the case of double-cancels, keep the old error code.
+ if (status_ != Status::CANCELED)
+ error_code_ = net::ERR_ABORTED;
status_ = Status::CANCELED;
} else if (defer) {
status_ = Status::CALLBACK_PENDING;

Powered by Google App Engine
This is Rietveld 408576698