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

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

Issue 10501004: Refactor the guts of ResourceDispatcherHostImpl into a new class named (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 // Sort out all the messages we saw by request. 929 // Sort out all the messages we saw by request.
930 ResourceIPCAccumulator::ClassifiedMessages msgs; 930 ResourceIPCAccumulator::ClassifiedMessages msgs;
931 accum_.GetClassifiedMessages(&msgs); 931 accum_.GetClassifiedMessages(&msgs);
932 932
933 // The 2 requests for the RVH 0 should have been processed. 933 // The 2 requests for the RVH 0 should have been processed.
934 ASSERT_EQ(2U, msgs.size()); 934 ASSERT_EQ(2U, msgs.size());
935 935
936 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 936 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
937 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 937 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
938 938
939 EXPECT_TRUE(host_.blocked_requests_map_.empty()); 939 EXPECT_TRUE(host_.blocked_loaders_map_.empty());
940 } 940 }
941 941
942 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes 942 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes
943 // away. Note that we rely on Purify for finding the leaks if any. 943 // away. Note that we rely on Purify for finding the leaks if any.
944 // If this test turns the Purify bot red, check the ResourceDispatcherHost 944 // If this test turns the Purify bot red, check the ResourceDispatcherHost
945 // destructor to make sure the blocked requests are deleted. 945 // destructor to make sure the blocked requests are deleted.
946 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { 946 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
947 // This second filter is used to emulate a second process. 947 // This second filter is used to emulate a second process.
948 scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter( 948 scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
949 this, browser_context_->GetResourceContext()); 949 this, browser_context_->GetResourceContext());
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 response.size())); 1371 response.size()));
1372 std::string response_data("<html>foobar</html>"); 1372 std::string response_data("<html>foobar</html>");
1373 1373
1374 SetResponse(raw_headers, response_data); 1374 SetResponse(raw_headers, response_data);
1375 SetResourceType(ResourceType::MAIN_FRAME); 1375 SetResourceType(ResourceType::MAIN_FRAME);
1376 HandleScheme("http"); 1376 HandleScheme("http");
1377 1377
1378 MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah")); 1378 MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
1379 1379
1380 GlobalRequestID global_request_id(filter_->child_id(), request_id); 1380 GlobalRequestID global_request_id(filter_->child_id(), request_id);
1381 host_.MarkAsTransferredNavigation(host_.GetURLRequest(global_request_id)); 1381 host_.MarkAsTransferredNavigation(global_request_id);
1382 1382
1383 // And now simulate a cancellation coming from the renderer. 1383 // And now simulate a cancellation coming from the renderer.
1384 ResourceHostMsg_CancelRequest msg(filter_->child_id(), request_id); 1384 ResourceHostMsg_CancelRequest msg(filter_->child_id(), request_id);
1385 bool msg_was_ok; 1385 bool msg_was_ok;
1386 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); 1386 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok);
1387 1387
1388 // Since the request is marked as being transferred, 1388 // Since the request is marked as being transferred,
1389 // the cancellation above should have been ignored and the request 1389 // the cancellation above should have been ignored and the request
1390 // should still be alive. 1390 // should still be alive.
1391 EXPECT_EQ(1, host_.pending_requests()); 1391 EXPECT_EQ(1, host_.pending_requests());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 PickleIterator iter(msgs[0][0]); 1426 PickleIterator iter(msgs[0][0]);
1427 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 1427 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
1428 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 1428 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status));
1429 1429
1430 EXPECT_EQ(1, request_id); 1430 EXPECT_EQ(1, request_id);
1431 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); 1431 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status());
1432 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); 1432 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error());
1433 } 1433 }
1434 1434
1435 } // namespace content 1435 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698