| Index: content/browser/renderer_host/resource_dispatcher_host_unittest.cc
|
| diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
|
| index 344bc6b2c4e59019ab06ff75cc699d12f9f02dad..eeda586337b6a6a63258faaf6b32a7205aeb8d71 100644
|
| --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
|
| +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc
|
| @@ -265,6 +265,27 @@ class URLRequestTestDelayedStartJob : public net::URLRequestTestJob {
|
| URLRequestTestDelayedStartJob*
|
| URLRequestTestDelayedStartJob::list_head_ = NULL;
|
|
|
| +// This class is a variation on URLRequestTestJob in that it only
|
| +// returns IO_pending errors before every read, not just the first one.
|
| +class URLRequestTestDelayedCompleteJob : public net::URLRequestTestJob {
|
| + public:
|
| + URLRequestTestDelayedCompleteJob(net::URLRequest* request)
|
| + : net::URLRequestTestJob(request) { }
|
| + URLRequestTestDelayedCompleteJob(net::URLRequest* request, bool auto_advance)
|
| + : net::URLRequestTestJob(request, auto_advance) { }
|
| + URLRequestTestDelayedCompleteJob(net::URLRequest* request,
|
| + const std::string& response_headers,
|
| + const std::string& response_data,
|
| + bool auto_advance)
|
| + : net::URLRequestTestJob(
|
| + request, response_headers, response_data, auto_advance) { }
|
| +
|
| + private:
|
| + bool FinalRoundIOPending() { return true; }
|
| +};
|
| +
|
| +
|
| +
|
| // Associated with an URLRequest to determine if the URLRequest gets deleted.
|
| class TestUserData : public base::SupportsUserData::Data {
|
| public:
|
| @@ -358,6 +379,7 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| &ResourceDispatcherHostTest::Factory);
|
| EnsureTestSchemeIsAllowed();
|
| delay_start_ = false;
|
| + delay_complete_ = false;
|
| }
|
|
|
| virtual void TearDown() {
|
| @@ -439,6 +461,8 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| if (test_fixture_->response_headers_.empty()) {
|
| if (delay_start_) {
|
| return new URLRequestTestDelayedStartJob(request);
|
| + } else if (delay_complete_) {
|
| + return new URLRequestTestDelayedCompleteJob(request);
|
| } else {
|
| return new net::URLRequestTestJob(request);
|
| }
|
| @@ -447,6 +471,10 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| return new URLRequestTestDelayedStartJob(
|
| request, test_fixture_->response_headers_,
|
| test_fixture_->response_data_, false);
|
| + } else if (delay_complete_) {
|
| + return new URLRequestTestDelayedCompleteJob(
|
| + request, test_fixture_->response_headers_,
|
| + test_fixture_->response_data_, false);
|
| } else {
|
| return new net::URLRequestTestJob(request,
|
| test_fixture_->response_headers_,
|
| @@ -460,6 +488,10 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| delay_start_ = delay_job_start;
|
| }
|
|
|
| + void SetDelayedCompleteJobGeneration(bool delay_job_complete) {
|
| + delay_complete_ = delay_job_complete;
|
| + }
|
| +
|
| MessageLoopForIO message_loop_;
|
| BrowserThreadImpl ui_thread_;
|
| BrowserThreadImpl file_thread_;
|
| @@ -476,10 +508,12 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| ResourceType::Type resource_type_;
|
| static ResourceDispatcherHostTest* test_fixture_;
|
| static bool delay_start_;
|
| + static bool delay_complete_;
|
| };
|
| // Static.
|
| ResourceDispatcherHostTest* ResourceDispatcherHostTest::test_fixture_ = NULL;
|
| bool ResourceDispatcherHostTest::delay_start_ = false;
|
| +bool ResourceDispatcherHostTest::delay_complete_ = false;
|
|
|
| void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id,
|
| int request_id,
|
| @@ -1267,9 +1301,12 @@ TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
|
| std::string raw_headers(net::HttpUtil::AssembleRawHeaders(response.data(),
|
| response.size()));
|
| std::string response_data("01234567890123456789\x01foobar");
|
| + // Get past sniffing metrics.
|
| + response_data.resize(1025, ' ');
|
|
|
| SetResponse(raw_headers, response_data);
|
| SetResourceType(ResourceType::MAIN_FRAME);
|
| + SetDelayedCompleteJobGeneration(true);
|
| HandleScheme("http");
|
|
|
| MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
| @@ -1302,9 +1339,12 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) {
|
| std::string raw_headers(net::HttpUtil::AssembleRawHeaders(response.data(),
|
| response.size()));
|
| std::string response_data("01234567890123456789\x01foobar");
|
| + // Get past sniffing metrics.
|
| + response_data.resize(1025, ' ');
|
|
|
| SetResponse(raw_headers, response_data);
|
| SetResourceType(ResourceType::MAIN_FRAME);
|
| + SetDelayedCompleteJobGeneration(true);
|
| HandleScheme("http");
|
|
|
| MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
|
|