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

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

Issue 2251643003: Remove the BeginSaveFile and BeginDownload methods from ResourceDispatcherHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize tab_info_ in OnStart instead of OnResponseStart because we need a central place where al… Created 4 years, 4 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/feature_list.h" 12 #include "base/feature_list.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "base/memory/shared_memory.h" 18 #include "base/memory/shared_memory.h"
19 #include "base/pickle.h" 19 #include "base/pickle.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h" 23 #include "base/strings/string_split.h"
24 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
25 #include "content/browser/browser_thread_impl.h" 25 #include "content/browser/browser_thread_impl.h"
26 #include "content/browser/cert_store_impl.h" 26 #include "content/browser/cert_store_impl.h"
27 #include "content/browser/child_process_security_policy_impl.h" 27 #include "content/browser/child_process_security_policy_impl.h"
28 #include "content/browser/download/download_manager_impl.h"
28 #include "content/browser/frame_host/navigation_request_info.h" 29 #include "content/browser/frame_host/navigation_request_info.h"
29 #include "content/browser/loader/cross_site_resource_handler.h" 30 #include "content/browser/loader/cross_site_resource_handler.h"
30 #include "content/browser/loader/detachable_resource_handler.h" 31 #include "content/browser/loader/detachable_resource_handler.h"
31 #include "content/browser/loader/navigation_url_loader.h" 32 #include "content/browser/loader/navigation_url_loader.h"
32 #include "content/browser/loader/resource_dispatcher_host_impl.h" 33 #include "content/browser/loader/resource_dispatcher_host_impl.h"
33 #include "content/browser/loader/resource_loader.h" 34 #include "content/browser/loader/resource_loader.h"
34 #include "content/browser/loader/resource_message_filter.h" 35 #include "content/browser/loader/resource_message_filter.h"
35 #include "content/browser/loader/resource_request_info_impl.h" 36 #include "content/browser/loader/resource_request_info_impl.h"
36 #include "content/browser/loader_delegate_impl.h" 37 #include "content/browser/loader_delegate_impl.h"
37 #include "content/common/appcache_interfaces.h" 38 #include "content/common/appcache_interfaces.h"
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); 863 BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
863 base::RunLoop().RunUntilIdle(); 864 base::RunLoop().RunUntilIdle();
864 filter_ = MakeForwardingFilter(); 865 filter_ = MakeForwardingFilter();
865 // TODO(cbentzel): Better way to get URLRequestContext? 866 // TODO(cbentzel): Better way to get URLRequestContext?
866 net::URLRequestContext* request_context = 867 net::URLRequestContext* request_context =
867 browser_context_->GetResourceContext()->GetRequestContext(); 868 browser_context_->GetResourceContext()->GetRequestContext();
868 job_factory_.reset(new TestURLRequestJobFactory(this)); 869 job_factory_.reset(new TestURLRequestJobFactory(this));
869 request_context->set_job_factory(job_factory_.get()); 870 request_context->set_job_factory(job_factory_.get());
870 request_context->set_network_delegate(&network_delegate_); 871 request_context->set_network_delegate(&network_delegate_);
871 host_.cert_store_for_testing_ = &mock_cert_store_; 872 host_.cert_store_for_testing_ = &mock_cert_store_;
873 DownloadManagerImpl::ResourceDispatcherHostCreated();
872 } 874 }
873 875
874 // IPC::Sender implementation 876 // IPC::Sender implementation
875 bool Send(IPC::Message* msg) override { 877 bool Send(IPC::Message* msg) override {
876 accum_.AddMessage(*msg); 878 accum_.AddMessage(*msg);
877 879
878 if (send_data_received_acks_ && 880 if (send_data_received_acks_ &&
879 msg->type() == ResourceMsg_DataReceived::ID) { 881 msg->type() == ResourceMsg_DataReceived::ID) {
880 GenerateDataReceivedACK(*msg); 882 GenerateDataReceivedACK(*msg);
881 } 883 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 int request_id, 1230 int request_id,
1229 net::RequestPriority priority) { 1231 net::RequestPriority priority) {
1230 ResourceRequest request = CreateResourceRequest( 1232 ResourceRequest request = CreateResourceRequest(
1231 "GET", RESOURCE_TYPE_SUB_RESOURCE, GURL("http://example.com/priority")); 1233 "GET", RESOURCE_TYPE_SUB_RESOURCE, GURL("http://example.com/priority"));
1232 request.render_frame_id = render_frame_id; 1234 request.render_frame_id = render_frame_id;
1233 request.priority = priority; 1235 request.priority = priority;
1234 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request); 1236 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request);
1235 host_.OnMessageReceived(msg, filter_.get()); 1237 host_.OnMessageReceived(msg, filter_.get());
1236 } 1238 }
1237 1239
1240 // TODO(ananta)
1241 // Move this test into the download tests.
1238 void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest( 1242 void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest(
1239 int request_id, 1243 int request_id,
1240 const GURL& url) { 1244 const GURL& url) {
1241 net::URLRequestContext* request_context = 1245 net::URLRequestContext* request_context =
1242 browser_context_->GetResourceContext()->GetRequestContext(); 1246 browser_context_->GetResourceContext()->GetRequestContext();
1243 std::unique_ptr<net::URLRequest> request( 1247 std::unique_ptr<net::URLRequest> request(
1244 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); 1248 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL));
1245 host_.BeginDownload(std::move(request), Referrer(), 1249 DownloadManagerImpl::BeginDownloadRequest(
1246 false, // is_content_initiated 1250 std::move(request), Referrer(), browser_context_->GetResourceContext(),
1247 browser_context_->GetResourceContext(), 1251 false, // is_content_initiated
1248 web_contents_->GetRenderProcessHost()->GetID(), 1252 web_contents_->GetRenderProcessHost()->GetID(),
1249 web_contents_->GetRoutingID(), 1253 web_contents_->GetRoutingID(),
1250 web_contents_->GetMainFrame()->GetRoutingID(), false); 1254 web_contents_->GetMainFrame()->GetRoutingID(), false);
1251 } 1255 }
1252 1256
1253 void ResourceDispatcherHostTest::CancelRequest(int request_id) { 1257 void ResourceDispatcherHostTest::CancelRequest(int request_id) {
1254 host_.CancelRequest(filter_->child_id(), request_id); 1258 host_.CancelRequest(filter_->child_id(), request_id);
1255 } 1259 }
1256 1260
1257 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { 1261 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) {
1258 CompleteStartRequest(filter_.get(), request_id); 1262 CompleteStartRequest(filter_.get(), request_id);
1259 } 1263 }
1260 1264
(...skipping 2562 matching lines...) Expand 10 before | Expand all | Expand 10 after
3823 return nullptr; 3827 return nullptr;
3824 } 3828 }
3825 3829
3826 INSTANTIATE_TEST_CASE_P( 3830 INSTANTIATE_TEST_CASE_P(
3827 ResourceDispatcherHostTests, 3831 ResourceDispatcherHostTests,
3828 ResourceDispatcherHostTest, 3832 ResourceDispatcherHostTest,
3829 testing::Values(TestConfig::kDefault, 3833 testing::Values(TestConfig::kDefault,
3830 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3834 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3831 3835
3832 } // namespace content 3836 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698