| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/loader/mojo_async_resource_handler.h" | 5 #include "content/browser/loader/mojo_async_resource_handler.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "content/browser/loader/resource_controller.h" | 18 #include "content/browser/loader/resource_controller.h" |
| 19 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 19 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 20 #include "content/browser/loader/resource_request_info_impl.h" | 20 #include "content/browser/loader/resource_request_info_impl.h" |
| 21 #include "content/browser/loader/test_url_loader_client.h" | 21 #include "content/browser/loader/test_url_loader_client.h" |
| 22 #include "content/common/resource_request_completion_status.h" | 22 #include "content/common/resource_request_completion_status.h" |
| 23 #include "content/common/url_loader.mojom.h" | 23 #include "content/common/url_loader.mojom.h" |
| 24 #include "content/public/browser/appcache_service.h" | 24 #include "content/public/browser/appcache_service.h" |
| 25 #include "content/public/browser/navigation_data.h" | 25 #include "content/public/browser/navigation_data.h" |
| 26 #include "content/public/browser/resource_context.h" | 26 #include "content/public/browser/resource_context.h" |
| 27 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 27 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 28 #include "content/public/browser/resource_throttle.h" | 28 #include "content/public/browser/resource_throttle.h" |
| 29 #include "content/public/browser/stream_info.h" | 29 #include "content/public/browser/stream_info.h" |
| 30 #include "content/public/common/previews_state.h" |
| 30 #include "content/public/common/resource_response.h" | 31 #include "content/public/common/resource_response.h" |
| 31 #include "content/public/common/resource_type.h" | 32 #include "content/public/common/resource_type.h" |
| 32 #include "content/public/test/test_browser_context.h" | 33 #include "content/public/test/test_browser_context.h" |
| 33 #include "content/public/test/test_browser_thread_bundle.h" | 34 #include "content/public/test/test_browser_thread_bundle.h" |
| 34 #include "mojo/public/c/system/data_pipe.h" | 35 #include "mojo/public/c/system/data_pipe.h" |
| 35 #include "mojo/public/c/system/types.h" | 36 #include "mojo/public/c/system/types.h" |
| 36 #include "mojo/public/cpp/bindings/strong_binding.h" | 37 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 37 #include "mojo/public/cpp/system/data_pipe.h" | 38 #include "mojo/public/cpp/system/data_pipe.h" |
| 38 #include "net/base/auth.h" | 39 #include "net/base/auth.h" |
| 39 #include "net/base/net_errors.h" | 40 #include "net/base/net_errors.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 net::URLRequest* request, | 135 net::URLRequest* request, |
| 135 ResourceContext* resource_context, | 136 ResourceContext* resource_context, |
| 136 ResourceResponse* response) override { | 137 ResourceResponse* response) override { |
| 137 ADD_FAILURE() << "OnRequestRedirected should not be called."; | 138 ADD_FAILURE() << "OnRequestRedirected should not be called."; |
| 138 } | 139 } |
| 139 | 140 |
| 140 void RequestComplete(net::URLRequest* url_request) override { | 141 void RequestComplete(net::URLRequest* url_request) override { |
| 141 ADD_FAILURE() << "RequestComplete should not be called."; | 142 ADD_FAILURE() << "RequestComplete should not be called."; |
| 142 } | 143 } |
| 143 | 144 |
| 144 bool ShouldEnableLoFiMode( | 145 PreviewsState GetPreviewsState( |
| 145 const net::URLRequest& url_request, | 146 const net::URLRequest& url_request, |
| 146 content::ResourceContext* resource_context) override { | 147 content::ResourceContext* resource_context) override { |
| 147 ADD_FAILURE() << "ShouldEnableLoFiMode should not be called."; | 148 ADD_FAILURE() << "GetPreviewsState should not be called."; |
| 148 return false; | 149 return PREVIEWS_UNSPECIFIED; |
| 149 } | 150 } |
| 150 | 151 |
| 151 NavigationData* GetNavigationData(net::URLRequest* request) const override { | 152 NavigationData* GetNavigationData(net::URLRequest* request) const override { |
| 152 ADD_FAILURE() << "GetNavigationData should not be called."; | 153 ADD_FAILURE() << "GetNavigationData should not be called."; |
| 153 return nullptr; | 154 return nullptr; |
| 154 } | 155 } |
| 155 | 156 |
| 156 std::unique_ptr<net::ClientCertStore> CreateClientCertStore( | 157 std::unique_ptr<net::ClientCertStore> CreateClientCertStore( |
| 157 ResourceContext* resource_context) override { | 158 ResourceContext* resource_context) override { |
| 158 ADD_FAILURE() << "CreateClientCertStore should not be called."; | 159 ADD_FAILURE() << "CreateClientCertStore should not be called."; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 request_.get(), // request | 329 request_.get(), // request |
| 329 RESOURCE_TYPE_XHR, // resource_type | 330 RESOURCE_TYPE_XHR, // resource_type |
| 330 browser_context_->GetResourceContext(), // context | 331 browser_context_->GetResourceContext(), // context |
| 331 2, // render_process_id | 332 2, // render_process_id |
| 332 0, // render_view_id | 333 0, // render_view_id |
| 333 0, // render_frame_id | 334 0, // render_frame_id |
| 334 true, // is_main_frame | 335 true, // is_main_frame |
| 335 false, // parent_is_main_frame | 336 false, // parent_is_main_frame |
| 336 false, // allow_download | 337 false, // allow_download |
| 337 true, // is_async | 338 true, // is_async |
| 338 false // is_using_lofi | 339 PREVIEWS_OFF // previews_state |
| 339 ); | 340 ); |
| 340 | 341 |
| 341 ResourceRequest request; | 342 ResourceRequest request; |
| 342 base::WeakPtr<mojo::StrongBinding<mojom::URLLoaderFactory>> weak_binding = | 343 base::WeakPtr<mojo::StrongBinding<mojom::URLLoaderFactory>> weak_binding = |
| 343 mojo::MakeStrongBinding(base::MakeUnique<TestURLLoaderFactory>(), | 344 mojo::MakeStrongBinding(base::MakeUnique<TestURLLoaderFactory>(), |
| 344 mojo::GetProxy(&url_loader_factory_)); | 345 mojo::GetProxy(&url_loader_factory_)); |
| 345 | 346 |
| 346 url_loader_factory_->CreateLoaderAndStart( | 347 url_loader_factory_->CreateLoaderAndStart( |
| 347 mojo::GetProxy(&url_loader_proxy_, | 348 mojo::GetProxy(&url_loader_proxy_, |
| 348 url_loader_factory_.associated_group()), | 349 url_loader_factory_.associated_group()), |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 } | 1271 } |
| 1271 } | 1272 } |
| 1272 EXPECT_EQ("B", body); | 1273 EXPECT_EQ("B", body); |
| 1273 } | 1274 } |
| 1274 | 1275 |
| 1275 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, | 1276 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, |
| 1276 MojoAsyncResourceHandlerWithAllocationSizeTest, | 1277 MojoAsyncResourceHandlerWithAllocationSizeTest, |
| 1277 ::testing::Values(8, 32 * 2014)); | 1278 ::testing::Values(8, 32 * 2014)); |
| 1278 } // namespace | 1279 } // namespace |
| 1279 } // namespace content | 1280 } // namespace content |
| OLD | NEW |