| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 class TestURLLoaderFactory final : public mojom::URLLoaderFactory { | 289 class TestURLLoaderFactory final : public mojom::URLLoaderFactory { |
| 290 public: | 290 public: |
| 291 TestURLLoaderFactory() {} | 291 TestURLLoaderFactory() {} |
| 292 ~TestURLLoaderFactory() override {} | 292 ~TestURLLoaderFactory() override {} |
| 293 | 293 |
| 294 void CreateLoaderAndStart(mojom::URLLoaderRequest request, | 294 void CreateLoaderAndStart(mojom::URLLoaderRequest request, |
| 295 int32_t routing_id, | 295 int32_t routing_id, |
| 296 int32_t request_id, | 296 int32_t request_id, |
| 297 uint32_t options, | 297 uint32_t options, |
| 298 const ResourceRequest& url_request, | 298 const ResourceRequest& url_request, |
| 299 mojom::URLLoaderClientPtr client_ptr) override { | 299 mojom::URLLoaderClientPtr client_ptr, |
| 300 const net::MutableNetworkTrafficAnnotationTag& |
| 301 traffic_annotation) override { |
| 300 loader_request_ = std::move(request); | 302 loader_request_ = std::move(request); |
| 301 client_ptr_ = std::move(client_ptr); | 303 client_ptr_ = std::move(client_ptr); |
| 302 } | 304 } |
| 303 | 305 |
| 304 mojom::URLLoaderRequest PassLoaderRequest() { | 306 mojom::URLLoaderRequest PassLoaderRequest() { |
| 305 return std::move(loader_request_); | 307 return std::move(loader_request_); |
| 306 } | 308 } |
| 307 | 309 |
| 308 mojom::URLLoaderClientPtr PassClientPtr() { return std::move(client_ptr_); } | 310 mojom::URLLoaderClientPtr PassClientPtr() { return std::move(client_ptr_); } |
| 309 | 311 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 ); | 355 ); |
| 354 | 356 |
| 355 ResourceRequest request; | 357 ResourceRequest request; |
| 356 base::WeakPtr<mojo::StrongBinding<mojom::URLLoaderFactory>> weak_binding = | 358 base::WeakPtr<mojo::StrongBinding<mojom::URLLoaderFactory>> weak_binding = |
| 357 mojo::MakeStrongBinding(base::MakeUnique<TestURLLoaderFactory>(), | 359 mojo::MakeStrongBinding(base::MakeUnique<TestURLLoaderFactory>(), |
| 358 mojo::MakeRequest(&url_loader_factory_)); | 360 mojo::MakeRequest(&url_loader_factory_)); |
| 359 | 361 |
| 360 url_loader_factory_->CreateLoaderAndStart( | 362 url_loader_factory_->CreateLoaderAndStart( |
| 361 mojo::MakeRequest(&url_loader_proxy_), kRouteId, kRequestId, | 363 mojo::MakeRequest(&url_loader_proxy_), kRouteId, kRequestId, |
| 362 mojom::kURLLoadOptionNone, request, | 364 mojom::kURLLoadOptionNone, request, |
| 363 url_loader_client_.CreateInterfacePtr()); | 365 url_loader_client_.CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); |
| 364 | 366 |
| 365 url_loader_factory_.FlushForTesting(); | 367 url_loader_factory_.FlushForTesting(); |
| 366 DCHECK(weak_binding); | 368 DCHECK(weak_binding); |
| 367 TestURLLoaderFactory* factory_impl = | 369 TestURLLoaderFactory* factory_impl = |
| 368 static_cast<TestURLLoaderFactory*>(weak_binding->impl()); | 370 static_cast<TestURLLoaderFactory*>(weak_binding->impl()); |
| 369 | 371 |
| 370 handler_.reset(new MojoAsyncResourceHandlerWithStubOperations( | 372 handler_.reset(new MojoAsyncResourceHandlerWithStubOperations( |
| 371 request_.get(), &rdh_, factory_impl->PassLoaderRequest(), | 373 request_.get(), &rdh_, factory_impl->PassLoaderRequest(), |
| 372 factory_impl->PassClientPtr())); | 374 factory_impl->PassClientPtr())); |
| 373 mock_loader_.reset(new MockResourceLoader(handler_.get())); | 375 mock_loader_.reset(new MockResourceLoader(handler_.get())); |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 } | 1361 } |
| 1360 } | 1362 } |
| 1361 EXPECT_EQ("B", body); | 1363 EXPECT_EQ("B", body); |
| 1362 } | 1364 } |
| 1363 | 1365 |
| 1364 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, | 1366 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, |
| 1365 MojoAsyncResourceHandlerWithAllocationSizeTest, | 1367 MojoAsyncResourceHandlerWithAllocationSizeTest, |
| 1366 ::testing::Values(8, 32 * 2014)); | 1368 ::testing::Values(8, 32 * 2014)); |
| 1367 } // namespace | 1369 } // namespace |
| 1368 } // namespace content | 1370 } // namespace content |
| OLD | NEW |