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

Side by Side Diff: content/browser/loader/mojo_async_resource_handler_unittest.cc

Issue 2668603003: Make ResourceHandler::OnWillRead able to complete asynchronously. (Closed)
Patch Set: One bot doesn't like 256 day timers. :( Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/loader/mojo_async_resource_handler.h" 5 #include "content/browser/loader/mojo_async_resource_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing()); 537 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing());
538 handler_ = nullptr; 538 handler_ = nullptr;
539 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing()); 539 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing());
540 } 540 }
541 541
542 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadWithInsufficientResource) { 542 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadWithInsufficientResource) {
543 rdh_.set_max_num_in_flight_requests_per_process(0); 543 rdh_.set_max_num_in_flight_requests_per_process(0);
544 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted()); 544 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
545 545
546 ASSERT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->OnWillRead()); 546 ASSERT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->OnWillRead());
547 // TODO(mmenke): Make this fail with net::ERR_INSUFFICIENT_RESOURCES. 547 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, mock_loader_->error_code());
548 EXPECT_EQ(net::ERR_ABORTED, mock_loader_->error_code());
549 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing()); 548 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing());
550 handler_ = nullptr; 549 handler_ = nullptr;
551 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing()); 550 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing());
552 } 551 }
553 552
554 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadAndOnReadCompleted) { 553 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadAndOnReadCompleted) {
555 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted()); 554 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
556 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead()); 555 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
557 // The buffer size that the mime sniffer requires implicitly. 556 // The buffer size that the mime sniffer requires implicitly.
558 ASSERT_GE(mock_loader_->io_buffer_size(), 557 ASSERT_GE(mock_loader_->io_buffer_size(),
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 } 1282 }
1284 } 1283 }
1285 EXPECT_EQ("B", body); 1284 EXPECT_EQ("B", body);
1286 } 1285 }
1287 1286
1288 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, 1287 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest,
1289 MojoAsyncResourceHandlerWithAllocationSizeTest, 1288 MojoAsyncResourceHandlerWithAllocationSizeTest,
1290 ::testing::Values(8, 32 * 2014)); 1289 ::testing::Values(8, 32 * 2014));
1291 } // namespace 1290 } // namespace
1292 } // namespace content 1291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698