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

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

Issue 2327433002: Stop using CertStore which is not compatible with PlzNavigate. (Closed)
Patch Set: remove cert_store on ios Created 4 years, 3 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"
27 #include "content/browser/child_process_security_policy_impl.h" 26 #include "content/browser/child_process_security_policy_impl.h"
28 #include "content/browser/download/download_manager_impl.h" 27 #include "content/browser/download/download_manager_impl.h"
29 #include "content/browser/download/download_resource_handler.h" 28 #include "content/browser/download/download_resource_handler.h"
30 #include "content/browser/frame_host/navigation_request_info.h" 29 #include "content/browser/frame_host/navigation_request_info.h"
31 #include "content/browser/loader/cross_site_resource_handler.h" 30 #include "content/browser/loader/cross_site_resource_handler.h"
32 #include "content/browser/loader/detachable_resource_handler.h" 31 #include "content/browser/loader/detachable_resource_handler.h"
33 #include "content/browser/loader/navigation_url_loader.h" 32 #include "content/browser/loader/navigation_url_loader.h"
34 #include "content/browser/loader/resource_dispatcher_host_impl.h" 33 #include "content/browser/loader/resource_dispatcher_host_impl.h"
35 #include "content/browser/loader/resource_loader.h" 34 #include "content/browser/loader/resource_loader.h"
36 #include "content/browser/loader/resource_message_filter.h" 35 #include "content/browser/loader/resource_message_filter.h"
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 GURL url; 839 GURL url;
841 net::LoadState load_state; 840 net::LoadState load_state;
842 net::UploadProgress upload_progress; 841 net::UploadProgress upload_progress;
843 }; 842 };
844 843
845 enum class TestConfig { 844 enum class TestConfig {
846 kDefault, 845 kDefault,
847 kOptimizeIPCForSmallResourceEnabled, 846 kOptimizeIPCForSmallResourceEnabled,
848 }; 847 };
849 848
850 // A mock CertStore that doesn't do anything, unless a default cert id
851 // is specified with set_default_cert_id(). If a default cert id is
852 // provided, then StoreCert() always returns that cert id.
853 class MockCertStore : public content::CertStore {
854 public:
855 MockCertStore() : default_cert_id_(0) {}
856
857 ~MockCertStore() override {}
858
859 int StoreCert(net::X509Certificate* cert, int process_id) override {
860 return default_cert_id_;
861 }
862
863 bool RetrieveCert(int process_id,
864 scoped_refptr<net::X509Certificate>* cert) override {
865 return false;
866 }
867
868 void set_default_cert_id(int default_cert_id) {
869 default_cert_id_ = default_cert_id;
870 }
871
872 private:
873 int default_cert_id_;
874 };
875
876 void CheckRequestCompleteErrorCode(const IPC::Message& message, 849 void CheckRequestCompleteErrorCode(const IPC::Message& message,
877 int expected_error_code) { 850 int expected_error_code) {
878 // Verify the expected error code was received. 851 // Verify the expected error code was received.
879 int request_id; 852 int request_id;
880 int error_code; 853 int error_code;
881 854
882 ASSERT_EQ(ResourceMsg_RequestComplete::ID, message.type()); 855 ASSERT_EQ(ResourceMsg_RequestComplete::ID, message.type());
883 856
884 base::PickleIterator iter(message); 857 base::PickleIterator iter(message);
885 ASSERT_TRUE(IPC::ReadParam(&message, &iter, &request_id)); 858 ASSERT_TRUE(IPC::ReadParam(&message, &iter, &request_id));
(...skipping 17 matching lines...) Expand all
903 browser_context_.reset(new TestBrowserContext()); 876 browser_context_.reset(new TestBrowserContext());
904 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); 877 BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
905 base::RunLoop().RunUntilIdle(); 878 base::RunLoop().RunUntilIdle();
906 filter_ = MakeForwardingFilter(); 879 filter_ = MakeForwardingFilter();
907 // TODO(cbentzel): Better way to get URLRequestContext? 880 // TODO(cbentzel): Better way to get URLRequestContext?
908 net::URLRequestContext* request_context = 881 net::URLRequestContext* request_context =
909 browser_context_->GetResourceContext()->GetRequestContext(); 882 browser_context_->GetResourceContext()->GetRequestContext();
910 job_factory_.reset(new TestURLRequestJobFactory(this)); 883 job_factory_.reset(new TestURLRequestJobFactory(this));
911 request_context->set_job_factory(job_factory_.get()); 884 request_context->set_job_factory(job_factory_.get());
912 request_context->set_network_delegate(&network_delegate_); 885 request_context->set_network_delegate(&network_delegate_);
913 host_.cert_store_for_testing_ = &mock_cert_store_;
914 } 886 }
915 887
916 // IPC::Sender implementation 888 // IPC::Sender implementation
917 bool Send(IPC::Message* msg) override { 889 bool Send(IPC::Message* msg) override {
918 accum_.AddMessage(*msg); 890 accum_.AddMessage(*msg);
919 891
920 if (send_data_received_acks_ && 892 if (send_data_received_acks_ &&
921 msg->type() == ResourceMsg_DataReceived::ID) { 893 msg->type() == ResourceMsg_DataReceived::ID) {
922 GenerateDataReceivedACK(*msg); 894 GenerateDataReceivedACK(*msg);
923 } 895 }
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 ResourceDispatcherHostImpl host_; 1165 ResourceDispatcherHostImpl host_;
1194 ResourceIPCAccumulator accum_; 1166 ResourceIPCAccumulator accum_;
1195 std::string response_headers_; 1167 std::string response_headers_;
1196 std::string response_data_; 1168 std::string response_data_;
1197 bool use_test_ssl_certificate_; 1169 bool use_test_ssl_certificate_;
1198 std::string scheme_; 1170 std::string scheme_;
1199 bool send_data_received_acks_; 1171 bool send_data_received_acks_;
1200 std::set<int> child_ids_; 1172 std::set<int> child_ids_;
1201 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_; 1173 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_;
1202 RenderViewHostTestEnabler render_view_host_test_enabler_; 1174 RenderViewHostTestEnabler render_view_host_test_enabler_;
1203 MockCertStore mock_cert_store_;
1204 bool auto_advance_; 1175 bool auto_advance_;
1205 }; 1176 };
1206 1177
1207 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, 1178 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id,
1208 int request_id, 1179 int request_id,
1209 const GURL& url) { 1180 const GURL& url) {
1210 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 1181 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
1211 url, RESOURCE_TYPE_SUB_RESOURCE); 1182 url, RESOURCE_TYPE_SUB_RESOURCE);
1212 } 1183 }
1213 1184
(...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after
3816 return nullptr; 3787 return nullptr;
3817 } 3788 }
3818 3789
3819 INSTANTIATE_TEST_CASE_P( 3790 INSTANTIATE_TEST_CASE_P(
3820 ResourceDispatcherHostTests, 3791 ResourceDispatcherHostTests,
3821 ResourceDispatcherHostTest, 3792 ResourceDispatcherHostTest,
3822 testing::Values(TestConfig::kDefault, 3793 testing::Values(TestConfig::kDefault,
3823 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3794 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3824 3795
3825 } // namespace content 3796 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/resource_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698