| Index: content/browser/loader/test_resource_handler.cc
|
| diff --git a/content/browser/loader/test_resource_handler.cc b/content/browser/loader/test_resource_handler.cc
|
| index 0ee72ae6744d140e22a9c3cf27a251259851c5b5..cdba366e1051fa8a9660e075b09025148788b045 100644
|
| --- a/content/browser/loader/test_resource_handler.cc
|
| +++ b/content/browser/loader/test_resource_handler.cc
|
| @@ -5,6 +5,7 @@
|
| #include "content/browser/loader/test_resource_handler.h"
|
|
|
| #include "base/logging.h"
|
| +#include "content/public/browser/resource_controller.h"
|
| #include "net/url_request/url_request_status.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -21,41 +22,47 @@ TestResourceHandler::TestResourceHandler()
|
|
|
| TestResourceHandler::~TestResourceHandler() {}
|
|
|
| -void TestResourceHandler::SetController(ResourceController* controller) {}
|
| +void TestResourceHandler::SetController(ResourceController* controller) {
|
| + controller_ = controller;
|
| +}
|
|
|
| -bool TestResourceHandler::OnRequestRedirected(
|
| +void TestResourceHandler::OnRequestRedirected(
|
| const net::RedirectInfo& redirect_info,
|
| ResourceResponse* response,
|
| - bool* defer) {
|
| + bool* defer_or_cancel) {
|
| NOTREACHED() << "Redirects are not supported by the TestResourceHandler.";
|
| - return false;
|
| }
|
|
|
| -bool TestResourceHandler::OnResponseStarted(ResourceResponse* response,
|
| - bool* defer) {
|
| +void TestResourceHandler::OnResponseStarted(ResourceResponse* response,
|
| + bool* defer_or_cancel) {
|
| EXPECT_EQ(1, on_will_start_called_);
|
| EXPECT_EQ(0, on_response_started_called_);
|
| EXPECT_EQ(0, on_response_completed_called_);
|
| ++on_response_started_called_;
|
|
|
| - if (!on_response_started_result_)
|
| - return false;
|
| - *defer = defer_on_response_started_;
|
| + if (!on_response_started_result_) {
|
| + controller_->Cancel();
|
| + *defer_or_cancel = true;
|
| + return;
|
| + }
|
| +
|
| + *defer_or_cancel = defer_on_response_started_;
|
| defer_on_response_started_ = false;
|
| - return true;
|
| }
|
|
|
| -bool TestResourceHandler::OnWillStart(const GURL& url, bool* defer) {
|
| +void TestResourceHandler::OnWillStart(const GURL& url, bool* defer_or_cancel) {
|
| EXPECT_EQ(0, on_response_started_called_);
|
| EXPECT_EQ(0, on_will_start_called_);
|
| EXPECT_EQ(0, on_response_completed_called_);
|
| ++on_will_start_called_;
|
|
|
| - if (!on_will_start_result_)
|
| - return false;
|
| + if (!on_will_start_result_) {
|
| + *defer_or_cancel = true;
|
| + controller_->Cancel();
|
| + return;
|
| + }
|
|
|
| - *defer = defer_on_will_start_;
|
| - return true;
|
| + *defer_or_cancel = defer_on_will_start_;
|
| }
|
|
|
| bool TestResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
|
| @@ -70,7 +77,8 @@ bool TestResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
|
| return on_will_read_result_;
|
| }
|
|
|
| -bool TestResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
|
| +void TestResourceHandler::OnReadCompleted(int bytes_read,
|
| + bool* defer_or_cancel) {
|
| EXPECT_EQ(1, on_will_start_called_);
|
| EXPECT_EQ(1, on_response_started_called_);
|
| EXPECT_EQ(0, on_response_completed_called_);
|
| @@ -79,11 +87,14 @@ bool TestResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
|
| EXPECT_LE(static_cast<size_t>(bytes_read), buffer_size_);
|
| if (body_)
|
| body_->append(buffer_->data(), bytes_read);
|
| - if (!on_read_completed_result_)
|
| - return false;
|
| - *defer = defer_on_read_completed_;
|
| + if (!on_read_completed_result_) {
|
| + *defer_or_cancel = true;
|
| + controller_->Cancel();
|
| + return;
|
| + }
|
| +
|
| + *defer_or_cancel = defer_on_read_completed_;
|
| defer_on_read_completed_ = false;
|
| - return true;
|
| }
|
|
|
| void TestResourceHandler::OnResponseCompleted(
|
|
|