| 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 #include <vector> | 10 #include <vector> |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 class TestURLLoaderFactory final : public mojom::URLLoaderFactory { | 287 class TestURLLoaderFactory final : public mojom::URLLoaderFactory { |
| 288 public: | 288 public: |
| 289 TestURLLoaderFactory() {} | 289 TestURLLoaderFactory() {} |
| 290 ~TestURLLoaderFactory() override {} | 290 ~TestURLLoaderFactory() override {} |
| 291 | 291 |
| 292 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest request, | 292 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest request, |
| 293 int32_t routing_id, | 293 int32_t routing_id, |
| 294 int32_t request_id, | 294 int32_t request_id, |
| 295 int32_t options, |
| 295 const ResourceRequest& url_request, | 296 const ResourceRequest& url_request, |
| 296 mojom::URLLoaderClientPtr client_ptr) override { | 297 mojom::URLLoaderClientPtr client_ptr) override { |
| 297 loader_request_ = std::move(request); | 298 loader_request_ = std::move(request); |
| 298 client_ptr_ = std::move(client_ptr); | 299 client_ptr_ = std::move(client_ptr); |
| 299 } | 300 } |
| 300 | 301 |
| 301 mojom::URLLoaderAssociatedRequest PassLoaderRequest() { | 302 mojom::URLLoaderAssociatedRequest PassLoaderRequest() { |
| 302 return std::move(loader_request_); | 303 return std::move(loader_request_); |
| 303 } | 304 } |
| 304 | 305 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 true, // is_async | 348 true, // is_async |
| 348 PREVIEWS_OFF // previews_state | 349 PREVIEWS_OFF // previews_state |
| 349 ); | 350 ); |
| 350 | 351 |
| 351 ResourceRequest request; | 352 ResourceRequest request; |
| 352 base::WeakPtr<mojo::StrongBinding<mojom::URLLoaderFactory>> weak_binding = | 353 base::WeakPtr<mojo::StrongBinding<mojom::URLLoaderFactory>> weak_binding = |
| 353 mojo::MakeStrongBinding(base::MakeUnique<TestURLLoaderFactory>(), | 354 mojo::MakeStrongBinding(base::MakeUnique<TestURLLoaderFactory>(), |
| 354 mojo::MakeRequest(&url_loader_factory_)); | 355 mojo::MakeRequest(&url_loader_factory_)); |
| 355 | 356 |
| 356 url_loader_factory_->CreateLoaderAndStart( | 357 url_loader_factory_->CreateLoaderAndStart( |
| 357 mojo::MakeRequest(&url_loader_proxy_), kRouteId, kRequestId, request, | 358 mojo::MakeRequest(&url_loader_proxy_), kRouteId, kRequestId, 0, request, |
| 358 url_loader_client_.CreateInterfacePtr()); | 359 url_loader_client_.CreateInterfacePtr()); |
| 359 | 360 |
| 360 url_loader_factory_.FlushForTesting(); | 361 url_loader_factory_.FlushForTesting(); |
| 361 DCHECK(weak_binding); | 362 DCHECK(weak_binding); |
| 362 TestURLLoaderFactory* factory_impl = | 363 TestURLLoaderFactory* factory_impl = |
| 363 static_cast<TestURLLoaderFactory*>(weak_binding->impl()); | 364 static_cast<TestURLLoaderFactory*>(weak_binding->impl()); |
| 364 | 365 |
| 365 handler_.reset(new MojoAsyncResourceHandlerWithStubOperations( | 366 handler_.reset(new MojoAsyncResourceHandlerWithStubOperations( |
| 366 request_.get(), &rdh_, factory_impl->PassLoaderRequest(), | 367 request_.get(), &rdh_, factory_impl->PassLoaderRequest(), |
| 367 factory_impl->PassClientPtr())); | 368 factory_impl->PassClientPtr())); |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 } | 1355 } |
| 1355 } | 1356 } |
| 1356 EXPECT_EQ("B", body); | 1357 EXPECT_EQ("B", body); |
| 1357 } | 1358 } |
| 1358 | 1359 |
| 1359 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, | 1360 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, |
| 1360 MojoAsyncResourceHandlerWithAllocationSizeTest, | 1361 MojoAsyncResourceHandlerWithAllocationSizeTest, |
| 1361 ::testing::Values(8, 32 * 2014)); | 1362 ::testing::Values(8, 32 * 2014)); |
| 1362 } // namespace | 1363 } // namespace |
| 1363 } // namespace content | 1364 } // namespace content |
| OLD | NEW |