Chromium Code Reviews| 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 "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 8 #include "mojo/public/cpp/bindings/associated_group.h" | |
| 9 #include "mojo/public/cpp/bindings/strong_associated_binding.h" | |
| 8 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 9 | 11 |
| 10 namespace content { | 12 namespace content { |
| 11 | 13 |
| 12 // static | 14 // static |
| 13 mojo::InterfacePtr<mojom::DownloadedTempFile> DownloadedTempFileImpl::Create( | 15 mojom::DownloadedTempFileAssociatedPtrInfo DownloadedTempFileImpl::Create( |
| 16 mojo::AssociatedGroup* associated_group, | |
| 17 int child_id, | |
| 18 int request_id) { | |
| 19 mojo::AssociatedInterfacePtrInfo<mojom::DownloadedTempFile> ptr_info; | |
| 20 mojo::AssociatedInterfaceRequest<mojom::DownloadedTempFile> request; | |
| 21 associated_group->CreateAssociatedInterface( | |
| 22 mojo::AssociatedGroup::WILL_PASS_PTR, &ptr_info, &request); | |
| 23 mojo::MakeStrongAssociatedBinding( | |
| 24 base::MakeUnique<DownloadedTempFileImpl>(child_id, request_id), | |
| 25 std::move(request)); | |
|
mmenke
2016/12/15 16:48:19
Sorry for all the round trips, but I really have n
mmenke
2016/12/15 16:51:08
And if we want Mojo to be the way for everyone to
tzik
2017/01/05 10:47:56
Hmm, I don't have good explanation that.
Yuzhu: Co
yzshen1
2017/01/13 15:55:03
AssociatedInterfacePtrInfo is the "handle" that co
mmenke
2017/01/13 17:48:33
I agree with this, which is why I was shocked to f
| |
| 26 return ptr_info; | |
| 27 } | |
| 28 | |
| 29 // static | |
| 30 mojom::DownloadedTempFilePtr DownloadedTempFileImpl::CreateForTesting( | |
| 14 int child_id, | 31 int child_id, |
| 15 int request_id) { | 32 int request_id) { |
| 16 mojo::InterfacePtr<mojom::DownloadedTempFile> ptr; | 33 mojo::InterfacePtr<mojom::DownloadedTempFile> ptr; |
| 17 auto binding = mojo::MakeStrongBinding( | 34 mojo::MakeStrongBinding( |
| 18 base::MakeUnique<DownloadedTempFileImpl>(child_id, request_id), | 35 base::MakeUnique<DownloadedTempFileImpl>(child_id, request_id), |
| 19 mojo::GetProxy(&ptr)); | 36 mojo::GetProxy(&ptr)); |
| 20 return ptr; | 37 return ptr; |
| 21 } | 38 } |
| 22 | 39 |
| 23 DownloadedTempFileImpl::~DownloadedTempFileImpl() { | 40 DownloadedTempFileImpl::~DownloadedTempFileImpl() { |
| 24 ResourceDispatcherHostImpl::Get()->UnregisterDownloadedTempFile(child_id_, | 41 ResourceDispatcherHostImpl::Get()->UnregisterDownloadedTempFile(child_id_, |
| 25 request_id_); | 42 request_id_); |
| 26 } | 43 } |
| 27 DownloadedTempFileImpl::DownloadedTempFileImpl(int child_id, int request_id) | 44 DownloadedTempFileImpl::DownloadedTempFileImpl(int child_id, int request_id) |
| 28 : child_id_(child_id), request_id_(request_id) {} | 45 : child_id_(child_id), request_id_(request_id) {} |
| 29 | 46 |
| 30 } // namespace content | 47 } // namespace content |
| OLD | NEW |