OLD | NEW |
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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 request.frame_id = 0; | 106 request.frame_id = 0; |
107 request.parent_is_main_frame = false; | 107 request.parent_is_main_frame = false; |
108 request.parent_frame_id = -1; | 108 request.parent_frame_id = -1; |
109 request.transition_type = PAGE_TRANSITION_LINK; | 109 request.transition_type = PAGE_TRANSITION_LINK; |
110 request.allow_download = true; | 110 request.allow_download = true; |
111 return request; | 111 return request; |
112 } | 112 } |
113 | 113 |
114 // Spin up the message loop to kick off the request. | 114 // Spin up the message loop to kick off the request. |
115 static void KickOffRequest() { | 115 static void KickOffRequest() { |
116 MessageLoop::current()->RunUntilIdle(); | 116 base::MessageLoop::current()->RunUntilIdle(); |
117 } | 117 } |
118 | 118 |
119 // We may want to move this to a shared space if it is useful for something else | 119 // We may want to move this to a shared space if it is useful for something else |
120 class ResourceIPCAccumulator { | 120 class ResourceIPCAccumulator { |
121 public: | 121 public: |
122 void AddMessage(const IPC::Message& msg) { | 122 void AddMessage(const IPC::Message& msg) { |
123 messages_.push_back(msg); | 123 messages_.push_back(msg); |
124 } | 124 } |
125 | 125 |
126 // This groups the messages by their request ID. The groups will be in order | 126 // This groups the messages by their request ID. The groups will be in order |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 700 |
701 void GenerateDataReceivedACK(const IPC::Message& msg) { | 701 void GenerateDataReceivedACK(const IPC::Message& msg) { |
702 EXPECT_EQ(ResourceMsg_DataReceived::ID, msg.type()); | 702 EXPECT_EQ(ResourceMsg_DataReceived::ID, msg.type()); |
703 | 703 |
704 int request_id = -1; | 704 int request_id = -1; |
705 bool result = PickleIterator(msg).ReadInt(&request_id); | 705 bool result = PickleIterator(msg).ReadInt(&request_id); |
706 DCHECK(result); | 706 DCHECK(result); |
707 scoped_ptr<IPC::Message> ack( | 707 scoped_ptr<IPC::Message> ack( |
708 new ResourceHostMsg_DataReceived_ACK(msg.routing_id(), request_id)); | 708 new ResourceHostMsg_DataReceived_ACK(msg.routing_id(), request_id)); |
709 | 709 |
710 MessageLoop::current()->PostTask( | 710 base::MessageLoop::current()->PostTask( |
711 FROM_HERE, | 711 FROM_HERE, |
712 base::Bind(&GenerateIPCMessage, filter_, base::Passed(&ack))); | 712 base::Bind(&GenerateIPCMessage, filter_, base::Passed(&ack))); |
713 } | 713 } |
714 | 714 |
715 MessageLoopForIO message_loop_; | 715 base::MessageLoopForIO message_loop_; |
716 BrowserThreadImpl ui_thread_; | 716 BrowserThreadImpl ui_thread_; |
717 BrowserThreadImpl file_thread_; | 717 BrowserThreadImpl file_thread_; |
718 BrowserThreadImpl cache_thread_; | 718 BrowserThreadImpl cache_thread_; |
719 BrowserThreadImpl io_thread_; | 719 BrowserThreadImpl io_thread_; |
720 scoped_ptr<TestBrowserContext> browser_context_; | 720 scoped_ptr<TestBrowserContext> browser_context_; |
721 scoped_refptr<ForwardingFilter> filter_; | 721 scoped_refptr<ForwardingFilter> filter_; |
722 ResourceDispatcherHostImpl host_; | 722 ResourceDispatcherHostImpl host_; |
723 ResourceIPCAccumulator accum_; | 723 ResourceIPCAccumulator accum_; |
724 std::string response_headers_; | 724 std::string response_headers_; |
725 std::string response_data_; | 725 std::string response_data_; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 TEST_F(ResourceDispatcherHostTest, Cancel) { | 870 TEST_F(ResourceDispatcherHostTest, Cancel) { |
871 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 871 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
872 | 872 |
873 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); | 873 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); |
874 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); | 874 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); |
875 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); | 875 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); |
876 CancelRequest(2); | 876 CancelRequest(2); |
877 | 877 |
878 // flush all the pending requests | 878 // flush all the pending requests |
879 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 879 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
880 MessageLoop::current()->RunUntilIdle(); | 880 base::MessageLoop::current()->RunUntilIdle(); |
881 | 881 |
882 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 882 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
883 | 883 |
884 ResourceIPCAccumulator::ClassifiedMessages msgs; | 884 ResourceIPCAccumulator::ClassifiedMessages msgs; |
885 accum_.GetClassifiedMessages(&msgs); | 885 accum_.GetClassifiedMessages(&msgs); |
886 | 886 |
887 // there are three requests, so we should have gotten them classified as such | 887 // there are three requests, so we should have gotten them classified as such |
888 ASSERT_EQ(3U, msgs.size()); | 888 ASSERT_EQ(3U, msgs.size()); |
889 | 889 |
890 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); | 890 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); |
(...skipping 19 matching lines...) Expand all Loading... |
910 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); | 910 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); |
911 CancelRequest(1); | 911 CancelRequest(1); |
912 | 912 |
913 // Our TestResourceThrottle should not have been deleted yet. This is to | 913 // Our TestResourceThrottle should not have been deleted yet. This is to |
914 // ensure that destruction of the URLRequest happens asynchronously to | 914 // ensure that destruction of the URLRequest happens asynchronously to |
915 // calling CancelRequest. | 915 // calling CancelRequest. |
916 EXPECT_FALSE(was_deleted); | 916 EXPECT_FALSE(was_deleted); |
917 | 917 |
918 // flush all the pending requests | 918 // flush all the pending requests |
919 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 919 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
920 MessageLoop::current()->RunUntilIdle(); | 920 base::MessageLoop::current()->RunUntilIdle(); |
921 | 921 |
922 EXPECT_TRUE(was_deleted); | 922 EXPECT_TRUE(was_deleted); |
923 | 923 |
924 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 924 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
925 } | 925 } |
926 | 926 |
927 // Tests if cancel is called in ResourceThrottle::WillStartRequest, then the | 927 // Tests if cancel is called in ResourceThrottle::WillStartRequest, then the |
928 // URLRequest will not be started. | 928 // URLRequest will not be started. |
929 TEST_F(ResourceDispatcherHostTest, CancelInResourceThrottleWillStartRequest) { | 929 TEST_F(ResourceDispatcherHostTest, CancelInResourceThrottleWillStartRequest) { |
930 TestResourceDispatcherHostDelegate delegate; | 930 TestResourceDispatcherHostDelegate delegate; |
931 delegate.set_flags(CANCEL_BEFORE_START); | 931 delegate.set_flags(CANCEL_BEFORE_START); |
932 host_.SetDelegate(&delegate); | 932 host_.SetDelegate(&delegate); |
933 | 933 |
934 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); | 934 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); |
935 | 935 |
936 // flush all the pending requests | 936 // flush all the pending requests |
937 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 937 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
938 MessageLoop::current()->RunUntilIdle(); | 938 base::MessageLoop::current()->RunUntilIdle(); |
939 | 939 |
940 ResourceIPCAccumulator::ClassifiedMessages msgs; | 940 ResourceIPCAccumulator::ClassifiedMessages msgs; |
941 accum_.GetClassifiedMessages(&msgs); | 941 accum_.GetClassifiedMessages(&msgs); |
942 | 942 |
943 // Check that request got canceled. | 943 // Check that request got canceled. |
944 ASSERT_EQ(1U, msgs[0].size()); | 944 ASSERT_EQ(1U, msgs[0].size()); |
945 CheckCancelledRequestCompleteMessage(msgs[0][0]); | 945 CheckCancelledRequestCompleteMessage(msgs[0][0]); |
946 | 946 |
947 // Make sure URLRequest is never started. | 947 // Make sure URLRequest is never started. |
948 EXPECT_EQ(0, url_request_jobs_created_count_); | 948 EXPECT_EQ(0, url_request_jobs_created_count_); |
949 } | 949 } |
950 | 950 |
951 TEST_F(ResourceDispatcherHostTest, PausedStartError) { | 951 TEST_F(ResourceDispatcherHostTest, PausedStartError) { |
952 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 952 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
953 | 953 |
954 // Arrange to have requests deferred before processing response headers. | 954 // Arrange to have requests deferred before processing response headers. |
955 TestResourceDispatcherHostDelegate delegate; | 955 TestResourceDispatcherHostDelegate delegate; |
956 delegate.set_flags(DEFER_PROCESSING_RESPONSE); | 956 delegate.set_flags(DEFER_PROCESSING_RESPONSE); |
957 host_.SetDelegate(&delegate); | 957 host_.SetDelegate(&delegate); |
958 | 958 |
959 SetDelayedStartJobGeneration(true); | 959 SetDelayedStartJobGeneration(true); |
960 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_error()); | 960 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_error()); |
961 CompleteStartRequest(1); | 961 CompleteStartRequest(1); |
962 | 962 |
963 // flush all the pending requests | 963 // flush all the pending requests |
964 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 964 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
965 MessageLoop::current()->RunUntilIdle(); | 965 base::MessageLoop::current()->RunUntilIdle(); |
966 | 966 |
967 EXPECT_EQ(0, host_.pending_requests()); | 967 EXPECT_EQ(0, host_.pending_requests()); |
968 } | 968 } |
969 | 969 |
970 TEST_F(ResourceDispatcherHostTest, ThrottleAndResumeTwice) { | 970 TEST_F(ResourceDispatcherHostTest, ThrottleAndResumeTwice) { |
971 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 971 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
972 | 972 |
973 // Arrange to have requests deferred before starting. | 973 // Arrange to have requests deferred before starting. |
974 TestResourceDispatcherHostDelegate delegate; | 974 TestResourceDispatcherHostDelegate delegate; |
975 delegate.set_flags(DEFER_STARTING_REQUEST); | 975 delegate.set_flags(DEFER_STARTING_REQUEST); |
976 delegate.set_create_two_throttles(true); | 976 delegate.set_create_two_throttles(true); |
977 host_.SetDelegate(&delegate); | 977 host_.SetDelegate(&delegate); |
978 | 978 |
979 // Make sure the first throttle blocked the request, and then resume. | 979 // Make sure the first throttle blocked the request, and then resume. |
980 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); | 980 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); |
981 GenericResourceThrottle* first_throttle = | 981 GenericResourceThrottle* first_throttle = |
982 GenericResourceThrottle::active_throttle(); | 982 GenericResourceThrottle::active_throttle(); |
983 ASSERT_TRUE(first_throttle); | 983 ASSERT_TRUE(first_throttle); |
984 first_throttle->Resume(); | 984 first_throttle->Resume(); |
985 | 985 |
986 // Make sure the second throttle blocked the request, and then resume. | 986 // Make sure the second throttle blocked the request, and then resume. |
987 ASSERT_TRUE(GenericResourceThrottle::active_throttle()); | 987 ASSERT_TRUE(GenericResourceThrottle::active_throttle()); |
988 ASSERT_NE(first_throttle, GenericResourceThrottle::active_throttle()); | 988 ASSERT_NE(first_throttle, GenericResourceThrottle::active_throttle()); |
989 GenericResourceThrottle::active_throttle()->Resume(); | 989 GenericResourceThrottle::active_throttle()->Resume(); |
990 | 990 |
991 ASSERT_FALSE(GenericResourceThrottle::active_throttle()); | 991 ASSERT_FALSE(GenericResourceThrottle::active_throttle()); |
992 | 992 |
993 // The request is started asynchronously. | 993 // The request is started asynchronously. |
994 MessageLoop::current()->RunUntilIdle(); | 994 base::MessageLoop::current()->RunUntilIdle(); |
995 | 995 |
996 // Flush all the pending requests. | 996 // Flush all the pending requests. |
997 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 997 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
998 | 998 |
999 EXPECT_EQ(0, host_.pending_requests()); | 999 EXPECT_EQ(0, host_.pending_requests()); |
1000 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); | 1000 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
1001 | 1001 |
1002 // Make sure the request completed successfully. | 1002 // Make sure the request completed successfully. |
1003 ResourceIPCAccumulator::ClassifiedMessages msgs; | 1003 ResourceIPCAccumulator::ClassifiedMessages msgs; |
1004 accum_.GetClassifiedMessages(&msgs); | 1004 accum_.GetClassifiedMessages(&msgs); |
1005 ASSERT_EQ(1U, msgs.size()); | 1005 ASSERT_EQ(1U, msgs.size()); |
1006 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); | 1006 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); |
1007 } | 1007 } |
1008 | 1008 |
1009 | 1009 |
1010 // Tests that the delegate can cancel a request and provide a error code. | 1010 // Tests that the delegate can cancel a request and provide a error code. |
1011 TEST_F(ResourceDispatcherHostTest, CancelInDelegate) { | 1011 TEST_F(ResourceDispatcherHostTest, CancelInDelegate) { |
1012 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 1012 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
1013 | 1013 |
1014 TestResourceDispatcherHostDelegate delegate; | 1014 TestResourceDispatcherHostDelegate delegate; |
1015 delegate.set_flags(CANCEL_BEFORE_START); | 1015 delegate.set_flags(CANCEL_BEFORE_START); |
1016 delegate.set_error_code_for_cancellation(net::ERR_ACCESS_DENIED); | 1016 delegate.set_error_code_for_cancellation(net::ERR_ACCESS_DENIED); |
1017 host_.SetDelegate(&delegate); | 1017 host_.SetDelegate(&delegate); |
1018 | 1018 |
1019 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); | 1019 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); |
1020 // The request will get cancelled by the throttle. | 1020 // The request will get cancelled by the throttle. |
1021 | 1021 |
1022 // flush all the pending requests | 1022 // flush all the pending requests |
1023 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 1023 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
1024 MessageLoop::current()->RunUntilIdle(); | 1024 base::MessageLoop::current()->RunUntilIdle(); |
1025 | 1025 |
1026 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 1026 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
1027 | 1027 |
1028 ResourceIPCAccumulator::ClassifiedMessages msgs; | 1028 ResourceIPCAccumulator::ClassifiedMessages msgs; |
1029 accum_.GetClassifiedMessages(&msgs); | 1029 accum_.GetClassifiedMessages(&msgs); |
1030 | 1030 |
1031 // Check the cancellation | 1031 // Check the cancellation |
1032 ASSERT_EQ(1U, msgs.size()); | 1032 ASSERT_EQ(1U, msgs.size()); |
1033 ASSERT_EQ(1U, msgs[0].size()); | 1033 ASSERT_EQ(1U, msgs[0].size()); |
1034 ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); | 1034 ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 | 1085 |
1086 // request 2 goes to us | 1086 // request 2 goes to us |
1087 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); | 1087 MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2()); |
1088 | 1088 |
1089 // request 3 goes to the test delegate | 1089 // request 3 goes to the test delegate |
1090 MakeTestRequest(test_filter.get(), 0, 3, | 1090 MakeTestRequest(test_filter.get(), 0, 3, |
1091 net::URLRequestTestJob::test_url_3()); | 1091 net::URLRequestTestJob::test_url_3()); |
1092 | 1092 |
1093 // Make sure all requests have finished stage one. test_url_1 will have | 1093 // Make sure all requests have finished stage one. test_url_1 will have |
1094 // finished. | 1094 // finished. |
1095 MessageLoop::current()->RunUntilIdle(); | 1095 base::MessageLoop::current()->RunUntilIdle(); |
1096 | 1096 |
1097 // TODO(mbelshe): | 1097 // TODO(mbelshe): |
1098 // Now that the async IO path is in place, the IO always completes on the | 1098 // Now that the async IO path is in place, the IO always completes on the |
1099 // initial call; so the requests have already completed. This basically | 1099 // initial call; so the requests have already completed. This basically |
1100 // breaks the whole test. | 1100 // breaks the whole test. |
1101 //EXPECT_EQ(3, host_.pending_requests()); | 1101 //EXPECT_EQ(3, host_.pending_requests()); |
1102 | 1102 |
1103 // Process each request for one level so one callback is called. | 1103 // Process each request for one level so one callback is called. |
1104 for (int i = 0; i < 2; i++) | 1104 for (int i = 0; i < 2; i++) |
1105 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); | 1105 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 | 1389 |
1390 // Issue two requests for the second process -- these should succeed since | 1390 // Issue two requests for the second process -- these should succeed since |
1391 // it is just process 0 that is saturated. | 1391 // it is just process 0 that is saturated. |
1392 MakeTestRequest(second_filter.get(), 0, kMaxRequests + 3, | 1392 MakeTestRequest(second_filter.get(), 0, kMaxRequests + 3, |
1393 net::URLRequestTestJob::test_url_2()); | 1393 net::URLRequestTestJob::test_url_2()); |
1394 MakeTestRequest(second_filter.get(), 0, kMaxRequests + 4, | 1394 MakeTestRequest(second_filter.get(), 0, kMaxRequests + 4, |
1395 net::URLRequestTestJob::test_url_2()); | 1395 net::URLRequestTestJob::test_url_2()); |
1396 | 1396 |
1397 // Flush all the pending requests. | 1397 // Flush all the pending requests. |
1398 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 1398 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
1399 MessageLoop::current()->RunUntilIdle(); | 1399 base::MessageLoop::current()->RunUntilIdle(); |
1400 | 1400 |
1401 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); | 1401 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(filter_->child_id())); |
1402 | 1402 |
1403 // Sorts out all the messages we saw by request. | 1403 // Sorts out all the messages we saw by request. |
1404 ResourceIPCAccumulator::ClassifiedMessages msgs; | 1404 ResourceIPCAccumulator::ClassifiedMessages msgs; |
1405 accum_.GetClassifiedMessages(&msgs); | 1405 accum_.GetClassifiedMessages(&msgs); |
1406 | 1406 |
1407 // We issued (kMaxRequests + 4) total requests. | 1407 // We issued (kMaxRequests + 4) total requests. |
1408 ASSERT_EQ(kMaxRequests + 4, msgs.size()); | 1408 ASSERT_EQ(kMaxRequests + 4, msgs.size()); |
1409 | 1409 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 GURL("http://other.com/blech")); | 1770 GURL("http://other.com/blech")); |
1771 request.transferred_request_child_id = filter_->child_id(); | 1771 request.transferred_request_child_id = filter_->child_id(); |
1772 request.transferred_request_request_id = request_id; | 1772 request.transferred_request_request_id = request_id; |
1773 | 1773 |
1774 // For cleanup. | 1774 // For cleanup. |
1775 child_ids_.insert(second_filter->child_id()); | 1775 child_ids_.insert(second_filter->child_id()); |
1776 ResourceHostMsg_RequestResource transfer_request_msg( | 1776 ResourceHostMsg_RequestResource transfer_request_msg( |
1777 new_render_view_id, new_request_id, request); | 1777 new_render_view_id, new_request_id, request); |
1778 bool msg_was_ok; | 1778 bool msg_was_ok; |
1779 host_.OnMessageReceived(transfer_request_msg, second_filter, &msg_was_ok); | 1779 host_.OnMessageReceived(transfer_request_msg, second_filter, &msg_was_ok); |
1780 MessageLoop::current()->RunUntilIdle(); | 1780 base::MessageLoop::current()->RunUntilIdle(); |
1781 | 1781 |
1782 // Flush all the pending requests. | 1782 // Flush all the pending requests. |
1783 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 1783 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
1784 | 1784 |
1785 // Check generated messages. | 1785 // Check generated messages. |
1786 ResourceIPCAccumulator::ClassifiedMessages msgs; | 1786 ResourceIPCAccumulator::ClassifiedMessages msgs; |
1787 accum_.GetClassifiedMessages(&msgs); | 1787 accum_.GetClassifiedMessages(&msgs); |
1788 | 1788 |
1789 ASSERT_EQ(1U, msgs.size()); | 1789 ASSERT_EQ(1U, msgs.size()); |
1790 CheckSuccessfulRequest(msgs[0], kResponseBody); | 1790 CheckSuccessfulRequest(msgs[0], kResponseBody); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1832 GURL("http://other.com/blech")); | 1832 GURL("http://other.com/blech")); |
1833 request.transferred_request_child_id = filter_->child_id(); | 1833 request.transferred_request_child_id = filter_->child_id(); |
1834 request.transferred_request_request_id = request_id; | 1834 request.transferred_request_request_id = request_id; |
1835 | 1835 |
1836 // For cleanup. | 1836 // For cleanup. |
1837 child_ids_.insert(second_filter->child_id()); | 1837 child_ids_.insert(second_filter->child_id()); |
1838 ResourceHostMsg_RequestResource transfer_request_msg( | 1838 ResourceHostMsg_RequestResource transfer_request_msg( |
1839 new_render_view_id, new_request_id, request); | 1839 new_render_view_id, new_request_id, request); |
1840 bool msg_was_ok; | 1840 bool msg_was_ok; |
1841 host_.OnMessageReceived(transfer_request_msg, second_filter, &msg_was_ok); | 1841 host_.OnMessageReceived(transfer_request_msg, second_filter, &msg_was_ok); |
1842 MessageLoop::current()->RunUntilIdle(); | 1842 base::MessageLoop::current()->RunUntilIdle(); |
1843 | 1843 |
1844 // Response data for "http://other.com/blerg": | 1844 // Response data for "http://other.com/blerg": |
1845 const std::string kResponseBody = "hello world"; | 1845 const std::string kResponseBody = "hello world"; |
1846 SetResponse("HTTP/1.1 200 OK\n" | 1846 SetResponse("HTTP/1.1 200 OK\n" |
1847 "Content-Type: text/plain\n\n", | 1847 "Content-Type: text/plain\n\n", |
1848 kResponseBody); | 1848 kResponseBody); |
1849 | 1849 |
1850 // OK, let the redirect happen. | 1850 // OK, let the redirect happen. |
1851 SetDelayedStartJobGeneration(false); | 1851 SetDelayedStartJobGeneration(false); |
1852 CompleteStartRequest(second_filter, new_request_id); | 1852 CompleteStartRequest(second_filter, new_request_id); |
1853 MessageLoop::current()->RunUntilIdle(); | 1853 base::MessageLoop::current()->RunUntilIdle(); |
1854 | 1854 |
1855 // Flush all the pending requests. | 1855 // Flush all the pending requests. |
1856 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 1856 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
1857 | 1857 |
1858 // Now, simulate the renderer choosing to follow the redirect. | 1858 // Now, simulate the renderer choosing to follow the redirect. |
1859 ResourceHostMsg_FollowRedirect redirect_msg( | 1859 ResourceHostMsg_FollowRedirect redirect_msg( |
1860 new_render_view_id, new_request_id, false, GURL()); | 1860 new_render_view_id, new_request_id, false, GURL()); |
1861 host_.OnMessageReceived(redirect_msg, second_filter, &msg_was_ok); | 1861 host_.OnMessageReceived(redirect_msg, second_filter, &msg_was_ok); |
1862 MessageLoop::current()->RunUntilIdle(); | 1862 base::MessageLoop::current()->RunUntilIdle(); |
1863 | 1863 |
1864 // Flush all the pending requests. | 1864 // Flush all the pending requests. |
1865 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 1865 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
1866 | 1866 |
1867 // Check generated messages. | 1867 // Check generated messages. |
1868 ResourceIPCAccumulator::ClassifiedMessages msgs; | 1868 ResourceIPCAccumulator::ClassifiedMessages msgs; |
1869 accum_.GetClassifiedMessages(&msgs); | 1869 accum_.GetClassifiedMessages(&msgs); |
1870 | 1870 |
1871 ASSERT_EQ(1U, msgs.size()); | 1871 ASSERT_EQ(1U, msgs.size()); |
1872 | 1872 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1961 break; | 1961 break; |
1962 } | 1962 } |
1963 | 1963 |
1964 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); | 1964 EXPECT_EQ(ResourceMsg_DataReceived::ID, msgs[0][i].type()); |
1965 | 1965 |
1966 ResourceHostMsg_DataReceived_ACK msg(0, 1); | 1966 ResourceHostMsg_DataReceived_ACK msg(0, 1); |
1967 bool msg_was_ok; | 1967 bool msg_was_ok; |
1968 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); | 1968 host_.OnMessageReceived(msg, filter_.get(), &msg_was_ok); |
1969 } | 1969 } |
1970 | 1970 |
1971 MessageLoop::current()->RunUntilIdle(); | 1971 base::MessageLoop::current()->RunUntilIdle(); |
1972 | 1972 |
1973 msgs.clear(); | 1973 msgs.clear(); |
1974 accum_.GetClassifiedMessages(&msgs); | 1974 accum_.GetClassifiedMessages(&msgs); |
1975 } | 1975 } |
1976 } | 1976 } |
1977 | 1977 |
1978 } // namespace content | 1978 } // namespace content |
OLD | NEW |