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

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

Issue 2626663002: Update MimeSniffingResourceHandler tests to use MockResourceLoader. (Closed)
Patch Set: Merge 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 ad91efd99937aa3d07ec89c2facc951be7ab3c1d..c376724e89cd59877642670f97c798b8bb13e3ab 100644
--- a/content/browser/loader/mock_resource_loader.cc
+++ b/content/browser/loader/mock_resource_loader.cc
@@ -35,6 +35,11 @@ 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.
+ // TODO(mmenke): Once there are no more double cancel cases, remove this
+ // code.
+ if (status_ != Status::CANCELED)
+ error_code_ = net::ERR_ABORTED;
status_ = Status::CANCELED;
} else if (defer) {
status_ = Status::CALLBACK_PENDING;
@@ -61,6 +66,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;
@@ -85,6 +93,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;
@@ -108,6 +119,9 @@ MockResourceLoader::Status MockResourceLoader::OnWillRead(int min_size) {
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;
EXPECT_EQ(0, io_buffer_size_);
EXPECT_FALSE(io_buffer_);
status_ = Status::CANCELED;
@@ -138,6 +152,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;
« no previous file with comments | « content/browser/loader/mime_sniffing_resource_handler_unittest.cc ('k') | content/browser/loader/resource_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698