| 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/renderer/mojo/blink_service_registry_impl.h" | 5 #include "content/renderer/mojo/blink_service_registry_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" |
| 9 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "content/common/mojo/service_registry_impl.h" | 12 #include "services/shell/public/cpp/interface_provider.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 BlinkServiceRegistryImpl::BlinkServiceRegistryImpl( | 16 BlinkServiceRegistryImpl::BlinkServiceRegistryImpl( |
| 16 base::WeakPtr<content::ServiceRegistry> service_registry) | 17 base::WeakPtr<shell::InterfaceProvider> remote_interfaces) |
| 17 : service_registry_(service_registry), | 18 : remote_interfaces_(remote_interfaces), |
| 18 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 19 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 19 weak_ptr_factory_(this) {} | 20 weak_ptr_factory_(this) {} |
| 20 | 21 |
| 21 BlinkServiceRegistryImpl::~BlinkServiceRegistryImpl() = default; | 22 BlinkServiceRegistryImpl::~BlinkServiceRegistryImpl() = default; |
| 22 | 23 |
| 23 void BlinkServiceRegistryImpl::connectToRemoteService( | 24 void BlinkServiceRegistryImpl::connectToRemoteService( |
| 24 const char* name, | 25 const char* name, |
| 25 mojo::ScopedMessagePipeHandle handle) { | 26 mojo::ScopedMessagePipeHandle handle) { |
| 26 if (!main_thread_task_runner_->BelongsToCurrentThread()) { | 27 if (!main_thread_task_runner_->BelongsToCurrentThread()) { |
| 27 main_thread_task_runner_->PostTask( | 28 main_thread_task_runner_->PostTask( |
| 28 FROM_HERE, base::Bind(&BlinkServiceRegistryImpl::connectToRemoteService, | 29 FROM_HERE, base::Bind(&BlinkServiceRegistryImpl::connectToRemoteService, |
| 29 weak_ptr_factory_.GetWeakPtr(), name, | 30 weak_ptr_factory_.GetWeakPtr(), name, |
| 30 base::Passed(&handle))); | 31 base::Passed(&handle))); |
| 31 return; | 32 return; |
| 32 } | 33 } |
| 33 | 34 |
| 34 if (!service_registry_) | 35 if (!remote_interfaces_) |
| 35 return; | 36 return; |
| 36 | 37 |
| 37 service_registry_->ConnectToRemoteService(name, std::move(handle)); | 38 remote_interfaces_->GetInterface(name, std::move(handle)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 } // namespace content | 41 } // namespace content |
| OLD | NEW |