| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 #include <utility> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
| 16 #include "base/pickle.h" | 16 #include "base/pickle.h" |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 | 1107 |
| 1108 void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest( | 1108 void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest( |
| 1109 int request_id, | 1109 int request_id, |
| 1110 const GURL& url) { | 1110 const GURL& url) { |
| 1111 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); | 1111 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); |
| 1112 save_info->prompt_for_save_location = false; | 1112 save_info->prompt_for_save_location = false; |
| 1113 net::URLRequestContext* request_context = | 1113 net::URLRequestContext* request_context = |
| 1114 browser_context_->GetResourceContext()->GetRequestContext(); | 1114 browser_context_->GetResourceContext()->GetRequestContext(); |
| 1115 scoped_ptr<net::URLRequest> request( | 1115 scoped_ptr<net::URLRequest> request( |
| 1116 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); | 1116 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); |
| 1117 host_.BeginDownload( | 1117 host_.BeginDownload(std::move(request), Referrer(), |
| 1118 request.Pass(), | 1118 false, // is_content_initiated |
| 1119 Referrer(), | 1119 browser_context_->GetResourceContext(), |
| 1120 false, // is_content_initiated | 1120 web_contents_->GetRenderProcessHost()->GetID(), |
| 1121 browser_context_->GetResourceContext(), | 1121 web_contents_->GetRoutingID(), |
| 1122 web_contents_->GetRenderProcessHost()->GetID(), | 1122 web_contents_->GetMainFrame()->GetRoutingID(), false, |
| 1123 web_contents_->GetRoutingID(), | 1123 false, std::move(save_info), DownloadItem::kInvalidId, |
| 1124 web_contents_->GetMainFrame()->GetRoutingID(), | 1124 ResourceDispatcherHostImpl::DownloadStartedCallback()); |
| 1125 false, | |
| 1126 false, | |
| 1127 save_info.Pass(), | |
| 1128 DownloadItem::kInvalidId, | |
| 1129 ResourceDispatcherHostImpl::DownloadStartedCallback()); | |
| 1130 } | 1125 } |
| 1131 | 1126 |
| 1132 void ResourceDispatcherHostTest::CancelRequest(int request_id) { | 1127 void ResourceDispatcherHostTest::CancelRequest(int request_id) { |
| 1133 host_.CancelRequest(filter_->child_id(), request_id); | 1128 host_.CancelRequest(filter_->child_id(), request_id); |
| 1134 } | 1129 } |
| 1135 | 1130 |
| 1136 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { | 1131 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { |
| 1137 CompleteStartRequest(filter_.get(), request_id); | 1132 CompleteStartRequest(filter_.get(), request_id); |
| 1138 } | 1133 } |
| 1139 | 1134 |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2042 4436, | 2037 4436, |
| 2043 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get())); | 2038 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get())); |
| 2044 | 2039 |
| 2045 // Add 33 bytes of upload content. | 2040 // Add 33 bytes of upload content. |
| 2046 std::string upload_content; | 2041 std::string upload_content; |
| 2047 upload_content.resize(33); | 2042 upload_content.resize(33); |
| 2048 std::fill(upload_content.begin(), upload_content.end(), 'x'); | 2043 std::fill(upload_content.begin(), upload_content.end(), 'x'); |
| 2049 scoped_ptr<net::UploadElementReader> reader(new net::UploadBytesElementReader( | 2044 scoped_ptr<net::UploadElementReader> reader(new net::UploadBytesElementReader( |
| 2050 upload_content.data(), upload_content.size())); | 2045 upload_content.data(), upload_content.size())); |
| 2051 req->set_upload( | 2046 req->set_upload( |
| 2052 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); | 2047 net::ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); |
| 2053 | 2048 |
| 2054 // Since the upload throttling is disabled, this has no effect on the cost. | 2049 // Since the upload throttling is disabled, this has no effect on the cost. |
| 2055 EXPECT_EQ( | 2050 EXPECT_EQ( |
| 2056 4436, | 2051 4436, |
| 2057 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get())); | 2052 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get())); |
| 2058 } | 2053 } |
| 2059 | 2054 |
| 2060 // Test that too much memory for outstanding requests for a particular | 2055 // Test that too much memory for outstanding requests for a particular |
| 2061 // render_process_host_id causes requests to fail. | 2056 // render_process_host_id causes requests to fail. |
| 2062 TEST_F(ResourceDispatcherHostTest, TooMuchOutstandingRequestsMemory) { | 2057 TEST_F(ResourceDispatcherHostTest, TooMuchOutstandingRequestsMemory) { |
| (...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3490 net::URLRequestJob* TestURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( | 3485 net::URLRequestJob* TestURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( |
| 3491 const std::string& scheme, | 3486 const std::string& scheme, |
| 3492 net::URLRequest* request, | 3487 net::URLRequest* request, |
| 3493 net::NetworkDelegate* network_delegate) const { | 3488 net::NetworkDelegate* network_delegate) const { |
| 3494 url_request_jobs_created_count_++; | 3489 url_request_jobs_created_count_++; |
| 3495 if (test_fixture_->wait_for_request_create_loop_) | 3490 if (test_fixture_->wait_for_request_create_loop_) |
| 3496 test_fixture_->wait_for_request_create_loop_->Quit(); | 3491 test_fixture_->wait_for_request_create_loop_->Quit(); |
| 3497 if (test_fixture_->loader_test_request_info_) { | 3492 if (test_fixture_->loader_test_request_info_) { |
| 3498 DCHECK_EQ(test_fixture_->loader_test_request_info_->url, request->url()); | 3493 DCHECK_EQ(test_fixture_->loader_test_request_info_->url, request->url()); |
| 3499 scoped_ptr<LoadInfoTestRequestInfo> info = | 3494 scoped_ptr<LoadInfoTestRequestInfo> info = |
| 3500 test_fixture_->loader_test_request_info_.Pass(); | 3495 std::move(test_fixture_->loader_test_request_info_); |
| 3501 return new URLRequestLoadInfoJob(request, network_delegate, | 3496 return new URLRequestLoadInfoJob(request, network_delegate, |
| 3502 info->load_state, info->upload_progress); | 3497 info->load_state, info->upload_progress); |
| 3503 } | 3498 } |
| 3504 if (hang_after_start_) { | 3499 if (hang_after_start_) { |
| 3505 return new net::URLRequestFailedJob(request, network_delegate, | 3500 return new net::URLRequestFailedJob(request, network_delegate, |
| 3506 net::ERR_IO_PENDING); | 3501 net::ERR_IO_PENDING); |
| 3507 } | 3502 } |
| 3508 if (test_fixture_->response_headers_.empty()) { | 3503 if (test_fixture_->response_headers_.empty()) { |
| 3509 if (delay_start_) { | 3504 if (delay_start_) { |
| 3510 return new URLRequestTestDelayedStartJob(request, network_delegate); | 3505 return new URLRequestTestDelayedStartJob(request, network_delegate); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3545 return nullptr; | 3540 return nullptr; |
| 3546 } | 3541 } |
| 3547 | 3542 |
| 3548 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse( | 3543 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse( |
| 3549 net::URLRequest* request, | 3544 net::URLRequest* request, |
| 3550 net::NetworkDelegate* network_delegate) const { | 3545 net::NetworkDelegate* network_delegate) const { |
| 3551 return nullptr; | 3546 return nullptr; |
| 3552 } | 3547 } |
| 3553 | 3548 |
| 3554 } // namespace content | 3549 } // namespace content |
| OLD | NEW |