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