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