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

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host_unittest.cc

Issue 10640019: Remove the HANDLED_EXTERNALLY status code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase + fix nits Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/resource_dispatcher_host_impl.h" 5 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 781
782 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 782 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
783 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3()); 783 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3());
784 784
785 // Check that request 2 got canceled. 785 // Check that request 2 got canceled.
786 ASSERT_EQ(2U, msgs[1].size()); 786 ASSERT_EQ(2U, msgs[1].size());
787 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type()); 787 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type());
788 ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[1][1].type()); 788 ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[1][1].type());
789 789
790 int request_id; 790 int request_id;
791 net::URLRequestStatus status; 791 int error_code;
792 792
793 PickleIterator iter(msgs[1][1]); 793 PickleIterator iter(msgs[1][1]);
794 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id)); 794 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id));
795 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status)); 795 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &error_code));
796 796
797 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); 797 EXPECT_EQ(net::ERR_ABORTED, error_code);
798 } 798 }
799 799
800 TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) { 800 TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) {
801 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); 801 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
802 802
803 bool was_deleted = false; 803 bool was_deleted = false;
804 804
805 // Arrange to have requests deferred before starting. 805 // Arrange to have requests deferred before starting.
806 TestResourceDispatcherHostDelegate delegate; 806 TestResourceDispatcherHostDelegate delegate;
807 delegate.set_defer_flags(DEFER_STARTING_REQUEST); 807 delegate.set_defer_flags(DEFER_STARTING_REQUEST);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2()); 1210 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2());
1211 1211
1212 // Check that the subsequent two requests (kMaxRequests + 1) and 1212 // Check that the subsequent two requests (kMaxRequests + 1) and
1213 // (kMaxRequests + 2) were failed, since the per-process bound was reached. 1213 // (kMaxRequests + 2) were failed, since the per-process bound was reached.
1214 for (int i = 0; i < 2; ++i) { 1214 for (int i = 0; i < 2; ++i) {
1215 // Should have sent a single RequestComplete message. 1215 // Should have sent a single RequestComplete message.
1216 int index = kMaxRequests + i; 1216 int index = kMaxRequests + i;
1217 EXPECT_EQ(1U, msgs[index].size()); 1217 EXPECT_EQ(1U, msgs[index].size());
1218 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[index][0].type()); 1218 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[index][0].type());
1219 1219
1220 // The RequestComplete message should have had status 1220 // The RequestComplete message should have the error code of
1221 // (CANCELLED, ERR_INSUFFICIENT_RESOURCES). 1221 // ERR_INSUFFICIENT_RESOURCES.
1222 int request_id; 1222 int request_id;
1223 net::URLRequestStatus status; 1223 int error_code;
1224 1224
1225 PickleIterator iter(msgs[index][0]); 1225 PickleIterator iter(msgs[index][0]);
1226 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id)); 1226 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id));
1227 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &status)); 1227 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &error_code));
1228 1228
1229 EXPECT_EQ(index + 1, request_id); 1229 EXPECT_EQ(index + 1, request_id);
1230 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); 1230 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, error_code);
1231 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.error());
1232 } 1231 }
1233 1232
1234 // The final 2 requests should have succeeded. 1233 // The final 2 requests should have succeeded.
1235 CheckSuccessfulRequest(msgs[kMaxRequests + 2], 1234 CheckSuccessfulRequest(msgs[kMaxRequests + 2],
1236 net::URLRequestTestJob::test_data_2()); 1235 net::URLRequestTestJob::test_data_2());
1237 CheckSuccessfulRequest(msgs[kMaxRequests + 3], 1236 CheckSuccessfulRequest(msgs[kMaxRequests + 3],
1238 net::URLRequestTestJob::test_data_2()); 1237 net::URLRequestTestJob::test_data_2());
1239 } 1238 }
1240 1239
1241 // Tests that we sniff the mime type for a simple request. 1240 // Tests that we sniff the mime type for a simple request.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); 1383 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
1385 1384
1386 // Sorts out all the messages we saw by request. 1385 // Sorts out all the messages we saw by request.
1387 ResourceIPCAccumulator::ClassifiedMessages msgs; 1386 ResourceIPCAccumulator::ClassifiedMessages msgs;
1388 accum_.GetClassifiedMessages(&msgs); 1387 accum_.GetClassifiedMessages(&msgs);
1389 1388
1390 // We should have gotten one RequestComplete message. 1389 // We should have gotten one RequestComplete message.
1391 ASSERT_EQ(1U, msgs[0].size()); 1390 ASSERT_EQ(1U, msgs[0].size());
1392 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); 1391 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type());
1393 1392
1394 // The RequestComplete message should have had status 1393 // The RequestComplete message should have had the error code of
1395 // (CANCELED, ERR_FILE_NOT_FOUND). 1394 // ERR_FILE_NOT_FOUND.
1396 int request_id; 1395 int request_id;
1397 net::URLRequestStatus status; 1396 int error_code;
1398 1397
1399 PickleIterator iter(msgs[0][0]); 1398 PickleIterator iter(msgs[0][0]);
1400 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 1399 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
1401 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 1400 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &error_code));
1402 1401
1403 EXPECT_EQ(1, request_id); 1402 EXPECT_EQ(1, request_id);
1404 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); 1403 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, error_code);
1405 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, status.error());
1406 } 1404 }
1407 1405
1408 // Test for http://crbug.com/76202 . We don't want to destroy a 1406 // Test for http://crbug.com/76202 . We don't want to destroy a
1409 // download request prematurely when processing a cancellation from 1407 // download request prematurely when processing a cancellation from
1410 // the renderer. 1408 // the renderer.
1411 TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) { 1409 TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
1412 EXPECT_EQ(0, host_.pending_requests()); 1410 EXPECT_EQ(0, host_.pending_requests());
1413 1411
1414 int render_view_id = 0; 1412 int render_view_id = 0;
1415 int request_id = 1; 1413 int request_id = 1;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1684 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1687 1685
1688 // Sort all the messages we saw by request. 1686 // Sort all the messages we saw by request.
1689 ResourceIPCAccumulator::ClassifiedMessages msgs; 1687 ResourceIPCAccumulator::ClassifiedMessages msgs;
1690 accum_.GetClassifiedMessages(&msgs); 1688 accum_.GetClassifiedMessages(&msgs);
1691 1689
1692 // We should have gotten one RequestComplete message. 1690 // We should have gotten one RequestComplete message.
1693 ASSERT_EQ(1U, msgs[0].size()); 1691 ASSERT_EQ(1U, msgs[0].size());
1694 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); 1692 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type());
1695 1693
1696 // The RequestComplete message should have had status 1694 // The RequestComplete message should have the error code of
1697 // (FAILED, ERR_UNKNOWN_URL_SCHEME). 1695 // ERR_UNKNOWN_URL_SCHEME.
1698 int request_id; 1696 int request_id;
1699 net::URLRequestStatus status; 1697 int error_code;
1700 1698
1701 PickleIterator iter(msgs[0][0]); 1699 PickleIterator iter(msgs[0][0]);
1702 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 1700 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
1703 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 1701 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &error_code));
1704 1702
1705 EXPECT_EQ(1, request_id); 1703 EXPECT_EQ(1, request_id);
1706 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); 1704 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, error_code);
1707 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error());
1708 } 1705 }
1709 1706
1710 TEST_F(ResourceDispatcherHostTest, DataReceivedACKs) { 1707 TEST_F(ResourceDispatcherHostTest, DataReceivedACKs) {
1711 EXPECT_EQ(0, host_.pending_requests()); 1708 EXPECT_EQ(0, host_.pending_requests());
1712 1709
1713 SendDataReceivedACKs(true); 1710 SendDataReceivedACKs(true);
1714 1711
1715 HandleScheme("big-job"); 1712 HandleScheme("big-job");
1716 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000")); 1713 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000"));
1717 1714
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 } 1762 }
1766 1763
1767 MessageLoop::current()->RunAllPending(); 1764 MessageLoop::current()->RunAllPending();
1768 1765
1769 msgs.clear(); 1766 msgs.clear();
1770 accum_.GetClassifiedMessages(&msgs); 1767 accum_.GetClassifiedMessages(&msgs);
1771 } 1768 }
1772 } 1769 }
1773 1770
1774 } // namespace content 1771 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host_impl.cc ('k') | content/browser/renderer_host/resource_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698