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 |
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" | |
13 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
15 #include "base/location.h" | 14 #include "base/location.h" |
16 #include "base/macros.h" | 15 #include "base/macros.h" |
17 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
18 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
19 #include "base/pickle.h" | 18 #include "base/pickle.h" |
20 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
21 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
22 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
| 23 #include "base/test/scoped_feature_list.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/child_process_security_policy_impl.h" | 26 #include "content/browser/child_process_security_policy_impl.h" |
27 #include "content/browser/download/download_manager_impl.h" | 27 #include "content/browser/download/download_manager_impl.h" |
28 #include "content/browser/download/download_resource_handler.h" | 28 #include "content/browser/download/download_resource_handler.h" |
29 #include "content/browser/frame_host/navigation_request_info.h" | 29 #include "content/browser/frame_host/navigation_request_info.h" |
30 #include "content/browser/loader/detachable_resource_handler.h" | 30 #include "content/browser/loader/detachable_resource_handler.h" |
31 #include "content/browser/loader/navigation_resource_throttle.h" | 31 #include "content/browser/loader/navigation_resource_throttle.h" |
32 #include "content/browser/loader/navigation_url_loader.h" | 32 #include "content/browser/loader/navigation_url_loader.h" |
33 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 33 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 SiteInstance::Create(browser_context_.get()); | 891 SiteInstance::Create(browser_context_.get()); |
892 web_contents_.reset( | 892 web_contents_.reset( |
893 WebContents::Create(WebContents::CreateParams(browser_context_.get()))); | 893 WebContents::Create(WebContents::CreateParams(browser_context_.get()))); |
894 web_contents_observer_.reset( | 894 web_contents_observer_.reset( |
895 new TestWebContentsObserver(web_contents_.get())); | 895 new TestWebContentsObserver(web_contents_.get())); |
896 web_contents_filter_ = new TestFilterSpecifyingChild( | 896 web_contents_filter_ = new TestFilterSpecifyingChild( |
897 browser_context_->GetResourceContext(), | 897 browser_context_->GetResourceContext(), |
898 web_contents_->GetRenderProcessHost()->GetID()); | 898 web_contents_->GetRenderProcessHost()->GetID()); |
899 child_ids_.insert(web_contents_->GetRenderProcessHost()->GetID()); | 899 child_ids_.insert(web_contents_->GetRenderProcessHost()->GetID()); |
900 | 900 |
901 base::FeatureList::ClearInstanceForTesting(); | |
902 switch (GetParam()) { | 901 switch (GetParam()) { |
903 case TestConfig::kDefault: | 902 case TestConfig::kDefault: |
904 base::FeatureList::InitializeInstance(std::string(), std::string()); | |
905 break; | 903 break; |
906 case TestConfig::kOptimizeIPCForSmallResourceEnabled: { | 904 case TestConfig::kOptimizeIPCForSmallResourceEnabled: { |
907 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 905 scoped_feature_list_.InitAndEnableFeature( |
908 feature_list->InitializeFromCommandLine( | 906 features::kOptimizeLoadingIPCForSmallResources); |
909 features::kOptimizeLoadingIPCForSmallResources.name, std::string()); | |
910 base::FeatureList::SetInstance(std::move(feature_list)); | |
911 ASSERT_TRUE(base::FeatureList::IsEnabled( | 907 ASSERT_TRUE(base::FeatureList::IsEnabled( |
912 features::kOptimizeLoadingIPCForSmallResources)); | 908 features::kOptimizeLoadingIPCForSmallResources)); |
913 break; | 909 break; |
914 } | 910 } |
915 } | 911 } |
916 } | 912 } |
917 | 913 |
918 void TearDown() override { | 914 void TearDown() override { |
919 web_contents_observer_.reset(); | 915 web_contents_observer_.reset(); |
920 web_contents_.reset(); | 916 web_contents_.reset(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 ResourceIPCAccumulator accum_; | 1122 ResourceIPCAccumulator accum_; |
1127 std::string response_headers_; | 1123 std::string response_headers_; |
1128 std::string response_data_; | 1124 std::string response_data_; |
1129 bool use_test_ssl_certificate_; | 1125 bool use_test_ssl_certificate_; |
1130 std::string scheme_; | 1126 std::string scheme_; |
1131 bool send_data_received_acks_; | 1127 bool send_data_received_acks_; |
1132 std::set<int> child_ids_; | 1128 std::set<int> child_ids_; |
1133 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_; | 1129 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_; |
1134 RenderViewHostTestEnabler render_view_host_test_enabler_; | 1130 RenderViewHostTestEnabler render_view_host_test_enabler_; |
1135 bool auto_advance_; | 1131 bool auto_advance_; |
| 1132 base::test::ScopedFeatureList scoped_feature_list_; |
1136 }; | 1133 }; |
1137 | 1134 |
1138 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, | 1135 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, |
1139 int request_id, | 1136 int request_id, |
1140 const GURL& url) { | 1137 const GURL& url) { |
1141 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, | 1138 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, |
1142 url, RESOURCE_TYPE_SUB_RESOURCE); | 1139 url, RESOURCE_TYPE_SUB_RESOURCE); |
1143 } | 1140 } |
1144 | 1141 |
1145 void ResourceDispatcherHostTest::MakeTestRequestWithRenderFrame( | 1142 void ResourceDispatcherHostTest::MakeTestRequestWithRenderFrame( |
(...skipping 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3846 return nullptr; | 3843 return nullptr; |
3847 } | 3844 } |
3848 | 3845 |
3849 INSTANTIATE_TEST_CASE_P( | 3846 INSTANTIATE_TEST_CASE_P( |
3850 ResourceDispatcherHostTests, | 3847 ResourceDispatcherHostTests, |
3851 ResourceDispatcherHostTest, | 3848 ResourceDispatcherHostTest, |
3852 testing::Values(TestConfig::kDefault, | 3849 testing::Values(TestConfig::kDefault, |
3853 TestConfig::kOptimizeIPCForSmallResourceEnabled)); | 3850 TestConfig::kOptimizeIPCForSmallResourceEnabled)); |
3854 | 3851 |
3855 } // namespace content | 3852 } // namespace content |
OLD | NEW |