| 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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 SiteInstance::Create(browser_context_.get()); | 890 SiteInstance::Create(browser_context_.get()); |
| 891 web_contents_.reset( | 891 web_contents_.reset( |
| 892 WebContents::Create(WebContents::CreateParams(browser_context_.get()))); | 892 WebContents::Create(WebContents::CreateParams(browser_context_.get()))); |
| 893 web_contents_observer_.reset( | 893 web_contents_observer_.reset( |
| 894 new TestWebContentsObserver(web_contents_.get())); | 894 new TestWebContentsObserver(web_contents_.get())); |
| 895 web_contents_filter_ = new TestFilterSpecifyingChild( | 895 web_contents_filter_ = new TestFilterSpecifyingChild( |
| 896 browser_context_->GetResourceContext(), | 896 browser_context_->GetResourceContext(), |
| 897 web_contents_->GetRenderProcessHost()->GetID()); | 897 web_contents_->GetRenderProcessHost()->GetID()); |
| 898 child_ids_.insert(web_contents_->GetRenderProcessHost()->GetID()); | 898 child_ids_.insert(web_contents_->GetRenderProcessHost()->GetID()); |
| 899 | 899 |
| 900 base::FeatureList::ClearInstanceForTesting(); | |
| 901 switch (GetParam()) { | 900 switch (GetParam()) { |
| 902 case TestConfig::kDefault: | 901 case TestConfig::kDefault: |
| 903 base::FeatureList::InitializeInstance(std::string(), std::string()); | |
| 904 break; | 902 break; |
| 905 case TestConfig::kOptimizeIPCForSmallResourceEnabled: { | 903 case TestConfig::kOptimizeIPCForSmallResourceEnabled: { |
| 906 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 904 scoped_feature_list_.InitAndEnableFeature( |
| 907 feature_list->InitializeFromCommandLine( | 905 features::kOptimizeLoadingIPCForSmallResources); |
| 908 features::kOptimizeLoadingIPCForSmallResources.name, std::string()); | |
| 909 base::FeatureList::SetInstance(std::move(feature_list)); | |
| 910 ASSERT_TRUE(base::FeatureList::IsEnabled( | 906 ASSERT_TRUE(base::FeatureList::IsEnabled( |
| 911 features::kOptimizeLoadingIPCForSmallResources)); | 907 features::kOptimizeLoadingIPCForSmallResources)); |
| 912 break; | 908 break; |
| 913 } | 909 } |
| 914 } | 910 } |
| 915 } | 911 } |
| 916 | 912 |
| 917 void TearDown() override { | 913 void TearDown() override { |
| 918 web_contents_observer_.reset(); | 914 web_contents_observer_.reset(); |
| 919 web_contents_.reset(); | 915 web_contents_.reset(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 ResourceIPCAccumulator accum_; | 1121 ResourceIPCAccumulator accum_; |
| 1126 std::string response_headers_; | 1122 std::string response_headers_; |
| 1127 std::string response_data_; | 1123 std::string response_data_; |
| 1128 bool use_test_ssl_certificate_; | 1124 bool use_test_ssl_certificate_; |
| 1129 std::string scheme_; | 1125 std::string scheme_; |
| 1130 bool send_data_received_acks_; | 1126 bool send_data_received_acks_; |
| 1131 std::set<int> child_ids_; | 1127 std::set<int> child_ids_; |
| 1132 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_; | 1128 std::unique_ptr<base::RunLoop> wait_for_request_complete_loop_; |
| 1133 RenderViewHostTestEnabler render_view_host_test_enabler_; | 1129 RenderViewHostTestEnabler render_view_host_test_enabler_; |
| 1134 bool auto_advance_; | 1130 bool auto_advance_; |
| 1131 base::test::ScopedFeatureList scoped_feature_list_; |
| 1135 }; | 1132 }; |
| 1136 | 1133 |
| 1137 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, | 1134 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, |
| 1138 int request_id, | 1135 int request_id, |
| 1139 const GURL& url) { | 1136 const GURL& url) { |
| 1140 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, | 1137 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, |
| 1141 url, RESOURCE_TYPE_SUB_RESOURCE); | 1138 url, RESOURCE_TYPE_SUB_RESOURCE); |
| 1142 } | 1139 } |
| 1143 | 1140 |
| 1144 void ResourceDispatcherHostTest::MakeTestRequestWithRenderFrame( | 1141 void ResourceDispatcherHostTest::MakeTestRequestWithRenderFrame( |
| (...skipping 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3845 return nullptr; | 3842 return nullptr; |
| 3846 } | 3843 } |
| 3847 | 3844 |
| 3848 INSTANTIATE_TEST_CASE_P( | 3845 INSTANTIATE_TEST_CASE_P( |
| 3849 ResourceDispatcherHostTests, | 3846 ResourceDispatcherHostTests, |
| 3850 ResourceDispatcherHostTest, | 3847 ResourceDispatcherHostTest, |
| 3851 testing::Values(TestConfig::kDefault, | 3848 testing::Values(TestConfig::kDefault, |
| 3852 TestConfig::kOptimizeIPCForSmallResourceEnabled)); | 3849 TestConfig::kOptimizeIPCForSmallResourceEnabled)); |
| 3853 | 3850 |
| 3854 } // namespace content | 3851 } // namespace content |
| OLD | NEW |