| 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/url_loader_factory_impl.h" | 5 #include "content/browser/loader/url_loader_factory_impl.h" |
| 6 | 6 |
| 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 8 #include "content/browser/loader/resource_message_filter.h" | 8 #include "content/browser/loader/resource_message_filter.h" |
| 9 #include "content/common/resource_request.h" | 9 #include "content/common/resource_request.h" |
| 10 #include "content/common/url_loader.mojom.h" | 10 #include "content/common/url_loader.mojom.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 URLLoaderFactoryImpl::URLLoaderFactoryImpl( | 16 URLLoaderFactoryImpl::URLLoaderFactoryImpl( |
| 16 scoped_refptr<ResourceMessageFilter> resource_message_filter, | 17 scoped_refptr<ResourceMessageFilter> resource_message_filter) |
| 17 mojo::InterfaceRequest<mojom::URLLoaderFactory> request) | 18 : resource_message_filter_(std::move(resource_message_filter)) { |
| 18 : resource_message_filter_(std::move(resource_message_filter)), | |
| 19 binding_(this, std::move(request)) { | |
| 20 DCHECK(resource_message_filter_); | 19 DCHECK(resource_message_filter_); |
| 21 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 20 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 22 } | 21 } |
| 23 | 22 |
| 24 URLLoaderFactoryImpl::~URLLoaderFactoryImpl() { | 23 URLLoaderFactoryImpl::~URLLoaderFactoryImpl() { |
| 25 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 24 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void URLLoaderFactoryImpl::CreateLoaderAndStart( | 27 void URLLoaderFactoryImpl::CreateLoaderAndStart( |
| 29 mojom::URLLoaderRequest request, | 28 mojom::URLLoaderRequest request, |
| 30 int32_t request_id, | 29 int32_t request_id, |
| 31 const ResourceRequest& url_request, | 30 const ResourceRequest& url_request, |
| 32 mojom::URLLoaderClientPtr client) { | 31 mojom::URLLoaderClientPtr client) { |
| 33 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 32 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 34 | 33 |
| 35 // TODO(yhirano): Provide the right routing ID. | 34 // TODO(yhirano): Provide the right routing ID. |
| 36 const int routing_id = 0; | 35 const int routing_id = 0; |
| 37 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 36 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 38 rdh->OnRequestResourceWithMojo(routing_id, request_id, url_request, | 37 rdh->OnRequestResourceWithMojo(routing_id, request_id, url_request, |
| 39 std::move(request), std::move(client), | 38 std::move(request), std::move(client), |
| 40 resource_message_filter_.get()); | 39 resource_message_filter_.get()); |
| 41 } | 40 } |
| 42 | 41 |
| 43 void URLLoaderFactoryImpl::Create( | 42 void URLLoaderFactoryImpl::Create( |
| 44 scoped_refptr<ResourceMessageFilter> filter, | 43 scoped_refptr<ResourceMessageFilter> filter, |
| 45 mojo::InterfaceRequest<mojom::URLLoaderFactory> request) { | 44 mojo::InterfaceRequest<mojom::URLLoaderFactory> request) { |
| 46 // The created instance is held by the StrongBinding. | 45 mojo::MakeStrongBinding( |
| 47 new URLLoaderFactoryImpl(std::move(filter), std::move(request)); | 46 base::WrapUnique(new URLLoaderFactoryImpl(std::move(filter))), |
| 47 std::move(request)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace content | 50 } // namespace content |
| OLD | NEW |