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