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

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: fixed some minor issues Created 8 years, 5 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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 737
738 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 738 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
739 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3()); 739 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3());
740 740
741 // Check that request 2 got canceled. 741 // Check that request 2 got canceled.
742 ASSERT_EQ(2U, msgs[1].size()); 742 ASSERT_EQ(2U, msgs[1].size());
743 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type()); 743 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type());
744 ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[1][1].type()); 744 ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[1][1].type());
745 745
746 int request_id; 746 int request_id;
747 net::URLRequestStatus status; 747 int error_code;
748 748
749 PickleIterator iter(msgs[1][1]); 749 PickleIterator iter(msgs[1][1]);
750 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id)); 750 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id));
751 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status)); 751 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &error_code));
752 752
753 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); 753 EXPECT_EQ(net::ERR_ABORTED, error_code);
754 } 754 }
755 755
756 TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) { 756 TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) {
757 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); 757 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
758 758
759 bool was_deleted = false; 759 bool was_deleted = false;
760 760
761 // Arrange to have requests deferred before starting. 761 // Arrange to have requests deferred before starting.
762 TestResourceDispatcherHostDelegate delegate; 762 TestResourceDispatcherHostDelegate delegate;
763 delegate.set_defer_flags(DEFER_STARTING_REQUEST); 763 delegate.set_defer_flags(DEFER_STARTING_REQUEST);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2()); 1166 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2());
1167 1167
1168 // Check that the subsequent two requests (kMaxRequests + 1) and 1168 // Check that the subsequent two requests (kMaxRequests + 1) and
1169 // (kMaxRequests + 2) were failed, since the per-process bound was reached. 1169 // (kMaxRequests + 2) were failed, since the per-process bound was reached.
1170 for (int i = 0; i < 2; ++i) { 1170 for (int i = 0; i < 2; ++i) {
1171 // Should have sent a single RequestComplete message. 1171 // Should have sent a single RequestComplete message.
1172 int index = kMaxRequests + i; 1172 int index = kMaxRequests + i;
1173 EXPECT_EQ(1U, msgs[index].size()); 1173 EXPECT_EQ(1U, msgs[index].size());
1174 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[index][0].type()); 1174 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[index][0].type());
1175 1175
1176 // The RequestComplete message should have had status 1176 // The RequestComplete message should have the error code of
1177 // (CANCELLED, ERR_INSUFFICIENT_RESOURCES). 1177 // ERR_INSUFFICIENT_RESOURCES.
1178 int request_id; 1178 int request_id;
1179 net::URLRequestStatus status; 1179 int error_code;
1180 1180
1181 PickleIterator iter(msgs[index][0]); 1181 PickleIterator iter(msgs[index][0]);
1182 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id)); 1182 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id));
1183 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &status)); 1183 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &error_code));
1184 1184
1185 EXPECT_EQ(index + 1, request_id); 1185 EXPECT_EQ(index + 1, request_id);
1186 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); 1186 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, error_code);
1187 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.error());
1188 } 1187 }
1189 1188
1190 // The final 2 requests should have succeeded. 1189 // The final 2 requests should have succeeded.
1191 CheckSuccessfulRequest(msgs[kMaxRequests + 2], 1190 CheckSuccessfulRequest(msgs[kMaxRequests + 2],
1192 net::URLRequestTestJob::test_data_2()); 1191 net::URLRequestTestJob::test_data_2());
1193 CheckSuccessfulRequest(msgs[kMaxRequests + 3], 1192 CheckSuccessfulRequest(msgs[kMaxRequests + 3],
1194 net::URLRequestTestJob::test_data_2()); 1193 net::URLRequestTestJob::test_data_2());
1195 } 1194 }
1196 1195
1197 // Tests that we sniff the mime type for a simple request. 1196 // Tests that we sniff the mime type for a simple request.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); 1329 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0));
1331 1330
1332 // Sorts out all the messages we saw by request. 1331 // Sorts out all the messages we saw by request.
1333 ResourceIPCAccumulator::ClassifiedMessages msgs; 1332 ResourceIPCAccumulator::ClassifiedMessages msgs;
1334 accum_.GetClassifiedMessages(&msgs); 1333 accum_.GetClassifiedMessages(&msgs);
1335 1334
1336 // We should have gotten one RequestComplete message. 1335 // We should have gotten one RequestComplete message.
1337 ASSERT_EQ(1U, msgs[0].size()); 1336 ASSERT_EQ(1U, msgs[0].size());
1338 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); 1337 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type());
1339 1338
1340 // The RequestComplete message should have had status 1339 // The RequestComplete message should have had the error code of
1341 // (CANCELED, ERR_FILE_NOT_FOUND). 1340 // ERR_FILE_NOT_FOUND.
1342 int request_id; 1341 int request_id;
1343 net::URLRequestStatus status; 1342 int error_code;
1344 1343
1345 PickleIterator iter(msgs[0][0]); 1344 PickleIterator iter(msgs[0][0]);
1346 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 1345 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
1347 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 1346 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &error_code));
1348 1347
1349 EXPECT_EQ(1, request_id); 1348 EXPECT_EQ(1, request_id);
1350 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status()); 1349 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, error_code);
1351 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, status.error());
1352 } 1350 }
1353 1351
1354 // Test for http://crbug.com/76202 . We don't want to destroy a 1352 // Test for http://crbug.com/76202 . We don't want to destroy a
1355 // download request prematurely when processing a cancellation from 1353 // download request prematurely when processing a cancellation from
1356 // the renderer. 1354 // the renderer.
1357 TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) { 1355 TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
1358 EXPECT_EQ(0, host_.pending_requests()); 1356 EXPECT_EQ(0, host_.pending_requests());
1359 1357
1360 int render_view_id = 0; 1358 int render_view_id = 0;
1361 int request_id = 1; 1359 int request_id = 1;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1492 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1495 1493
1496 // Sort all the messages we saw by request. 1494 // Sort all the messages we saw by request.
1497 ResourceIPCAccumulator::ClassifiedMessages msgs; 1495 ResourceIPCAccumulator::ClassifiedMessages msgs;
1498 accum_.GetClassifiedMessages(&msgs); 1496 accum_.GetClassifiedMessages(&msgs);
1499 1497
1500 // We should have gotten one RequestComplete message. 1498 // We should have gotten one RequestComplete message.
1501 ASSERT_EQ(1U, msgs[0].size()); 1499 ASSERT_EQ(1U, msgs[0].size());
1502 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); 1500 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type());
1503 1501
1504 // The RequestComplete message should have had status 1502 // The RequestComplete message should have the error code of
1505 // (FAILED, ERR_UNKNOWN_URL_SCHEME). 1503 // ERR_UNKNOWN_URL_SCHEME.
1506 int request_id; 1504 int request_id;
1507 net::URLRequestStatus status; 1505 int error_code;
1508 1506
1509 PickleIterator iter(msgs[0][0]); 1507 PickleIterator iter(msgs[0][0]);
1510 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 1508 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
1511 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 1509 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &error_code));
1512 1510
1513 EXPECT_EQ(1, request_id); 1511 EXPECT_EQ(1, request_id);
1514 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); 1512 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, error_code);
1515 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error());
1516 } 1513 }
1517 1514
1518 TEST_F(ResourceDispatcherHostTest, DataReceivedACKs) { 1515 TEST_F(ResourceDispatcherHostTest, DataReceivedACKs) {
1519 EXPECT_EQ(0, host_.pending_requests()); 1516 EXPECT_EQ(0, host_.pending_requests());
1520 1517
1521 SendDataReceivedACKs(true); 1518 SendDataReceivedACKs(true);
1522 1519
1523 HandleScheme("big-job"); 1520 HandleScheme("big-job");
1524 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000")); 1521 MakeTestRequest(0, 1, GURL("big-job:0123456789,1000000"));
1525 1522
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 } 1570 }
1574 1571
1575 MessageLoop::current()->RunAllPending(); 1572 MessageLoop::current()->RunAllPending();
1576 1573
1577 msgs.clear(); 1574 msgs.clear();
1578 accum_.GetClassifiedMessages(&msgs); 1575 accum_.GetClassifiedMessages(&msgs);
1579 } 1576 }
1580 } 1577 }
1581 1578
1582 } // namespace content 1579 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698