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

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: Response to comments Created 3 years, 9 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing()); 529 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing());
530 handler_ = nullptr; 530 handler_ = nullptr;
531 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing()); 531 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing());
532 } 532 }
533 533
534 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadWithInsufficientResource) { 534 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadWithInsufficientResource) {
535 rdh_.set_max_num_in_flight_requests_per_process(0); 535 rdh_.set_max_num_in_flight_requests_per_process(0);
536 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted()); 536 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
537 537
538 ASSERT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->OnWillRead()); 538 ASSERT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->OnWillRead());
539 // TODO(mmenke): Make this fail with net::ERR_INSUFFICIENT_RESOURCES. 539 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, mock_loader_->error_code());
540 EXPECT_EQ(net::ERR_ABORTED, mock_loader_->error_code());
541 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing()); 540 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing());
542 handler_ = nullptr; 541 handler_ = nullptr;
543 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing()); 542 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing());
544 } 543 }
545 544
546 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadAndOnReadCompleted) { 545 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadAndOnReadCompleted) {
547 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted()); 546 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
548 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead()); 547 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
549 // The buffer size that the mime sniffer requires implicitly. 548 // The buffer size that the mime sniffer requires implicitly.
550 ASSERT_GE(mock_loader_->io_buffer_size(), 549 ASSERT_GE(mock_loader_->io_buffer_size(),
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } 1274 }
1276 } 1275 }
1277 EXPECT_EQ("B", body); 1276 EXPECT_EQ("B", body);
1278 } 1277 }
1279 1278
1280 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, 1279 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest,
1281 MojoAsyncResourceHandlerWithAllocationSizeTest, 1280 MojoAsyncResourceHandlerWithAllocationSizeTest,
1282 ::testing::Values(8, 32 * 2014)); 1281 ::testing::Values(8, 32 * 2014));
1283 } // namespace 1282 } // namespace
1284 } // namespace content 1283 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/mojo_async_resource_handler.cc ('k') | content/browser/loader/navigation_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698