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 "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 10 matching lines...) Expand all Loading... |
21 #include "content/public/browser/global_request_id.h" | 21 #include "content/public/browser/global_request_id.h" |
22 #include "content/public/browser/resource_context.h" | 22 #include "content/public/browser/resource_context.h" |
23 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 23 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
24 #include "content/public/browser/resource_throttle.h" | 24 #include "content/public/browser/resource_throttle.h" |
25 #include "content/public/common/resource_response.h" | 25 #include "content/public/common/resource_response.h" |
26 #include "content/public/test/test_browser_context.h" | 26 #include "content/public/test/test_browser_context.h" |
27 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
28 #include "net/base/upload_data.h" | 28 #include "net/base/upload_data.h" |
29 #include "net/http/http_util.h" | 29 #include "net/http/http_util.h" |
30 #include "net/url_request/url_request.h" | 30 #include "net/url_request/url_request.h" |
| 31 #include "net/url_request/url_request_context.h" |
31 #include "net/url_request/url_request_job.h" | 32 #include "net/url_request/url_request_job.h" |
32 #include "net/url_request/url_request_test_job.h" | 33 #include "net/url_request/url_request_test_job.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "webkit/appcache/appcache_interfaces.h" | 35 #include "webkit/appcache/appcache_interfaces.h" |
35 | 36 |
36 // TODO(eroman): Write unit tests for SafeBrowsing that exercise | 37 // TODO(eroman): Write unit tests for SafeBrowsing that exercise |
37 // SafeBrowsingResourceHandler. | 38 // SafeBrowsingResourceHandler. |
38 | 39 |
39 namespace content { | 40 namespace content { |
40 | 41 |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 | 963 |
963 host_.CancelRequestsForProcess(filter_->child_id()); | 964 host_.CancelRequestsForProcess(filter_->child_id()); |
964 host_.CancelRequestsForProcess(second_filter->child_id()); | 965 host_.CancelRequestsForProcess(second_filter->child_id()); |
965 | 966 |
966 // Flush all the pending requests. | 967 // Flush all the pending requests. |
967 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} | 968 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
968 } | 969 } |
969 | 970 |
970 // Test the private helper method "CalculateApproximateMemoryCost()". | 971 // Test the private helper method "CalculateApproximateMemoryCost()". |
971 TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { | 972 TEST_F(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { |
972 net::URLRequest req(GURL("http://www.google.com"), NULL); | 973 net::URLRequestContext context; |
| 974 net::URLRequest req(GURL("http://www.google.com"), NULL, &context); |
973 EXPECT_EQ(4427, | 975 EXPECT_EQ(4427, |
974 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(&req)); | 976 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(&req)); |
975 | 977 |
976 // Add 9 bytes of referrer. | 978 // Add 9 bytes of referrer. |
977 req.set_referrer("123456789"); | 979 req.set_referrer("123456789"); |
978 EXPECT_EQ(4436, | 980 EXPECT_EQ(4436, |
979 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(&req)); | 981 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(&req)); |
980 | 982 |
981 // Add 33 bytes of upload content. | 983 // Add 33 bytes of upload content. |
982 std::string upload_content; | 984 std::string upload_content; |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 PickleIterator iter(msgs[0][0]); | 1428 PickleIterator iter(msgs[0][0]); |
1427 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); | 1429 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); |
1428 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); | 1430 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); |
1429 | 1431 |
1430 EXPECT_EQ(1, request_id); | 1432 EXPECT_EQ(1, request_id); |
1431 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); | 1433 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); |
1432 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); | 1434 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); |
1433 } | 1435 } |
1434 | 1436 |
1435 } // namespace content | 1437 } // namespace content |
OLD | NEW |