| 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/downloaded_temp_file_impl.h" | 5 #include "content/browser/loader/downloaded_temp_file_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 8 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 9 #include "mojo/public/cpp/bindings/strong_associated_binding.h" | |
| 10 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 11 | 10 |
| 12 namespace content { | 11 namespace content { |
| 13 | 12 |
| 14 // static | 13 // static |
| 15 mojom::DownloadedTempFileAssociatedPtrInfo DownloadedTempFileImpl::Create( | 14 mojom::DownloadedTempFilePtr DownloadedTempFileImpl::Create(int child_id, |
| 16 int child_id, | 15 int request_id) { |
| 17 int request_id) { | |
| 18 mojo::AssociatedInterfacePtrInfo<mojom::DownloadedTempFile> ptr_info; | |
| 19 auto request = mojo::MakeRequest(&ptr_info); | |
| 20 mojo::MakeStrongAssociatedBinding( | |
| 21 base::MakeUnique<DownloadedTempFileImpl>(child_id, request_id), | |
| 22 std::move(request)); | |
| 23 return ptr_info; | |
| 24 } | |
| 25 | |
| 26 // static | |
| 27 mojom::DownloadedTempFilePtr DownloadedTempFileImpl::CreateForTesting( | |
| 28 int child_id, | |
| 29 int request_id) { | |
| 30 mojo::InterfacePtr<mojom::DownloadedTempFile> ptr; | 16 mojo::InterfacePtr<mojom::DownloadedTempFile> ptr; |
| 31 mojo::MakeStrongBinding( | 17 mojo::MakeStrongBinding( |
| 32 base::MakeUnique<DownloadedTempFileImpl>(child_id, request_id), | 18 base::MakeUnique<DownloadedTempFileImpl>(child_id, request_id), |
| 33 mojo::MakeRequest(&ptr)); | 19 mojo::MakeRequest(&ptr)); |
| 34 return ptr; | 20 return ptr; |
| 35 } | 21 } |
| 36 | 22 |
| 37 DownloadedTempFileImpl::~DownloadedTempFileImpl() { | 23 DownloadedTempFileImpl::~DownloadedTempFileImpl() { |
| 38 ResourceDispatcherHostImpl::Get()->UnregisterDownloadedTempFile(child_id_, | 24 ResourceDispatcherHostImpl::Get()->UnregisterDownloadedTempFile(child_id_, |
| 39 request_id_); | 25 request_id_); |
| 40 } | 26 } |
| 41 DownloadedTempFileImpl::DownloadedTempFileImpl(int child_id, int request_id) | 27 DownloadedTempFileImpl::DownloadedTempFileImpl(int child_id, int request_id) |
| 42 : child_id_(child_id), request_id_(request_id) {} | 28 : child_id_(child_id), request_id_(request_id) {} |
| 43 | 29 |
| 44 } // namespace content | 30 } // namespace content |
| OLD | NEW |